From d5197060cd51ad5b9400e691f702a6b5032fc3b1 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 8 Feb 2023 22:53:32 +0000 Subject: [PATCH 1/2] feat: enable "rest" transport in Python for services supporting numeric enums PiperOrigin-RevId: 508143576 Source-Link: https://github.com/googleapis/googleapis/commit/7a702a989db3b413f39ff8994ca53fb38b6928c2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/6ad1279c0e7aa787ac6b66c9fd4a210692edffcd Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNmFkMTI3OWMwZTdhYTc4N2FjNmI2NmM5ZmQ0YTIxMDY5MmVkZmZjZCJ9 --- owl-bot-staging/v1/.coveragerc | 13 + owl-bot-staging/v1/.flake8 | 33 + owl-bot-staging/v1/MANIFEST.in | 2 + owl-bot-staging/v1/README.rst | 49 + .../certificate_manager.rst | 10 + .../docs/certificate_manager_v1/services.rst | 6 + .../v1/docs/certificate_manager_v1/types.rst | 6 + owl-bot-staging/v1/docs/conf.py | 376 + owl-bot-staging/v1/docs/index.rst | 7 + .../cloud/certificate_manager/__init__.py | 99 + .../certificate_manager/gapic_version.py | 16 + .../google/cloud/certificate_manager/py.typed | 2 + .../cloud/certificate_manager_v1/__init__.py | 100 + .../gapic_metadata.json | 388 + .../certificate_manager_v1/gapic_version.py | 16 + .../cloud/certificate_manager_v1/py.typed | 2 + .../services/__init__.py | 15 + .../services/certificate_manager/__init__.py | 22 + .../certificate_manager/async_client.py | 3616 ++++ .../services/certificate_manager/client.py | 3716 ++++ .../services/certificate_manager/pagers.py | 624 + .../transports/__init__.py | 38 + .../certificate_manager/transports/base.py | 677 + .../certificate_manager/transports/grpc.py | 1036 ++ .../transports/grpc_asyncio.py | 1035 ++ .../certificate_manager/transports/rest.py | 3498 ++++ .../certificate_manager_v1/types/__init__.py | 94 + .../types/certificate_issuance_config.py | 318 + .../types/certificate_manager.py | 1514 ++ owl-bot-staging/v1/mypy.ini | 3 + owl-bot-staging/v1/noxfile.py | 184 + ...ficate_manager_create_certificate_async.py | 57 + ...reate_certificate_issuance_config_async.py | 63 + ...create_certificate_issuance_config_sync.py | 63 + ...te_manager_create_certificate_map_async.py | 57 + ...ager_create_certificate_map_entry_async.py | 61 + ...nager_create_certificate_map_entry_sync.py | 61 + ...ate_manager_create_certificate_map_sync.py | 57 + ...ificate_manager_create_certificate_sync.py | 57 + ..._manager_create_dns_authorization_async.py | 61 + ...e_manager_create_dns_authorization_sync.py | 61 + ...ficate_manager_delete_certificate_async.py | 56 + ...elete_certificate_issuance_config_async.py | 56 + ...delete_certificate_issuance_config_sync.py | 56 + ...te_manager_delete_certificate_map_async.py | 56 + ...ager_delete_certificate_map_entry_async.py | 56 + ...nager_delete_certificate_map_entry_sync.py | 56 + ...ate_manager_delete_certificate_map_sync.py | 56 + ...ificate_manager_delete_certificate_sync.py | 56 + ..._manager_delete_dns_authorization_async.py | 56 + ...e_manager_delete_dns_authorization_sync.py | 56 + ...rtificate_manager_get_certificate_async.py | 52 + ...r_get_certificate_issuance_config_async.py | 52 + ...er_get_certificate_issuance_config_sync.py | 52 + ...icate_manager_get_certificate_map_async.py | 52 + ...manager_get_certificate_map_entry_async.py | 52 + ..._manager_get_certificate_map_entry_sync.py | 52 + ...ficate_manager_get_certificate_map_sync.py | 52 + ...ertificate_manager_get_certificate_sync.py | 52 + ...ate_manager_get_dns_authorization_async.py | 52 + ...cate_manager_get_dns_authorization_sync.py | 52 + ...list_certificate_issuance_configs_async.py | 53 + ..._list_certificate_issuance_configs_sync.py | 53 + ...ager_list_certificate_map_entries_async.py | 53 + ...nager_list_certificate_map_entries_sync.py | 53 + ...ate_manager_list_certificate_maps_async.py | 53 + ...cate_manager_list_certificate_maps_sync.py | 53 + ...ificate_manager_list_certificates_async.py | 53 + ...tificate_manager_list_certificates_sync.py | 53 + ...e_manager_list_dns_authorizations_async.py | 53 + ...te_manager_list_dns_authorizations_sync.py | 53 + ...ficate_manager_update_certificate_async.py | 55 + ...te_manager_update_certificate_map_async.py | 55 + ...ager_update_certificate_map_entry_async.py | 59 + ...nager_update_certificate_map_entry_sync.py | 59 + ...ate_manager_update_certificate_map_sync.py | 55 + ...ificate_manager_update_certificate_sync.py | 55 + ..._manager_update_dns_authorization_async.py | 59 + ...e_manager_update_dns_authorization_sync.py | 59 + ...ta_google.cloud.certificatemanager.v1.json | 3991 ++++ .../fixup_certificate_manager_v1_keywords.py | 199 + owl-bot-staging/v1/setup.py | 90 + .../v1/testing/constraints-3.10.txt | 6 + .../v1/testing/constraints-3.11.txt | 6 + .../v1/testing/constraints-3.12.txt | 6 + .../v1/testing/constraints-3.7.txt | 9 + .../v1/testing/constraints-3.8.txt | 6 + .../v1/testing/constraints-3.9.txt | 6 + 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/certificate_manager_v1/__init__.py | 16 + .../test_certificate_manager.py | 15180 ++++++++++++++++ 93 files changed, 39742 insertions(+) create mode 100644 owl-bot-staging/v1/.coveragerc create mode 100644 owl-bot-staging/v1/.flake8 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/certificate_manager_v1/certificate_manager.rst create mode 100644 owl-bot-staging/v1/docs/certificate_manager_v1/services.rst create mode 100644 owl-bot-staging/v1/docs/certificate_manager_v1/types.rst create mode 100644 owl-bot-staging/v1/docs/conf.py create mode 100644 owl-bot-staging/v1/docs/index.rst create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager/gapic_version.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_version.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/async_client.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/client.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/pagers.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/base.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_issuance_config.py create mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_manager.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/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_async.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_sync.py create mode 100644 owl-bot-staging/v1/samples/generated_samples/snippet_metadata_google.cloud.certificatemanager.v1.json create mode 100644 owl-bot-staging/v1/scripts/fixup_certificate_manager_v1_keywords.py create mode 100644 owl-bot-staging/v1/setup.py create mode 100644 owl-bot-staging/v1/testing/constraints-3.10.txt create mode 100644 owl-bot-staging/v1/testing/constraints-3.11.txt create mode 100644 owl-bot-staging/v1/testing/constraints-3.12.txt create mode 100644 owl-bot-staging/v1/testing/constraints-3.7.txt create mode 100644 owl-bot-staging/v1/testing/constraints-3.8.txt create mode 100644 owl-bot-staging/v1/testing/constraints-3.9.txt 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/certificate_manager_v1/__init__.py create mode 100644 owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py diff --git a/owl-bot-staging/v1/.coveragerc b/owl-bot-staging/v1/.coveragerc new file mode 100644 index 0000000..ca7b438 --- /dev/null +++ b/owl-bot-staging/v1/.coveragerc @@ -0,0 +1,13 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/certificate_manager/__init__.py + google/cloud/certificate_manager/gapic_version.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ diff --git a/owl-bot-staging/v1/.flake8 b/owl-bot-staging/v1/.flake8 new file mode 100644 index 0000000..29227d4 --- /dev/null +++ b/owl-bot-staging/v1/.flake8 @@ -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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Generated by synthtool. DO NOT EDIT! +[flake8] +ignore = E203, E266, E501, W503 +exclude = + # Exclude generated code. + **/proto/** + **/gapic/** + **/services/** + **/types/** + *_pb2.py + + # Standard linting exemptions. + **/.nox/** + __pycache__, + .git, + *.pyc, + conf.py diff --git a/owl-bot-staging/v1/MANIFEST.in b/owl-bot-staging/v1/MANIFEST.in new file mode 100644 index 0000000..7f4b675 --- /dev/null +++ b/owl-bot-staging/v1/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/certificate_manager *.py +recursive-include google/cloud/certificate_manager_v1 *.py diff --git a/owl-bot-staging/v1/README.rst b/owl-bot-staging/v1/README.rst new file mode 100644 index 0000000..531c68e --- /dev/null +++ b/owl-bot-staging/v1/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Certificate Manager 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 Certificate Manager 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/certificate_manager_v1/certificate_manager.rst b/owl-bot-staging/v1/docs/certificate_manager_v1/certificate_manager.rst new file mode 100644 index 0000000..46e71d3 --- /dev/null +++ b/owl-bot-staging/v1/docs/certificate_manager_v1/certificate_manager.rst @@ -0,0 +1,10 @@ +CertificateManager +------------------------------------ + +.. automodule:: google.cloud.certificate_manager_v1.services.certificate_manager + :members: + :inherited-members: + +.. automodule:: google.cloud.certificate_manager_v1.services.certificate_manager.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v1/docs/certificate_manager_v1/services.rst b/owl-bot-staging/v1/docs/certificate_manager_v1/services.rst new file mode 100644 index 0000000..e52959e --- /dev/null +++ b/owl-bot-staging/v1/docs/certificate_manager_v1/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Certificate Manager v1 API +==================================================== +.. toctree:: + :maxdepth: 2 + + certificate_manager diff --git a/owl-bot-staging/v1/docs/certificate_manager_v1/types.rst b/owl-bot-staging/v1/docs/certificate_manager_v1/types.rst new file mode 100644 index 0000000..cb69a66 --- /dev/null +++ b/owl-bot-staging/v1/docs/certificate_manager_v1/types.rst @@ -0,0 +1,6 @@ +Types for Google Cloud Certificate Manager v1 API +================================================= + +.. automodule:: google.cloud.certificate_manager_v1.types + :members: + :show-inheritance: diff --git a/owl-bot-staging/v1/docs/conf.py b/owl-bot-staging/v1/docs/conf.py new file mode 100644 index 0000000..b7f32aa --- /dev/null +++ b/owl-bot-staging/v1/docs/conf.py @@ -0,0 +1,376 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# google-cloud-certificate-manager 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 = "4.0.1" + +# 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 root toctree document. +root_doc = "index" + +# General information about the project. +project = u"google-cloud-certificate-manager" +copyright = u"2022, 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-certificate-manager-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 = [ + ( + root_doc, + "google-cloud-certificate-manager.tex", + u"google-cloud-certificate-manager 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 = [ + ( + root_doc, + "google-cloud-certificate-manager", + u"Google Cloud Certificate Manager 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 = [ + ( + root_doc, + "google-cloud-certificate-manager", + u"google-cloud-certificate-manager Documentation", + author, + "google-cloud-certificate-manager", + "GAPIC library for Google Cloud Certificate Manager 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 new file mode 100644 index 0000000..b0ad281 --- /dev/null +++ b/owl-bot-staging/v1/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + certificate_manager_v1/services + certificate_manager_v1/types diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager/__init__.py b/owl-bot-staging/v1/google/cloud/certificate_manager/__init__.py new file mode 100644 index 0000000..0a9d6ba --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager/__init__.py @@ -0,0 +1,99 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from google.cloud.certificate_manager import gapic_version as package_version + +__version__ = package_version.__version__ + + +from google.cloud.certificate_manager_v1.services.certificate_manager.client import CertificateManagerClient +from google.cloud.certificate_manager_v1.services.certificate_manager.async_client import CertificateManagerAsyncClient + +from google.cloud.certificate_manager_v1.types.certificate_issuance_config import CertificateIssuanceConfig +from google.cloud.certificate_manager_v1.types.certificate_issuance_config import CreateCertificateIssuanceConfigRequest +from google.cloud.certificate_manager_v1.types.certificate_issuance_config import DeleteCertificateIssuanceConfigRequest +from google.cloud.certificate_manager_v1.types.certificate_issuance_config import GetCertificateIssuanceConfigRequest +from google.cloud.certificate_manager_v1.types.certificate_issuance_config import ListCertificateIssuanceConfigsRequest +from google.cloud.certificate_manager_v1.types.certificate_issuance_config import ListCertificateIssuanceConfigsResponse +from google.cloud.certificate_manager_v1.types.certificate_manager import Certificate +from google.cloud.certificate_manager_v1.types.certificate_manager import CertificateMap +from google.cloud.certificate_manager_v1.types.certificate_manager import CertificateMapEntry +from google.cloud.certificate_manager_v1.types.certificate_manager import CreateCertificateMapEntryRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import CreateCertificateMapRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import CreateCertificateRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import CreateDnsAuthorizationRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import DeleteCertificateMapEntryRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import DeleteCertificateMapRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import DeleteCertificateRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import DeleteDnsAuthorizationRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import DnsAuthorization +from google.cloud.certificate_manager_v1.types.certificate_manager import GetCertificateMapEntryRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import GetCertificateMapRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import GetCertificateRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import GetDnsAuthorizationRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import ListCertificateMapEntriesRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import ListCertificateMapEntriesResponse +from google.cloud.certificate_manager_v1.types.certificate_manager import ListCertificateMapsRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import ListCertificateMapsResponse +from google.cloud.certificate_manager_v1.types.certificate_manager import ListCertificatesRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import ListCertificatesResponse +from google.cloud.certificate_manager_v1.types.certificate_manager import ListDnsAuthorizationsRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import ListDnsAuthorizationsResponse +from google.cloud.certificate_manager_v1.types.certificate_manager import OperationMetadata +from google.cloud.certificate_manager_v1.types.certificate_manager import UpdateCertificateMapEntryRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import UpdateCertificateMapRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import UpdateCertificateRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import UpdateDnsAuthorizationRequest +from google.cloud.certificate_manager_v1.types.certificate_manager import ServingState + +__all__ = ('CertificateManagerClient', + 'CertificateManagerAsyncClient', + 'CertificateIssuanceConfig', + 'CreateCertificateIssuanceConfigRequest', + 'DeleteCertificateIssuanceConfigRequest', + 'GetCertificateIssuanceConfigRequest', + 'ListCertificateIssuanceConfigsRequest', + 'ListCertificateIssuanceConfigsResponse', + 'Certificate', + 'CertificateMap', + 'CertificateMapEntry', + 'CreateCertificateMapEntryRequest', + 'CreateCertificateMapRequest', + 'CreateCertificateRequest', + 'CreateDnsAuthorizationRequest', + 'DeleteCertificateMapEntryRequest', + 'DeleteCertificateMapRequest', + 'DeleteCertificateRequest', + 'DeleteDnsAuthorizationRequest', + 'DnsAuthorization', + 'GetCertificateMapEntryRequest', + 'GetCertificateMapRequest', + 'GetCertificateRequest', + 'GetDnsAuthorizationRequest', + 'ListCertificateMapEntriesRequest', + 'ListCertificateMapEntriesResponse', + 'ListCertificateMapsRequest', + 'ListCertificateMapsResponse', + 'ListCertificatesRequest', + 'ListCertificatesResponse', + 'ListDnsAuthorizationsRequest', + 'ListDnsAuthorizationsResponse', + 'OperationMetadata', + 'UpdateCertificateMapEntryRequest', + 'UpdateCertificateMapRequest', + 'UpdateCertificateRequest', + 'UpdateDnsAuthorizationRequest', + 'ServingState', +) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager/gapic_version.py b/owl-bot-staging/v1/google/cloud/certificate_manager/gapic_version.py new file mode 100644 index 0000000..405b1ce --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +__version__ = "0.1.0" # {x-release-please-version} diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager/py.typed b/owl-bot-staging/v1/google/cloud/certificate_manager/py.typed new file mode 100644 index 0000000..9e0b37d --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-certificate-manager package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/__init__.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/__init__.py new file mode 100644 index 0000000..6134c17 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/__init__.py @@ -0,0 +1,100 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from google.cloud.certificate_manager_v1 import gapic_version as package_version + +__version__ = package_version.__version__ + + +from .services.certificate_manager import CertificateManagerClient +from .services.certificate_manager import CertificateManagerAsyncClient + +from .types.certificate_issuance_config import CertificateIssuanceConfig +from .types.certificate_issuance_config import CreateCertificateIssuanceConfigRequest +from .types.certificate_issuance_config import DeleteCertificateIssuanceConfigRequest +from .types.certificate_issuance_config import GetCertificateIssuanceConfigRequest +from .types.certificate_issuance_config import ListCertificateIssuanceConfigsRequest +from .types.certificate_issuance_config import ListCertificateIssuanceConfigsResponse +from .types.certificate_manager import Certificate +from .types.certificate_manager import CertificateMap +from .types.certificate_manager import CertificateMapEntry +from .types.certificate_manager import CreateCertificateMapEntryRequest +from .types.certificate_manager import CreateCertificateMapRequest +from .types.certificate_manager import CreateCertificateRequest +from .types.certificate_manager import CreateDnsAuthorizationRequest +from .types.certificate_manager import DeleteCertificateMapEntryRequest +from .types.certificate_manager import DeleteCertificateMapRequest +from .types.certificate_manager import DeleteCertificateRequest +from .types.certificate_manager import DeleteDnsAuthorizationRequest +from .types.certificate_manager import DnsAuthorization +from .types.certificate_manager import GetCertificateMapEntryRequest +from .types.certificate_manager import GetCertificateMapRequest +from .types.certificate_manager import GetCertificateRequest +from .types.certificate_manager import GetDnsAuthorizationRequest +from .types.certificate_manager import ListCertificateMapEntriesRequest +from .types.certificate_manager import ListCertificateMapEntriesResponse +from .types.certificate_manager import ListCertificateMapsRequest +from .types.certificate_manager import ListCertificateMapsResponse +from .types.certificate_manager import ListCertificatesRequest +from .types.certificate_manager import ListCertificatesResponse +from .types.certificate_manager import ListDnsAuthorizationsRequest +from .types.certificate_manager import ListDnsAuthorizationsResponse +from .types.certificate_manager import OperationMetadata +from .types.certificate_manager import UpdateCertificateMapEntryRequest +from .types.certificate_manager import UpdateCertificateMapRequest +from .types.certificate_manager import UpdateCertificateRequest +from .types.certificate_manager import UpdateDnsAuthorizationRequest +from .types.certificate_manager import ServingState + +__all__ = ( + 'CertificateManagerAsyncClient', +'Certificate', +'CertificateIssuanceConfig', +'CertificateManagerClient', +'CertificateMap', +'CertificateMapEntry', +'CreateCertificateIssuanceConfigRequest', +'CreateCertificateMapEntryRequest', +'CreateCertificateMapRequest', +'CreateCertificateRequest', +'CreateDnsAuthorizationRequest', +'DeleteCertificateIssuanceConfigRequest', +'DeleteCertificateMapEntryRequest', +'DeleteCertificateMapRequest', +'DeleteCertificateRequest', +'DeleteDnsAuthorizationRequest', +'DnsAuthorization', +'GetCertificateIssuanceConfigRequest', +'GetCertificateMapEntryRequest', +'GetCertificateMapRequest', +'GetCertificateRequest', +'GetDnsAuthorizationRequest', +'ListCertificateIssuanceConfigsRequest', +'ListCertificateIssuanceConfigsResponse', +'ListCertificateMapEntriesRequest', +'ListCertificateMapEntriesResponse', +'ListCertificateMapsRequest', +'ListCertificateMapsResponse', +'ListCertificatesRequest', +'ListCertificatesResponse', +'ListDnsAuthorizationsRequest', +'ListDnsAuthorizationsResponse', +'OperationMetadata', +'ServingState', +'UpdateCertificateMapEntryRequest', +'UpdateCertificateMapRequest', +'UpdateCertificateRequest', +'UpdateDnsAuthorizationRequest', +) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_metadata.json b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_metadata.json new file mode 100644 index 0000000..0c07957 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_metadata.json @@ -0,0 +1,388 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.certificate_manager_v1", + "protoPackage": "google.cloud.certificatemanager.v1", + "schema": "1.0", + "services": { + "CertificateManager": { + "clients": { + "grpc": { + "libraryClient": "CertificateManagerClient", + "rpcs": { + "CreateCertificate": { + "methods": [ + "create_certificate" + ] + }, + "CreateCertificateIssuanceConfig": { + "methods": [ + "create_certificate_issuance_config" + ] + }, + "CreateCertificateMap": { + "methods": [ + "create_certificate_map" + ] + }, + "CreateCertificateMapEntry": { + "methods": [ + "create_certificate_map_entry" + ] + }, + "CreateDnsAuthorization": { + "methods": [ + "create_dns_authorization" + ] + }, + "DeleteCertificate": { + "methods": [ + "delete_certificate" + ] + }, + "DeleteCertificateIssuanceConfig": { + "methods": [ + "delete_certificate_issuance_config" + ] + }, + "DeleteCertificateMap": { + "methods": [ + "delete_certificate_map" + ] + }, + "DeleteCertificateMapEntry": { + "methods": [ + "delete_certificate_map_entry" + ] + }, + "DeleteDnsAuthorization": { + "methods": [ + "delete_dns_authorization" + ] + }, + "GetCertificate": { + "methods": [ + "get_certificate" + ] + }, + "GetCertificateIssuanceConfig": { + "methods": [ + "get_certificate_issuance_config" + ] + }, + "GetCertificateMap": { + "methods": [ + "get_certificate_map" + ] + }, + "GetCertificateMapEntry": { + "methods": [ + "get_certificate_map_entry" + ] + }, + "GetDnsAuthorization": { + "methods": [ + "get_dns_authorization" + ] + }, + "ListCertificateIssuanceConfigs": { + "methods": [ + "list_certificate_issuance_configs" + ] + }, + "ListCertificateMapEntries": { + "methods": [ + "list_certificate_map_entries" + ] + }, + "ListCertificateMaps": { + "methods": [ + "list_certificate_maps" + ] + }, + "ListCertificates": { + "methods": [ + "list_certificates" + ] + }, + "ListDnsAuthorizations": { + "methods": [ + "list_dns_authorizations" + ] + }, + "UpdateCertificate": { + "methods": [ + "update_certificate" + ] + }, + "UpdateCertificateMap": { + "methods": [ + "update_certificate_map" + ] + }, + "UpdateCertificateMapEntry": { + "methods": [ + "update_certificate_map_entry" + ] + }, + "UpdateDnsAuthorization": { + "methods": [ + "update_dns_authorization" + ] + } + } + }, + "grpc-async": { + "libraryClient": "CertificateManagerAsyncClient", + "rpcs": { + "CreateCertificate": { + "methods": [ + "create_certificate" + ] + }, + "CreateCertificateIssuanceConfig": { + "methods": [ + "create_certificate_issuance_config" + ] + }, + "CreateCertificateMap": { + "methods": [ + "create_certificate_map" + ] + }, + "CreateCertificateMapEntry": { + "methods": [ + "create_certificate_map_entry" + ] + }, + "CreateDnsAuthorization": { + "methods": [ + "create_dns_authorization" + ] + }, + "DeleteCertificate": { + "methods": [ + "delete_certificate" + ] + }, + "DeleteCertificateIssuanceConfig": { + "methods": [ + "delete_certificate_issuance_config" + ] + }, + "DeleteCertificateMap": { + "methods": [ + "delete_certificate_map" + ] + }, + "DeleteCertificateMapEntry": { + "methods": [ + "delete_certificate_map_entry" + ] + }, + "DeleteDnsAuthorization": { + "methods": [ + "delete_dns_authorization" + ] + }, + "GetCertificate": { + "methods": [ + "get_certificate" + ] + }, + "GetCertificateIssuanceConfig": { + "methods": [ + "get_certificate_issuance_config" + ] + }, + "GetCertificateMap": { + "methods": [ + "get_certificate_map" + ] + }, + "GetCertificateMapEntry": { + "methods": [ + "get_certificate_map_entry" + ] + }, + "GetDnsAuthorization": { + "methods": [ + "get_dns_authorization" + ] + }, + "ListCertificateIssuanceConfigs": { + "methods": [ + "list_certificate_issuance_configs" + ] + }, + "ListCertificateMapEntries": { + "methods": [ + "list_certificate_map_entries" + ] + }, + "ListCertificateMaps": { + "methods": [ + "list_certificate_maps" + ] + }, + "ListCertificates": { + "methods": [ + "list_certificates" + ] + }, + "ListDnsAuthorizations": { + "methods": [ + "list_dns_authorizations" + ] + }, + "UpdateCertificate": { + "methods": [ + "update_certificate" + ] + }, + "UpdateCertificateMap": { + "methods": [ + "update_certificate_map" + ] + }, + "UpdateCertificateMapEntry": { + "methods": [ + "update_certificate_map_entry" + ] + }, + "UpdateDnsAuthorization": { + "methods": [ + "update_dns_authorization" + ] + } + } + }, + "rest": { + "libraryClient": "CertificateManagerClient", + "rpcs": { + "CreateCertificate": { + "methods": [ + "create_certificate" + ] + }, + "CreateCertificateIssuanceConfig": { + "methods": [ + "create_certificate_issuance_config" + ] + }, + "CreateCertificateMap": { + "methods": [ + "create_certificate_map" + ] + }, + "CreateCertificateMapEntry": { + "methods": [ + "create_certificate_map_entry" + ] + }, + "CreateDnsAuthorization": { + "methods": [ + "create_dns_authorization" + ] + }, + "DeleteCertificate": { + "methods": [ + "delete_certificate" + ] + }, + "DeleteCertificateIssuanceConfig": { + "methods": [ + "delete_certificate_issuance_config" + ] + }, + "DeleteCertificateMap": { + "methods": [ + "delete_certificate_map" + ] + }, + "DeleteCertificateMapEntry": { + "methods": [ + "delete_certificate_map_entry" + ] + }, + "DeleteDnsAuthorization": { + "methods": [ + "delete_dns_authorization" + ] + }, + "GetCertificate": { + "methods": [ + "get_certificate" + ] + }, + "GetCertificateIssuanceConfig": { + "methods": [ + "get_certificate_issuance_config" + ] + }, + "GetCertificateMap": { + "methods": [ + "get_certificate_map" + ] + }, + "GetCertificateMapEntry": { + "methods": [ + "get_certificate_map_entry" + ] + }, + "GetDnsAuthorization": { + "methods": [ + "get_dns_authorization" + ] + }, + "ListCertificateIssuanceConfigs": { + "methods": [ + "list_certificate_issuance_configs" + ] + }, + "ListCertificateMapEntries": { + "methods": [ + "list_certificate_map_entries" + ] + }, + "ListCertificateMaps": { + "methods": [ + "list_certificate_maps" + ] + }, + "ListCertificates": { + "methods": [ + "list_certificates" + ] + }, + "ListDnsAuthorizations": { + "methods": [ + "list_dns_authorizations" + ] + }, + "UpdateCertificate": { + "methods": [ + "update_certificate" + ] + }, + "UpdateCertificateMap": { + "methods": [ + "update_certificate_map" + ] + }, + "UpdateCertificateMapEntry": { + "methods": [ + "update_certificate_map_entry" + ] + }, + "UpdateDnsAuthorization": { + "methods": [ + "update_dns_authorization" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_version.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_version.py new file mode 100644 index 0000000..405b1ce --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +__version__ = "0.1.0" # {x-release-please-version} diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/py.typed b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/py.typed new file mode 100644 index 0000000..9e0b37d --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-certificate-manager package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/__init__.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/__init__.py new file mode 100644 index 0000000..e8e1c38 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/__init__.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/__init__.py new file mode 100644 index 0000000..b41279d --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from .client import CertificateManagerClient +from .async_client import CertificateManagerAsyncClient + +__all__ = ( + 'CertificateManagerClient', + 'CertificateManagerAsyncClient', +) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/async_client.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/async_client.py new file mode 100644 index 0000000..da2753e --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/async_client.py @@ -0,0 +1,3616 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +import functools +import re +from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union + +from google.cloud.certificate_manager_v1 import gapic_version as package_version + +from google.api_core.client_options import ClientOptions +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.certificate_manager_v1.services.certificate_manager import pagers +from google.cloud.certificate_manager_v1.types import certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_manager +from google.cloud.location import locations_pb2 # type: ignore +from google.longrunning import operations_pb2 +from google.protobuf import duration_pb2 # type: ignore +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 CertificateManagerTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import CertificateManagerGrpcAsyncIOTransport +from .client import CertificateManagerClient + + +class CertificateManagerAsyncClient: + """API Overview + + Certificates Manager API allows customers to see and manage all + their TLS certificates. + + Certificates Manager API service provides methods to manage + certificates, group them into collections, and create serving + configuration that can be easily applied to other Cloud resources + e.g. Target Proxies. + + Data Model + + The Certificates Manager service exposes the following resources: + + - ``Certificate`` that describes a single TLS certificate. + - ``CertificateMap`` that describes a collection of certificates + that can be attached to a target resource. + - ``CertificateMapEntry`` that describes a single configuration + entry that consists of a SNI and a group of certificates. It's a + subresource of CertificateMap. + + Certificate, CertificateMap and CertificateMapEntry IDs have to + fully match the regexp ``[a-z0-9-]{1,63}``. In other words, + + - only lower case letters, digits, and hyphen are allowed + - length of the resource ID has to be in [1,63] range. + + Provides methods to manage Cloud Certificate Manager entities. + """ + + _client: CertificateManagerClient + + DEFAULT_ENDPOINT = CertificateManagerClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = CertificateManagerClient.DEFAULT_MTLS_ENDPOINT + + ca_pool_path = staticmethod(CertificateManagerClient.ca_pool_path) + parse_ca_pool_path = staticmethod(CertificateManagerClient.parse_ca_pool_path) + certificate_path = staticmethod(CertificateManagerClient.certificate_path) + parse_certificate_path = staticmethod(CertificateManagerClient.parse_certificate_path) + certificate_issuance_config_path = staticmethod(CertificateManagerClient.certificate_issuance_config_path) + parse_certificate_issuance_config_path = staticmethod(CertificateManagerClient.parse_certificate_issuance_config_path) + certificate_map_path = staticmethod(CertificateManagerClient.certificate_map_path) + parse_certificate_map_path = staticmethod(CertificateManagerClient.parse_certificate_map_path) + certificate_map_entry_path = staticmethod(CertificateManagerClient.certificate_map_entry_path) + parse_certificate_map_entry_path = staticmethod(CertificateManagerClient.parse_certificate_map_entry_path) + dns_authorization_path = staticmethod(CertificateManagerClient.dns_authorization_path) + parse_dns_authorization_path = staticmethod(CertificateManagerClient.parse_dns_authorization_path) + common_billing_account_path = staticmethod(CertificateManagerClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(CertificateManagerClient.parse_common_billing_account_path) + common_folder_path = staticmethod(CertificateManagerClient.common_folder_path) + parse_common_folder_path = staticmethod(CertificateManagerClient.parse_common_folder_path) + common_organization_path = staticmethod(CertificateManagerClient.common_organization_path) + parse_common_organization_path = staticmethod(CertificateManagerClient.parse_common_organization_path) + common_project_path = staticmethod(CertificateManagerClient.common_project_path) + parse_common_project_path = staticmethod(CertificateManagerClient.parse_common_project_path) + common_location_path = staticmethod(CertificateManagerClient.common_location_path) + parse_common_location_path = staticmethod(CertificateManagerClient.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: + CertificateManagerAsyncClient: The constructed client. + """ + return CertificateManagerClient.from_service_account_info.__func__(CertificateManagerAsyncClient, 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: + CertificateManagerAsyncClient: The constructed client. + """ + return CertificateManagerClient.from_service_account_file.__func__(CertificateManagerAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @classmethod + def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[ClientOptions] = None): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variable is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return CertificateManagerClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> CertificateManagerTransport: + """Returns the transport used by the client instance. + + Returns: + CertificateManagerTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(CertificateManagerClient).get_transport_class, type(CertificateManagerClient)) + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, CertificateManagerTransport] = "grpc_asyncio", + client_options: Optional[ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the certificate manager 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, ~.CertificateManagerTransport]): 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 = CertificateManagerClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def list_certificates(self, + request: Optional[Union[certificate_manager.ListCertificatesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificatesAsyncPager: + r"""Lists Certificates in a given project and location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_list_certificates(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificatesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificates(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.ListCertificatesRequest, dict]]): + The request object. Request for the `ListCertificates` + method. + parent (:class:`str`): + Required. The project and location from which the + certificate should 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificatesAsyncPager: + Response for the ListCertificates method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_manager.ListCertificatesRequest(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_certificates, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("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.ListCertificatesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_certificate(self, + request: Optional[Union[certificate_manager.GetCertificateRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.Certificate: + r"""Gets details of a single Certificate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_get_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateRequest( + name="name_value", + ) + + # Make the request + response = await client.get_certificate(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.GetCertificateRequest, dict]]): + The request object. Request for the `GetCertificate` + method. + name (:class:`str`): + Required. A name of the certificate to describe. Must be + in the format ``projects/*/locations/*/certificates/*``. + + 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.certificate_manager_v1.types.Certificate: + Defines TLS certificate. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_manager.GetCertificateRequest(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_certificate, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_certificate(self, + request: Optional[Union[certificate_manager.CreateCertificateRequest, dict]] = None, + *, + parent: Optional[str] = None, + certificate: Optional[certificate_manager.Certificate] = None, + certificate_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a new Certificate in a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_create_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.CreateCertificateRequest( + parent="parent_value", + certificate_id="certificate_id_value", + ) + + # Make the request + operation = client.create_certificate(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.CreateCertificateRequest, dict]]): + The request object. Request for the `CreateCertificate` + method. + parent (:class:`str`): + Required. The parent resource of the certificate. Must + be in the format ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate (:class:`google.cloud.certificate_manager_v1.types.Certificate`): + Required. A definition of the + certificate to create. + + This corresponds to the ``certificate`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_id (:class:`str`): + Required. A user-provided name of the + certificate. + + This corresponds to the ``certificate_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.certificate_manager_v1.types.Certificate` + Defines TLS certificate. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate, certificate_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 = certificate_manager.CreateCertificateRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate is not None: + request.certificate = certificate + if certificate_id is not None: + request.certificate_id = certificate_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_certificate, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("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, + certificate_manager.Certificate, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_certificate(self, + request: Optional[Union[certificate_manager.UpdateCertificateRequest, dict]] = None, + *, + certificate: Optional[certificate_manager.Certificate] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates a Certificate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_update_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.UpdateCertificateRequest( + ) + + # Make the request + operation = client.update_certificate(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.UpdateCertificateRequest, dict]]): + The request object. Request for the `UpdateCertificate` + method. + certificate (:class:`google.cloud.certificate_manager_v1.types.Certificate`): + Required. A definition of the + certificate to update. + + This corresponds to the ``certificate`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.certificate_manager_v1.types.Certificate` + Defines TLS certificate. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate, 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 = certificate_manager.UpdateCertificateRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate is not None: + request.certificate = certificate + 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_certificate, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("certificate.name", request.certificate.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, + certificate_manager.Certificate, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_certificate(self, + request: Optional[Union[certificate_manager.DeleteCertificateRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes a single Certificate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_delete_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.DeleteCertificateRequest, dict]]): + The request object. Request for the `DeleteCertificate` + method. + name (:class:`str`): + Required. A name of the certificate to delete. Must be + in the format ``projects/*/locations/*/certificates/*``. + + 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); + + } + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_manager.DeleteCertificateRequest(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_certificate, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_certificate_maps(self, + request: Optional[Union[certificate_manager.ListCertificateMapsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateMapsAsyncPager: + r"""Lists CertificateMaps in a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_list_certificate_maps(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificateMapsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificate_maps(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.ListCertificateMapsRequest, dict]]): + The request object. Request for the + `ListCertificateMaps` method. + parent (:class:`str`): + Required. The project and location from which the + certificate maps should 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapsAsyncPager: + Response for the ListCertificateMaps method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_manager.ListCertificateMapsRequest(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_certificate_maps, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("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.ListCertificateMapsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_certificate_map(self, + request: Optional[Union[certificate_manager.GetCertificateMapRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.CertificateMap: + r"""Gets details of a single CertificateMap. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_get_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateMapRequest( + name="name_value", + ) + + # Make the request + response = await client.get_certificate_map(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.GetCertificateMapRequest, dict]]): + The request object. Request for the `GetCertificateMap` + method. + name (:class:`str`): + Required. A name of the certificate map to describe. + Must be in the format + ``projects/*/locations/*/certificateMaps/*``. + + 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.certificate_manager_v1.types.CertificateMap: + Defines a collection of certificate + configurations. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_manager.GetCertificateMapRequest(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_certificate_map, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_certificate_map(self, + request: Optional[Union[certificate_manager.CreateCertificateMapRequest, dict]] = None, + *, + parent: Optional[str] = None, + certificate_map: Optional[certificate_manager.CertificateMap] = None, + certificate_map_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a new CertificateMap in a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_create_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.CreateCertificateMapRequest( + parent="parent_value", + certificate_map_id="certificate_map_id_value", + ) + + # Make the request + operation = client.create_certificate_map(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.CreateCertificateMapRequest, dict]]): + The request object. Request for the + `CreateCertificateMap` method. + parent (:class:`str`): + Required. The parent resource of the certificate map. + Must be in the format ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_map (:class:`google.cloud.certificate_manager_v1.types.CertificateMap`): + Required. A definition of the + certificate map to create. + + This corresponds to the ``certificate_map`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_map_id (:class:`str`): + Required. A user-provided name of the + certificate map. + + This corresponds to the ``certificate_map_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.certificate_manager_v1.types.CertificateMap` + Defines a collection of certificate configurations. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate_map, certificate_map_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 = certificate_manager.CreateCertificateMapRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate_map is not None: + request.certificate_map = certificate_map + if certificate_map_id is not None: + request.certificate_map_id = certificate_map_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_certificate_map, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("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, + certificate_manager.CertificateMap, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_certificate_map(self, + request: Optional[Union[certificate_manager.UpdateCertificateMapRequest, dict]] = None, + *, + certificate_map: Optional[certificate_manager.CertificateMap] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates a CertificateMap. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_update_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.UpdateCertificateMapRequest( + ) + + # Make the request + operation = client.update_certificate_map(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.UpdateCertificateMapRequest, dict]]): + The request object. Request for the + `UpdateCertificateMap` method. + certificate_map (:class:`google.cloud.certificate_manager_v1.types.CertificateMap`): + Required. A definition of the + certificate map to update. + + This corresponds to the ``certificate_map`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.certificate_manager_v1.types.CertificateMap` + Defines a collection of certificate configurations. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_map, 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 = certificate_manager.UpdateCertificateMapRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_map is not None: + request.certificate_map = certificate_map + 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_certificate_map, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("certificate_map.name", request.certificate_map.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, + certificate_manager.CertificateMap, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_certificate_map(self, + request: Optional[Union[certificate_manager.DeleteCertificateMapRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes a single CertificateMap. A Certificate Map + can't be deleted if it contains Certificate Map Entries. + Remove all the entries from the map before calling this + method. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_delete_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateMapRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate_map(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.DeleteCertificateMapRequest, dict]]): + The request object. Request for the + `DeleteCertificateMap` method. + name (:class:`str`): + Required. A name of the certificate map to delete. Must + be in the format + ``projects/*/locations/*/certificateMaps/*``. + + 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); + + } + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_manager.DeleteCertificateMapRequest(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_certificate_map, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_certificate_map_entries(self, + request: Optional[Union[certificate_manager.ListCertificateMapEntriesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateMapEntriesAsyncPager: + r"""Lists CertificateMapEntries in a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_list_certificate_map_entries(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificateMapEntriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificate_map_entries(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesRequest, dict]]): + The request object. Request for the + `ListCertificateMapEntries` method. + parent (:class:`str`): + Required. The project, location and certificate map from + which the certificate map entries should be listed, + specified in the format + ``projects/*/locations/*/certificateMaps/*``. + + 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapEntriesAsyncPager: + Response for the ListCertificateMapEntries method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_manager.ListCertificateMapEntriesRequest(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_certificate_map_entries, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("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.ListCertificateMapEntriesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_certificate_map_entry(self, + request: Optional[Union[certificate_manager.GetCertificateMapEntryRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.CertificateMapEntry: + r"""Gets details of a single CertificateMapEntry. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_get_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateMapEntryRequest( + name="name_value", + ) + + # Make the request + response = await client.get_certificate_map_entry(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.GetCertificateMapEntryRequest, dict]]): + The request object. Request for the + `GetCertificateMapEntry` method. + name (:class:`str`): + Required. A name of the certificate map entry to + describe. Must be in the format + ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. + + 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.certificate_manager_v1.types.CertificateMapEntry: + Defines a certificate map entry. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_manager.GetCertificateMapEntryRequest(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_certificate_map_entry, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_certificate_map_entry(self, + request: Optional[Union[certificate_manager.CreateCertificateMapEntryRequest, dict]] = None, + *, + parent: Optional[str] = None, + certificate_map_entry: Optional[certificate_manager.CertificateMapEntry] = None, + certificate_map_entry_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a new CertificateMapEntry in a given project + and location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_create_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + certificate_map_entry = certificate_manager_v1.CertificateMapEntry() + certificate_map_entry.hostname = "hostname_value" + + request = certificate_manager_v1.CreateCertificateMapEntryRequest( + parent="parent_value", + certificate_map_entry_id="certificate_map_entry_id_value", + certificate_map_entry=certificate_map_entry, + ) + + # Make the request + operation = client.create_certificate_map_entry(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.CreateCertificateMapEntryRequest, dict]]): + The request object. Request for the + `CreateCertificateMapEntry` method. + parent (:class:`str`): + Required. The parent resource of the certificate map + entry. Must be in the format + ``projects/*/locations/*/certificateMaps/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_map_entry (:class:`google.cloud.certificate_manager_v1.types.CertificateMapEntry`): + Required. A definition of the + certificate map entry to create. + + This corresponds to the ``certificate_map_entry`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_map_entry_id (:class:`str`): + Required. A user-provided name of the + certificate map entry. + + This corresponds to the ``certificate_map_entry_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.certificate_manager_v1.types.CertificateMapEntry` + Defines a certificate map entry. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate_map_entry, certificate_map_entry_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 = certificate_manager.CreateCertificateMapEntryRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate_map_entry is not None: + request.certificate_map_entry = certificate_map_entry + if certificate_map_entry_id is not None: + request.certificate_map_entry_id = certificate_map_entry_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_certificate_map_entry, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("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, + certificate_manager.CertificateMapEntry, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_certificate_map_entry(self, + request: Optional[Union[certificate_manager.UpdateCertificateMapEntryRequest, dict]] = None, + *, + certificate_map_entry: Optional[certificate_manager.CertificateMapEntry] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates a CertificateMapEntry. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_update_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + certificate_map_entry = certificate_manager_v1.CertificateMapEntry() + certificate_map_entry.hostname = "hostname_value" + + request = certificate_manager_v1.UpdateCertificateMapEntryRequest( + certificate_map_entry=certificate_map_entry, + ) + + # Make the request + operation = client.update_certificate_map_entry(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.UpdateCertificateMapEntryRequest, dict]]): + The request object. Request for the + `UpdateCertificateMapEntry` method. + certificate_map_entry (:class:`google.cloud.certificate_manager_v1.types.CertificateMapEntry`): + Required. A definition of the + certificate map entry to create map + entry. + + This corresponds to the ``certificate_map_entry`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.certificate_manager_v1.types.CertificateMapEntry` + Defines a certificate map entry. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_map_entry, 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 = certificate_manager.UpdateCertificateMapEntryRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_map_entry is not None: + request.certificate_map_entry = certificate_map_entry + 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_certificate_map_entry, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("certificate_map_entry.name", request.certificate_map_entry.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, + certificate_manager.CertificateMapEntry, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_certificate_map_entry(self, + request: Optional[Union[certificate_manager.DeleteCertificateMapEntryRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes a single CertificateMapEntry. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_delete_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateMapEntryRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate_map_entry(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.DeleteCertificateMapEntryRequest, dict]]): + The request object. Request for the + `DeleteCertificateMapEntry` method. + name (:class:`str`): + Required. A name of the certificate map entry to delete. + Must be in the format + ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. + + 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); + + } + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_manager.DeleteCertificateMapEntryRequest(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_certificate_map_entry, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_dns_authorizations(self, + request: Optional[Union[certificate_manager.ListDnsAuthorizationsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListDnsAuthorizationsAsyncPager: + r"""Lists DnsAuthorizations in a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_list_dns_authorizations(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListDnsAuthorizationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_dns_authorizations(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsRequest, dict]]): + The request object. Request for the + `ListDnsAuthorizations` method. + parent (:class:`str`): + Required. The project and location from which the dns + authorizations should 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.certificate_manager_v1.services.certificate_manager.pagers.ListDnsAuthorizationsAsyncPager: + Response for the ListDnsAuthorizations method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_manager.ListDnsAuthorizationsRequest(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_dns_authorizations, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("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.ListDnsAuthorizationsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_dns_authorization(self, + request: Optional[Union[certificate_manager.GetDnsAuthorizationRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.DnsAuthorization: + r"""Gets details of a single DnsAuthorization. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_get_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetDnsAuthorizationRequest( + name="name_value", + ) + + # Make the request + response = await client.get_dns_authorization(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.GetDnsAuthorizationRequest, dict]]): + The request object. Request for the + `GetDnsAuthorization` method. + name (:class:`str`): + Required. A name of the dns authorization to describe. + Must be in the format + ``projects/*/locations/*/dnsAuthorizations/*``. + + 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.certificate_manager_v1.types.DnsAuthorization: + A DnsAuthorization resource describes + a way to perform domain authorization + for certificate issuance. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_manager.GetDnsAuthorizationRequest(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_dns_authorization, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_dns_authorization(self, + request: Optional[Union[certificate_manager.CreateDnsAuthorizationRequest, dict]] = None, + *, + parent: Optional[str] = None, + dns_authorization: Optional[certificate_manager.DnsAuthorization] = None, + dns_authorization_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a new DnsAuthorization in a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_create_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + dns_authorization = certificate_manager_v1.DnsAuthorization() + dns_authorization.domain = "domain_value" + + request = certificate_manager_v1.CreateDnsAuthorizationRequest( + parent="parent_value", + dns_authorization_id="dns_authorization_id_value", + dns_authorization=dns_authorization, + ) + + # Make the request + operation = client.create_dns_authorization(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.CreateDnsAuthorizationRequest, dict]]): + The request object. Request for the + `CreateDnsAuthorization` method. + parent (:class:`str`): + Required. The parent resource of the dns authorization. + Must be in the format ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + dns_authorization (:class:`google.cloud.certificate_manager_v1.types.DnsAuthorization`): + Required. A definition of the dns + authorization to create. + + This corresponds to the ``dns_authorization`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + dns_authorization_id (:class:`str`): + Required. A user-provided name of the + dns authorization. + + This corresponds to the ``dns_authorization_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.certificate_manager_v1.types.DnsAuthorization` A DnsAuthorization resource describes a way to perform domain authorization + for certificate issuance. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, dns_authorization, dns_authorization_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 = certificate_manager.CreateDnsAuthorizationRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if dns_authorization is not None: + request.dns_authorization = dns_authorization + if dns_authorization_id is not None: + request.dns_authorization_id = dns_authorization_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_dns_authorization, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("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, + certificate_manager.DnsAuthorization, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_dns_authorization(self, + request: Optional[Union[certificate_manager.UpdateDnsAuthorizationRequest, dict]] = None, + *, + dns_authorization: Optional[certificate_manager.DnsAuthorization] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates a DnsAuthorization. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_update_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + dns_authorization = certificate_manager_v1.DnsAuthorization() + dns_authorization.domain = "domain_value" + + request = certificate_manager_v1.UpdateDnsAuthorizationRequest( + dns_authorization=dns_authorization, + ) + + # Make the request + operation = client.update_dns_authorization(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.UpdateDnsAuthorizationRequest, dict]]): + The request object. Request for the + `UpdateDnsAuthorization` method. + dns_authorization (:class:`google.cloud.certificate_manager_v1.types.DnsAuthorization`): + Required. A definition of the dns + authorization to update. + + This corresponds to the ``dns_authorization`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.certificate_manager_v1.types.DnsAuthorization` A DnsAuthorization resource describes a way to perform domain authorization + for certificate issuance. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([dns_authorization, 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 = certificate_manager.UpdateDnsAuthorizationRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if dns_authorization is not None: + request.dns_authorization = dns_authorization + 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_dns_authorization, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("dns_authorization.name", request.dns_authorization.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, + certificate_manager.DnsAuthorization, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_dns_authorization(self, + request: Optional[Union[certificate_manager.DeleteDnsAuthorizationRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes a single DnsAuthorization. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_delete_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteDnsAuthorizationRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_dns_authorization(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.DeleteDnsAuthorizationRequest, dict]]): + The request object. Request for the + `DeleteDnsAuthorization` method. + name (:class:`str`): + Required. A name of the dns authorization to delete. + Must be in the format + ``projects/*/locations/*/dnsAuthorizations/*``. + + 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); + + } + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_manager.DeleteDnsAuthorizationRequest(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_dns_authorization, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_certificate_issuance_configs(self, + request: Optional[Union[certificate_issuance_config.ListCertificateIssuanceConfigsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateIssuanceConfigsAsyncPager: + r"""Lists CertificateIssuanceConfigs in a given project + and location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_list_certificate_issuance_configs(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificateIssuanceConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificate_issuance_configs(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsRequest, dict]]): + The request object. Request for the + `ListCertificateIssuanceConfigs` method. + parent (:class:`str`): + Required. The project and location from which the + certificate should 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateIssuanceConfigsAsyncPager: + Response for the ListCertificateIssuanceConfigs method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_issuance_config.ListCertificateIssuanceConfigsRequest(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_certificate_issuance_configs, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("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.ListCertificateIssuanceConfigsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_certificate_issuance_config(self, + request: Optional[Union[certificate_issuance_config.GetCertificateIssuanceConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_issuance_config.CertificateIssuanceConfig: + r"""Gets details of a single CertificateIssuanceConfig. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_get_certificate_issuance_config(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateIssuanceConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.get_certificate_issuance_config(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.GetCertificateIssuanceConfigRequest, dict]]): + The request object. Request for the + `GetCertificateIssuanceConfig` method. + name (:class:`str`): + Required. A name of the certificate issuance config to + describe. Must be in the format + ``projects/*/locations/*/certificateIssuanceConfigs/*``. + + 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.certificate_manager_v1.types.CertificateIssuanceConfig: + CertificateIssuanceConfig specifies + how to issue and manage a certificate. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_issuance_config.GetCertificateIssuanceConfigRequest(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_certificate_issuance_config, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_certificate_issuance_config(self, + request: Optional[Union[gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, dict]] = None, + *, + parent: Optional[str] = None, + certificate_issuance_config: Optional[gcc_certificate_issuance_config.CertificateIssuanceConfig] = None, + certificate_issuance_config_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a new CertificateIssuanceConfig in a given + project and location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_create_certificate_issuance_config(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + certificate_issuance_config = certificate_manager_v1.CertificateIssuanceConfig() + certificate_issuance_config.certificate_authority_config.certificate_authority_service_config.ca_pool = "ca_pool_value" + certificate_issuance_config.rotation_window_percentage = 2788 + certificate_issuance_config.key_algorithm = "ECDSA_P256" + + request = certificate_manager_v1.CreateCertificateIssuanceConfigRequest( + parent="parent_value", + certificate_issuance_config_id="certificate_issuance_config_id_value", + certificate_issuance_config=certificate_issuance_config, + ) + + # Make the request + operation = client.create_certificate_issuance_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.CreateCertificateIssuanceConfigRequest, dict]]): + The request object. Request for the + `CreateCertificateIssuanceConfig` method. + parent (:class:`str`): + Required. The parent resource of the certificate + issuance config. Must be in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_issuance_config (:class:`google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig`): + Required. A definition of the + certificate issuance config to create. + + This corresponds to the ``certificate_issuance_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_issuance_config_id (:class:`str`): + Required. A user-provided name of the + certificate config. + + This corresponds to the ``certificate_issuance_config_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.certificate_manager_v1.types.CertificateIssuanceConfig` + CertificateIssuanceConfig specifies how to issue and + manage a certificate. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate_issuance_config, certificate_issuance_config_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 = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate_issuance_config is not None: + request.certificate_issuance_config = certificate_issuance_config + if certificate_issuance_config_id is not None: + request.certificate_issuance_config_id = certificate_issuance_config_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_certificate_issuance_config, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("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, + gcc_certificate_issuance_config.CertificateIssuanceConfig, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_certificate_issuance_config(self, + request: Optional[Union[certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes a single CertificateIssuanceConfig. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + async def sample_delete_certificate_issuance_config(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateIssuanceConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate_issuance_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.certificate_manager_v1.types.DeleteCertificateIssuanceConfigRequest, dict]]): + The request object. Request for the + `DeleteCertificateIssuanceConfig` method. + name (:class:`str`): + Required. A name of the certificate issuance config to + delete. Must be in the format + ``projects/*/locations/*/certificateIssuanceConfigs/*``. + + 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); + + } + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest(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_certificate_issuance_config, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_operations( + self, + request: Optional[operations_pb2.ListOperationsRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.ListOperationsResponse: + r"""Lists operations that match the specified filter in the request. + + Args: + request (:class:`~.operations_pb2.ListOperationsRequest`): + The request object. Request message for + `ListOperations` 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: + ~.operations_pb2.ListOperationsResponse: + Response message for ``ListOperations`` method. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.ListOperationsRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.list_operations, + 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_operation( + self, + request: Optional[operations_pb2.GetOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` 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: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def delete_operation( + self, + request: Optional[operations_pb2.DeleteOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a long-running operation. + + This method indicates that the client is no longer interested + in the operation result. It does not cancel the operation. + If the server doesn't support this method, it returns + `google.rpc.Code.UNIMPLEMENTED`. + + Args: + request (:class:`~.operations_pb2.DeleteOperationRequest`): + The request object. Request message for + `DeleteOperation` 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: + None + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.DeleteOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.delete_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Send the request. + await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + async def cancel_operation( + self, + request: Optional[operations_pb2.CancelOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Starts asynchronous cancellation on a long-running operation. + + The server makes a best effort to cancel the operation, but success + is not guaranteed. If the server doesn't support this method, it returns + `google.rpc.Code.UNIMPLEMENTED`. + + Args: + request (:class:`~.operations_pb2.CancelOperationRequest`): + The request object. Request message for + `CancelOperation` 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: + None + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.CancelOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.cancel_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Send the request. + await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + async def get_location( + self, + request: Optional[locations_pb2.GetLocationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.Location: + r"""Gets information about a location. + + Args: + request (:class:`~.location_pb2.GetLocationRequest`): + The request object. Request message for + `GetLocation` 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: + ~.location_pb2.Location: + Location object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = locations_pb2.GetLocationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.get_location, + 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 list_locations( + self, + request: Optional[locations_pb2.ListLocationsRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.ListLocationsResponse: + r"""Lists information about the supported locations for this service. + + Args: + request (:class:`~.location_pb2.ListLocationsRequest`): + The request object. Request message for + `ListLocations` 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: + ~.location_pb2.ListLocationsResponse: + Response message for ``ListLocations`` method. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = locations_pb2.ListLocationsRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.list_locations, + 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 __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + + +__all__ = ( + "CertificateManagerAsyncClient", +) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/client.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/client.py new file mode 100644 index 0000000..5396a2e --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/client.py @@ -0,0 +1,3716 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +import os +import re +from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast + +from google.cloud.certificate_manager_v1 import gapic_version as package_version + +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.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 + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.certificate_manager_v1.services.certificate_manager import pagers +from google.cloud.certificate_manager_v1.types import certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_manager +from google.cloud.location import locations_pb2 # type: ignore +from google.longrunning import operations_pb2 +from google.protobuf import duration_pb2 # type: ignore +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 CertificateManagerTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import CertificateManagerGrpcTransport +from .transports.grpc_asyncio import CertificateManagerGrpcAsyncIOTransport +from .transports.rest import CertificateManagerRestTransport + + +class CertificateManagerClientMeta(type): + """Metaclass for the CertificateManager 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[CertificateManagerTransport]] + _transport_registry["grpc"] = CertificateManagerGrpcTransport + _transport_registry["grpc_asyncio"] = CertificateManagerGrpcAsyncIOTransport + _transport_registry["rest"] = CertificateManagerRestTransport + + def get_transport_class(cls, + label: Optional[str] = None, + ) -> Type[CertificateManagerTransport]: + """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 CertificateManagerClient(metaclass=CertificateManagerClientMeta): + """API Overview + + Certificates Manager API allows customers to see and manage all + their TLS certificates. + + Certificates Manager API service provides methods to manage + certificates, group them into collections, and create serving + configuration that can be easily applied to other Cloud resources + e.g. Target Proxies. + + Data Model + + The Certificates Manager service exposes the following resources: + + - ``Certificate`` that describes a single TLS certificate. + - ``CertificateMap`` that describes a collection of certificates + that can be attached to a target resource. + - ``CertificateMapEntry`` that describes a single configuration + entry that consists of a SNI and a group of certificates. It's a + subresource of CertificateMap. + + Certificate, CertificateMap and CertificateMapEntry IDs have to + fully match the regexp ``[a-z0-9-]{1,63}``. In other words, + + - only lower case letters, digits, and hyphen are allowed + - length of the resource ID has to be in [1,63] range. + + Provides methods to manage Cloud Certificate Manager entities. + """ + + @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 = "certificatemanager.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: + CertificateManagerClient: 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: + CertificateManagerClient: 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) -> CertificateManagerTransport: + """Returns the transport used by the client instance. + + Returns: + CertificateManagerTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def ca_pool_path(project: str,location: str,ca_pool: str,) -> str: + """Returns a fully-qualified ca_pool string.""" + return "projects/{project}/locations/{location}/caPools/{ca_pool}".format(project=project, location=location, ca_pool=ca_pool, ) + + @staticmethod + def parse_ca_pool_path(path: str) -> Dict[str,str]: + """Parses a ca_pool path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/caPools/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def certificate_path(project: str,location: str,certificate: str,) -> str: + """Returns a fully-qualified certificate string.""" + return "projects/{project}/locations/{location}/certificates/{certificate}".format(project=project, location=location, certificate=certificate, ) + + @staticmethod + def parse_certificate_path(path: str) -> Dict[str,str]: + """Parses a certificate path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificates/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def certificate_issuance_config_path(project: str,location: str,certificate_issuance_config: str,) -> str: + """Returns a fully-qualified certificate_issuance_config string.""" + return "projects/{project}/locations/{location}/certificateIssuanceConfigs/{certificate_issuance_config}".format(project=project, location=location, certificate_issuance_config=certificate_issuance_config, ) + + @staticmethod + def parse_certificate_issuance_config_path(path: str) -> Dict[str,str]: + """Parses a certificate_issuance_config path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificateIssuanceConfigs/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def certificate_map_path(project: str,location: str,certificate_map: str,) -> str: + """Returns a fully-qualified certificate_map string.""" + return "projects/{project}/locations/{location}/certificateMaps/{certificate_map}".format(project=project, location=location, certificate_map=certificate_map, ) + + @staticmethod + def parse_certificate_map_path(path: str) -> Dict[str,str]: + """Parses a certificate_map path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificateMaps/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def certificate_map_entry_path(project: str,location: str,certificate_map: str,certificate_map_entry: str,) -> str: + """Returns a fully-qualified certificate_map_entry string.""" + return "projects/{project}/locations/{location}/certificateMaps/{certificate_map}/certificateMapEntries/{certificate_map_entry}".format(project=project, location=location, certificate_map=certificate_map, certificate_map_entry=certificate_map_entry, ) + + @staticmethod + def parse_certificate_map_entry_path(path: str) -> Dict[str,str]: + """Parses a certificate_map_entry path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificateMaps/(?P.+?)/certificateMapEntries/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def dns_authorization_path(project: str,location: str,dns_authorization: str,) -> str: + """Returns a fully-qualified dns_authorization string.""" + return "projects/{project}/locations/{location}/dnsAuthorizations/{dns_authorization}".format(project=project, location=location, dns_authorization=dns_authorization, ) + + @staticmethod + def parse_dns_authorization_path(path: str) -> Dict[str,str]: + """Parses a dns_authorization path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/dnsAuthorizations/(?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 {} + + @classmethod + def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_options_lib.ClientOptions] = None): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variable is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`") + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`") + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Optional[Union[str, CertificateManagerTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the certificate manager 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, CertificateManagerTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): 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() + client_options = cast(client_options_lib.ClientOptions, client_options) + + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(client_options) + + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError("client_options.api_key and credentials are mutually exclusive") + + # 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, CertificateManagerTransport): + # transport is a CertificateManagerTransport instance. + if credentials or client_options.credentials_file or api_key_value: + 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: + import google.auth._default # type: ignore + + if api_key_value and hasattr(google.auth._default, "get_api_key_credentials"): + credentials = google.auth._default.get_api_key_credentials(api_key_value) + + 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, + always_use_jwt_access=True, + api_audience=client_options.api_audience, + ) + + def list_certificates(self, + request: Optional[Union[certificate_manager.ListCertificatesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificatesPager: + r"""Lists Certificates in a given project and location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_list_certificates(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificatesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificates(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.ListCertificatesRequest, dict]): + The request object. Request for the `ListCertificates` + method. + parent (str): + Required. The project and location from which the + certificate should 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificatesPager: + Response for the ListCertificates method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_manager.ListCertificatesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.ListCertificatesRequest): + request = certificate_manager.ListCertificatesRequest(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_certificates] + + # 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.ListCertificatesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_certificate(self, + request: Optional[Union[certificate_manager.GetCertificateRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.Certificate: + r"""Gets details of a single Certificate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_get_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateRequest( + name="name_value", + ) + + # Make the request + response = client.get_certificate(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.GetCertificateRequest, dict]): + The request object. Request for the `GetCertificate` + method. + name (str): + Required. A name of the certificate to describe. Must be + in the format ``projects/*/locations/*/certificates/*``. + + 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.certificate_manager_v1.types.Certificate: + Defines TLS certificate. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_manager.GetCertificateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.GetCertificateRequest): + request = certificate_manager.GetCertificateRequest(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_certificate] + + # 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_certificate(self, + request: Optional[Union[certificate_manager.CreateCertificateRequest, dict]] = None, + *, + parent: Optional[str] = None, + certificate: Optional[certificate_manager.Certificate] = None, + certificate_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates a new Certificate in a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_create_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.CreateCertificateRequest( + parent="parent_value", + certificate_id="certificate_id_value", + ) + + # Make the request + operation = client.create_certificate(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.CreateCertificateRequest, dict]): + The request object. Request for the `CreateCertificate` + method. + parent (str): + Required. The parent resource of the certificate. Must + be in the format ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate (google.cloud.certificate_manager_v1.types.Certificate): + Required. A definition of the + certificate to create. + + This corresponds to the ``certificate`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_id (str): + Required. A user-provided name of the + certificate. + + This corresponds to the ``certificate_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.certificate_manager_v1.types.Certificate` + Defines TLS certificate. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate, certificate_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 certificate_manager.CreateCertificateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.CreateCertificateRequest): + request = certificate_manager.CreateCertificateRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate is not None: + request.certificate = certificate + if certificate_id is not None: + request.certificate_id = certificate_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_certificate] + + # 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, + certificate_manager.Certificate, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_certificate(self, + request: Optional[Union[certificate_manager.UpdateCertificateRequest, dict]] = None, + *, + certificate: Optional[certificate_manager.Certificate] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Updates a Certificate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_update_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.UpdateCertificateRequest( + ) + + # Make the request + operation = client.update_certificate(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.UpdateCertificateRequest, dict]): + The request object. Request for the `UpdateCertificate` + method. + certificate (google.cloud.certificate_manager_v1.types.Certificate): + Required. A definition of the + certificate to update. + + This corresponds to the ``certificate`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.certificate_manager_v1.types.Certificate` + Defines TLS certificate. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate, 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 certificate_manager.UpdateCertificateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.UpdateCertificateRequest): + request = certificate_manager.UpdateCertificateRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate is not None: + request.certificate = certificate + 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_certificate] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("certificate.name", request.certificate.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, + certificate_manager.Certificate, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_certificate(self, + request: Optional[Union[certificate_manager.DeleteCertificateRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Deletes a single Certificate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_delete_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.DeleteCertificateRequest, dict]): + The request object. Request for the `DeleteCertificate` + method. + name (str): + Required. A name of the certificate to delete. Must be + in the format ``projects/*/locations/*/certificates/*``. + + 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); + + } + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_manager.DeleteCertificateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.DeleteCertificateRequest): + request = certificate_manager.DeleteCertificateRequest(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_certificate] + + # 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=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_certificate_maps(self, + request: Optional[Union[certificate_manager.ListCertificateMapsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateMapsPager: + r"""Lists CertificateMaps in a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_list_certificate_maps(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificateMapsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificate_maps(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.ListCertificateMapsRequest, dict]): + The request object. Request for the + `ListCertificateMaps` method. + parent (str): + Required. The project and location from which the + certificate maps should 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapsPager: + Response for the ListCertificateMaps method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_manager.ListCertificateMapsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.ListCertificateMapsRequest): + request = certificate_manager.ListCertificateMapsRequest(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_certificate_maps] + + # 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.ListCertificateMapsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_certificate_map(self, + request: Optional[Union[certificate_manager.GetCertificateMapRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.CertificateMap: + r"""Gets details of a single CertificateMap. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_get_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateMapRequest( + name="name_value", + ) + + # Make the request + response = client.get_certificate_map(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.GetCertificateMapRequest, dict]): + The request object. Request for the `GetCertificateMap` + method. + name (str): + Required. A name of the certificate map to describe. + Must be in the format + ``projects/*/locations/*/certificateMaps/*``. + + 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.certificate_manager_v1.types.CertificateMap: + Defines a collection of certificate + configurations. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_manager.GetCertificateMapRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.GetCertificateMapRequest): + request = certificate_manager.GetCertificateMapRequest(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_certificate_map] + + # 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_certificate_map(self, + request: Optional[Union[certificate_manager.CreateCertificateMapRequest, dict]] = None, + *, + parent: Optional[str] = None, + certificate_map: Optional[certificate_manager.CertificateMap] = None, + certificate_map_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates a new CertificateMap in a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_create_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.CreateCertificateMapRequest( + parent="parent_value", + certificate_map_id="certificate_map_id_value", + ) + + # Make the request + operation = client.create_certificate_map(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.CreateCertificateMapRequest, dict]): + The request object. Request for the + `CreateCertificateMap` method. + parent (str): + Required. The parent resource of the certificate map. + Must be in the format ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_map (google.cloud.certificate_manager_v1.types.CertificateMap): + Required. A definition of the + certificate map to create. + + This corresponds to the ``certificate_map`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_map_id (str): + Required. A user-provided name of the + certificate map. + + This corresponds to the ``certificate_map_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.certificate_manager_v1.types.CertificateMap` + Defines a collection of certificate configurations. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate_map, certificate_map_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 certificate_manager.CreateCertificateMapRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.CreateCertificateMapRequest): + request = certificate_manager.CreateCertificateMapRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate_map is not None: + request.certificate_map = certificate_map + if certificate_map_id is not None: + request.certificate_map_id = certificate_map_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_certificate_map] + + # 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, + certificate_manager.CertificateMap, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_certificate_map(self, + request: Optional[Union[certificate_manager.UpdateCertificateMapRequest, dict]] = None, + *, + certificate_map: Optional[certificate_manager.CertificateMap] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Updates a CertificateMap. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_update_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.UpdateCertificateMapRequest( + ) + + # Make the request + operation = client.update_certificate_map(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.UpdateCertificateMapRequest, dict]): + The request object. Request for the + `UpdateCertificateMap` method. + certificate_map (google.cloud.certificate_manager_v1.types.CertificateMap): + Required. A definition of the + certificate map to update. + + This corresponds to the ``certificate_map`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.certificate_manager_v1.types.CertificateMap` + Defines a collection of certificate configurations. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_map, 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 certificate_manager.UpdateCertificateMapRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.UpdateCertificateMapRequest): + request = certificate_manager.UpdateCertificateMapRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_map is not None: + request.certificate_map = certificate_map + 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_certificate_map] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("certificate_map.name", request.certificate_map.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, + certificate_manager.CertificateMap, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_certificate_map(self, + request: Optional[Union[certificate_manager.DeleteCertificateMapRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Deletes a single CertificateMap. A Certificate Map + can't be deleted if it contains Certificate Map Entries. + Remove all the entries from the map before calling this + method. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_delete_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateMapRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate_map(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.DeleteCertificateMapRequest, dict]): + The request object. Request for the + `DeleteCertificateMap` method. + name (str): + Required. A name of the certificate map to delete. Must + be in the format + ``projects/*/locations/*/certificateMaps/*``. + + 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); + + } + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_manager.DeleteCertificateMapRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.DeleteCertificateMapRequest): + request = certificate_manager.DeleteCertificateMapRequest(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_certificate_map] + + # 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=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_certificate_map_entries(self, + request: Optional[Union[certificate_manager.ListCertificateMapEntriesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateMapEntriesPager: + r"""Lists CertificateMapEntries in a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_list_certificate_map_entries(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificateMapEntriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificate_map_entries(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesRequest, dict]): + The request object. Request for the + `ListCertificateMapEntries` method. + parent (str): + Required. The project, location and certificate map from + which the certificate map entries should be listed, + specified in the format + ``projects/*/locations/*/certificateMaps/*``. + + 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapEntriesPager: + Response for the ListCertificateMapEntries method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_manager.ListCertificateMapEntriesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.ListCertificateMapEntriesRequest): + request = certificate_manager.ListCertificateMapEntriesRequest(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_certificate_map_entries] + + # 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.ListCertificateMapEntriesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_certificate_map_entry(self, + request: Optional[Union[certificate_manager.GetCertificateMapEntryRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.CertificateMapEntry: + r"""Gets details of a single CertificateMapEntry. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_get_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateMapEntryRequest( + name="name_value", + ) + + # Make the request + response = client.get_certificate_map_entry(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.GetCertificateMapEntryRequest, dict]): + The request object. Request for the + `GetCertificateMapEntry` method. + name (str): + Required. A name of the certificate map entry to + describe. Must be in the format + ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. + + 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.certificate_manager_v1.types.CertificateMapEntry: + Defines a certificate map entry. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_manager.GetCertificateMapEntryRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.GetCertificateMapEntryRequest): + request = certificate_manager.GetCertificateMapEntryRequest(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_certificate_map_entry] + + # 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_certificate_map_entry(self, + request: Optional[Union[certificate_manager.CreateCertificateMapEntryRequest, dict]] = None, + *, + parent: Optional[str] = None, + certificate_map_entry: Optional[certificate_manager.CertificateMapEntry] = None, + certificate_map_entry_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates a new CertificateMapEntry in a given project + and location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_create_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + certificate_map_entry = certificate_manager_v1.CertificateMapEntry() + certificate_map_entry.hostname = "hostname_value" + + request = certificate_manager_v1.CreateCertificateMapEntryRequest( + parent="parent_value", + certificate_map_entry_id="certificate_map_entry_id_value", + certificate_map_entry=certificate_map_entry, + ) + + # Make the request + operation = client.create_certificate_map_entry(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.CreateCertificateMapEntryRequest, dict]): + The request object. Request for the + `CreateCertificateMapEntry` method. + parent (str): + Required. The parent resource of the certificate map + entry. Must be in the format + ``projects/*/locations/*/certificateMaps/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_map_entry (google.cloud.certificate_manager_v1.types.CertificateMapEntry): + Required. A definition of the + certificate map entry to create. + + This corresponds to the ``certificate_map_entry`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_map_entry_id (str): + Required. A user-provided name of the + certificate map entry. + + This corresponds to the ``certificate_map_entry_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.certificate_manager_v1.types.CertificateMapEntry` + Defines a certificate map entry. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate_map_entry, certificate_map_entry_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 certificate_manager.CreateCertificateMapEntryRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.CreateCertificateMapEntryRequest): + request = certificate_manager.CreateCertificateMapEntryRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate_map_entry is not None: + request.certificate_map_entry = certificate_map_entry + if certificate_map_entry_id is not None: + request.certificate_map_entry_id = certificate_map_entry_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_certificate_map_entry] + + # 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, + certificate_manager.CertificateMapEntry, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_certificate_map_entry(self, + request: Optional[Union[certificate_manager.UpdateCertificateMapEntryRequest, dict]] = None, + *, + certificate_map_entry: Optional[certificate_manager.CertificateMapEntry] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Updates a CertificateMapEntry. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_update_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + certificate_map_entry = certificate_manager_v1.CertificateMapEntry() + certificate_map_entry.hostname = "hostname_value" + + request = certificate_manager_v1.UpdateCertificateMapEntryRequest( + certificate_map_entry=certificate_map_entry, + ) + + # Make the request + operation = client.update_certificate_map_entry(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.UpdateCertificateMapEntryRequest, dict]): + The request object. Request for the + `UpdateCertificateMapEntry` method. + certificate_map_entry (google.cloud.certificate_manager_v1.types.CertificateMapEntry): + Required. A definition of the + certificate map entry to create map + entry. + + This corresponds to the ``certificate_map_entry`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.certificate_manager_v1.types.CertificateMapEntry` + Defines a certificate map entry. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_map_entry, 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 certificate_manager.UpdateCertificateMapEntryRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.UpdateCertificateMapEntryRequest): + request = certificate_manager.UpdateCertificateMapEntryRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_map_entry is not None: + request.certificate_map_entry = certificate_map_entry + 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_certificate_map_entry] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("certificate_map_entry.name", request.certificate_map_entry.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, + certificate_manager.CertificateMapEntry, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_certificate_map_entry(self, + request: Optional[Union[certificate_manager.DeleteCertificateMapEntryRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Deletes a single CertificateMapEntry. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_delete_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateMapEntryRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate_map_entry(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.DeleteCertificateMapEntryRequest, dict]): + The request object. Request for the + `DeleteCertificateMapEntry` method. + name (str): + Required. A name of the certificate map entry to delete. + Must be in the format + ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. + + 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); + + } + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_manager.DeleteCertificateMapEntryRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.DeleteCertificateMapEntryRequest): + request = certificate_manager.DeleteCertificateMapEntryRequest(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_certificate_map_entry] + + # 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=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_dns_authorizations(self, + request: Optional[Union[certificate_manager.ListDnsAuthorizationsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListDnsAuthorizationsPager: + r"""Lists DnsAuthorizations in a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_list_dns_authorizations(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListDnsAuthorizationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_dns_authorizations(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsRequest, dict]): + The request object. Request for the + `ListDnsAuthorizations` method. + parent (str): + Required. The project and location from which the dns + authorizations should 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.certificate_manager_v1.services.certificate_manager.pagers.ListDnsAuthorizationsPager: + Response for the ListDnsAuthorizations method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_manager.ListDnsAuthorizationsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.ListDnsAuthorizationsRequest): + request = certificate_manager.ListDnsAuthorizationsRequest(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_dns_authorizations] + + # 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.ListDnsAuthorizationsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_dns_authorization(self, + request: Optional[Union[certificate_manager.GetDnsAuthorizationRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.DnsAuthorization: + r"""Gets details of a single DnsAuthorization. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_get_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetDnsAuthorizationRequest( + name="name_value", + ) + + # Make the request + response = client.get_dns_authorization(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.GetDnsAuthorizationRequest, dict]): + The request object. Request for the + `GetDnsAuthorization` method. + name (str): + Required. A name of the dns authorization to describe. + Must be in the format + ``projects/*/locations/*/dnsAuthorizations/*``. + + 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.certificate_manager_v1.types.DnsAuthorization: + A DnsAuthorization resource describes + a way to perform domain authorization + for certificate issuance. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_manager.GetDnsAuthorizationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.GetDnsAuthorizationRequest): + request = certificate_manager.GetDnsAuthorizationRequest(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_dns_authorization] + + # 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_dns_authorization(self, + request: Optional[Union[certificate_manager.CreateDnsAuthorizationRequest, dict]] = None, + *, + parent: Optional[str] = None, + dns_authorization: Optional[certificate_manager.DnsAuthorization] = None, + dns_authorization_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates a new DnsAuthorization in a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_create_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + dns_authorization = certificate_manager_v1.DnsAuthorization() + dns_authorization.domain = "domain_value" + + request = certificate_manager_v1.CreateDnsAuthorizationRequest( + parent="parent_value", + dns_authorization_id="dns_authorization_id_value", + dns_authorization=dns_authorization, + ) + + # Make the request + operation = client.create_dns_authorization(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.CreateDnsAuthorizationRequest, dict]): + The request object. Request for the + `CreateDnsAuthorization` method. + parent (str): + Required. The parent resource of the dns authorization. + Must be in the format ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + dns_authorization (google.cloud.certificate_manager_v1.types.DnsAuthorization): + Required. A definition of the dns + authorization to create. + + This corresponds to the ``dns_authorization`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + dns_authorization_id (str): + Required. A user-provided name of the + dns authorization. + + This corresponds to the ``dns_authorization_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.certificate_manager_v1.types.DnsAuthorization` A DnsAuthorization resource describes a way to perform domain authorization + for certificate issuance. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, dns_authorization, dns_authorization_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 certificate_manager.CreateDnsAuthorizationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.CreateDnsAuthorizationRequest): + request = certificate_manager.CreateDnsAuthorizationRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if dns_authorization is not None: + request.dns_authorization = dns_authorization + if dns_authorization_id is not None: + request.dns_authorization_id = dns_authorization_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_dns_authorization] + + # 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, + certificate_manager.DnsAuthorization, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_dns_authorization(self, + request: Optional[Union[certificate_manager.UpdateDnsAuthorizationRequest, dict]] = None, + *, + dns_authorization: Optional[certificate_manager.DnsAuthorization] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Updates a DnsAuthorization. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_update_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + dns_authorization = certificate_manager_v1.DnsAuthorization() + dns_authorization.domain = "domain_value" + + request = certificate_manager_v1.UpdateDnsAuthorizationRequest( + dns_authorization=dns_authorization, + ) + + # Make the request + operation = client.update_dns_authorization(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.UpdateDnsAuthorizationRequest, dict]): + The request object. Request for the + `UpdateDnsAuthorization` method. + dns_authorization (google.cloud.certificate_manager_v1.types.DnsAuthorization): + Required. A definition of the dns + authorization to update. + + This corresponds to the ``dns_authorization`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.certificate_manager_v1.types.DnsAuthorization` A DnsAuthorization resource describes a way to perform domain authorization + for certificate issuance. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([dns_authorization, 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 certificate_manager.UpdateDnsAuthorizationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.UpdateDnsAuthorizationRequest): + request = certificate_manager.UpdateDnsAuthorizationRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if dns_authorization is not None: + request.dns_authorization = dns_authorization + 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_dns_authorization] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("dns_authorization.name", request.dns_authorization.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, + certificate_manager.DnsAuthorization, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_dns_authorization(self, + request: Optional[Union[certificate_manager.DeleteDnsAuthorizationRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Deletes a single DnsAuthorization. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_delete_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteDnsAuthorizationRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_dns_authorization(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.DeleteDnsAuthorizationRequest, dict]): + The request object. Request for the + `DeleteDnsAuthorization` method. + name (str): + Required. A name of the dns authorization to delete. + Must be in the format + ``projects/*/locations/*/dnsAuthorizations/*``. + + 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); + + } + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_manager.DeleteDnsAuthorizationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_manager.DeleteDnsAuthorizationRequest): + request = certificate_manager.DeleteDnsAuthorizationRequest(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_dns_authorization] + + # 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=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_certificate_issuance_configs(self, + request: Optional[Union[certificate_issuance_config.ListCertificateIssuanceConfigsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateIssuanceConfigsPager: + r"""Lists CertificateIssuanceConfigs in a given project + and location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_list_certificate_issuance_configs(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificateIssuanceConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificate_issuance_configs(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsRequest, dict]): + The request object. Request for the + `ListCertificateIssuanceConfigs` method. + parent (str): + Required. The project and location from which the + certificate should 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateIssuanceConfigsPager: + Response for the ListCertificateIssuanceConfigs method. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_issuance_config.ListCertificateIssuanceConfigsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_issuance_config.ListCertificateIssuanceConfigsRequest): + request = certificate_issuance_config.ListCertificateIssuanceConfigsRequest(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_certificate_issuance_configs] + + # 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.ListCertificateIssuanceConfigsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_certificate_issuance_config(self, + request: Optional[Union[certificate_issuance_config.GetCertificateIssuanceConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_issuance_config.CertificateIssuanceConfig: + r"""Gets details of a single CertificateIssuanceConfig. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_get_certificate_issuance_config(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateIssuanceConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_certificate_issuance_config(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.GetCertificateIssuanceConfigRequest, dict]): + The request object. Request for the + `GetCertificateIssuanceConfig` method. + name (str): + Required. A name of the certificate issuance config to + describe. Must be in the format + ``projects/*/locations/*/certificateIssuanceConfigs/*``. + + 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.certificate_manager_v1.types.CertificateIssuanceConfig: + CertificateIssuanceConfig specifies + how to issue and manage a certificate. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_issuance_config.GetCertificateIssuanceConfigRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_issuance_config.GetCertificateIssuanceConfigRequest): + request = certificate_issuance_config.GetCertificateIssuanceConfigRequest(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_certificate_issuance_config] + + # 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_certificate_issuance_config(self, + request: Optional[Union[gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, dict]] = None, + *, + parent: Optional[str] = None, + certificate_issuance_config: Optional[gcc_certificate_issuance_config.CertificateIssuanceConfig] = None, + certificate_issuance_config_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates a new CertificateIssuanceConfig in a given + project and location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_create_certificate_issuance_config(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + certificate_issuance_config = certificate_manager_v1.CertificateIssuanceConfig() + certificate_issuance_config.certificate_authority_config.certificate_authority_service_config.ca_pool = "ca_pool_value" + certificate_issuance_config.rotation_window_percentage = 2788 + certificate_issuance_config.key_algorithm = "ECDSA_P256" + + request = certificate_manager_v1.CreateCertificateIssuanceConfigRequest( + parent="parent_value", + certificate_issuance_config_id="certificate_issuance_config_id_value", + certificate_issuance_config=certificate_issuance_config, + ) + + # Make the request + operation = client.create_certificate_issuance_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.CreateCertificateIssuanceConfigRequest, dict]): + The request object. Request for the + `CreateCertificateIssuanceConfig` method. + parent (str): + Required. The parent resource of the certificate + issuance config. Must be in the format + ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_issuance_config (google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig): + Required. A definition of the + certificate issuance config to create. + + This corresponds to the ``certificate_issuance_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_issuance_config_id (str): + Required. A user-provided name of the + certificate config. + + This corresponds to the ``certificate_issuance_config_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.certificate_manager_v1.types.CertificateIssuanceConfig` + CertificateIssuanceConfig specifies how to issue and + manage a certificate. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate_issuance_config, certificate_issuance_config_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 gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest): + request = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate_issuance_config is not None: + request.certificate_issuance_config = certificate_issuance_config + if certificate_issuance_config_id is not None: + request.certificate_issuance_config_id = certificate_issuance_config_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_certificate_issuance_config] + + # 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, + gcc_certificate_issuance_config.CertificateIssuanceConfig, + metadata_type=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_certificate_issuance_config(self, + request: Optional[Union[certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Deletes a single CertificateIssuanceConfig. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import certificate_manager_v1 + + def sample_delete_certificate_issuance_config(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateIssuanceConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate_issuance_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.certificate_manager_v1.types.DeleteCertificateIssuanceConfigRequest, dict]): + The request object. Request for the + `DeleteCertificateIssuanceConfig` method. + name (str): + Required. A name of the certificate issuance config to + delete. Must be in the format + ``projects/*/locations/*/certificateIssuanceConfigs/*``. + + 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); + + } + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a certificate_issuance_config.DeleteCertificateIssuanceConfigRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, certificate_issuance_config.DeleteCertificateIssuanceConfigRequest): + request = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest(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_certificate_issuance_config] + + # 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=certificate_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def __enter__(self) -> "CertificateManagerClient": + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + + def list_operations( + self, + request: Optional[operations_pb2.ListOperationsRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.ListOperationsResponse: + r"""Lists operations that match the specified filter in the request. + + Args: + request (:class:`~.operations_pb2.ListOperationsRequest`): + The request object. Request message for + `ListOperations` 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: + ~.operations_pb2.ListOperationsResponse: + Response message for ``ListOperations`` method. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.ListOperationsRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_operations, + 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 = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def get_operation( + self, + request: Optional[operations_pb2.GetOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` 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: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_operation, + 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 = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def delete_operation( + self, + request: Optional[operations_pb2.DeleteOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a long-running operation. + + This method indicates that the client is no longer interested + in the operation result. It does not cancel the operation. + If the server doesn't support this method, it returns + `google.rpc.Code.UNIMPLEMENTED`. + + Args: + request (:class:`~.operations_pb2.DeleteOperationRequest`): + The request object. Request message for + `DeleteOperation` 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: + None + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.DeleteOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.delete_operation, + 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. + rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + def cancel_operation( + self, + request: Optional[operations_pb2.CancelOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Starts asynchronous cancellation on a long-running operation. + + The server makes a best effort to cancel the operation, but success + is not guaranteed. If the server doesn't support this method, it returns + `google.rpc.Code.UNIMPLEMENTED`. + + Args: + request (:class:`~.operations_pb2.CancelOperationRequest`): + The request object. Request message for + `CancelOperation` 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: + None + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.CancelOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.cancel_operation, + 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. + rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + def get_location( + self, + request: Optional[locations_pb2.GetLocationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.Location: + r"""Gets information about a location. + + Args: + request (:class:`~.location_pb2.GetLocationRequest`): + The request object. Request message for + `GetLocation` 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: + ~.location_pb2.Location: + Location object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = locations_pb2.GetLocationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_location, + 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 = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_locations( + self, + request: Optional[locations_pb2.ListLocationsRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.ListLocationsResponse: + r"""Lists information about the supported locations for this service. + + Args: + request (:class:`~.location_pb2.ListLocationsRequest`): + The request object. Request message for + `ListLocations` 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: + ~.location_pb2.ListLocationsResponse: + Response message for ``ListLocations`` method. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = locations_pb2.ListLocationsRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_locations, + 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 = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + + +__all__ = ( + "CertificateManagerClient", +) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/pagers.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/pagers.py new file mode 100644 index 0000000..364a957 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/pagers.py @@ -0,0 +1,624 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator + +from google.cloud.certificate_manager_v1.types import certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_manager + + +class ListCertificatesPager: + """A pager for iterating through ``list_certificates`` requests. + + This class thinly wraps an initial + :class:`google.cloud.certificate_manager_v1.types.ListCertificatesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``certificates`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCertificates`` requests and continue to iterate + through the ``certificates`` field on the + corresponding responses. + + All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificatesResponse` + 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[..., certificate_manager.ListCertificatesResponse], + request: certificate_manager.ListCertificatesRequest, + response: certificate_manager.ListCertificatesResponse, + *, + 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.certificate_manager_v1.types.ListCertificatesRequest): + The initial request object. + response (google.cloud.certificate_manager_v1.types.ListCertificatesResponse): + 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 = certificate_manager.ListCertificatesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[certificate_manager.ListCertificatesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[certificate_manager.Certificate]: + for page in self.pages: + yield from page.certificates + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificatesAsyncPager: + """A pager for iterating through ``list_certificates`` requests. + + This class thinly wraps an initial + :class:`google.cloud.certificate_manager_v1.types.ListCertificatesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``certificates`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCertificates`` requests and continue to iterate + through the ``certificates`` field on the + corresponding responses. + + All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificatesResponse` + 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[certificate_manager.ListCertificatesResponse]], + request: certificate_manager.ListCertificatesRequest, + response: certificate_manager.ListCertificatesResponse, + *, + 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.certificate_manager_v1.types.ListCertificatesRequest): + The initial request object. + response (google.cloud.certificate_manager_v1.types.ListCertificatesResponse): + 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 = certificate_manager.ListCertificatesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[certificate_manager.ListCertificatesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[certificate_manager.Certificate]: + async def async_generator(): + async for page in self.pages: + for response in page.certificates: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateMapsPager: + """A pager for iterating through ``list_certificate_maps`` requests. + + This class thinly wraps an initial + :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``certificate_maps`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCertificateMaps`` requests and continue to iterate + through the ``certificate_maps`` field on the + corresponding responses. + + All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapsResponse` + 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[..., certificate_manager.ListCertificateMapsResponse], + request: certificate_manager.ListCertificateMapsRequest, + response: certificate_manager.ListCertificateMapsResponse, + *, + 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.certificate_manager_v1.types.ListCertificateMapsRequest): + The initial request object. + response (google.cloud.certificate_manager_v1.types.ListCertificateMapsResponse): + 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 = certificate_manager.ListCertificateMapsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[certificate_manager.ListCertificateMapsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[certificate_manager.CertificateMap]: + for page in self.pages: + yield from page.certificate_maps + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateMapsAsyncPager: + """A pager for iterating through ``list_certificate_maps`` requests. + + This class thinly wraps an initial + :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``certificate_maps`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCertificateMaps`` requests and continue to iterate + through the ``certificate_maps`` field on the + corresponding responses. + + All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapsResponse` + 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[certificate_manager.ListCertificateMapsResponse]], + request: certificate_manager.ListCertificateMapsRequest, + response: certificate_manager.ListCertificateMapsResponse, + *, + 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.certificate_manager_v1.types.ListCertificateMapsRequest): + The initial request object. + response (google.cloud.certificate_manager_v1.types.ListCertificateMapsResponse): + 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 = certificate_manager.ListCertificateMapsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[certificate_manager.ListCertificateMapsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[certificate_manager.CertificateMap]: + async def async_generator(): + async for page in self.pages: + for response in page.certificate_maps: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateMapEntriesPager: + """A pager for iterating through ``list_certificate_map_entries`` requests. + + This class thinly wraps an initial + :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``certificate_map_entries`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCertificateMapEntries`` requests and continue to iterate + through the ``certificate_map_entries`` field on the + corresponding responses. + + All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesResponse` + 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[..., certificate_manager.ListCertificateMapEntriesResponse], + request: certificate_manager.ListCertificateMapEntriesRequest, + response: certificate_manager.ListCertificateMapEntriesResponse, + *, + 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.certificate_manager_v1.types.ListCertificateMapEntriesRequest): + The initial request object. + response (google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesResponse): + 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 = certificate_manager.ListCertificateMapEntriesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[certificate_manager.ListCertificateMapEntriesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[certificate_manager.CertificateMapEntry]: + for page in self.pages: + yield from page.certificate_map_entries + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateMapEntriesAsyncPager: + """A pager for iterating through ``list_certificate_map_entries`` requests. + + This class thinly wraps an initial + :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``certificate_map_entries`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCertificateMapEntries`` requests and continue to iterate + through the ``certificate_map_entries`` field on the + corresponding responses. + + All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesResponse` + 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[certificate_manager.ListCertificateMapEntriesResponse]], + request: certificate_manager.ListCertificateMapEntriesRequest, + response: certificate_manager.ListCertificateMapEntriesResponse, + *, + 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.certificate_manager_v1.types.ListCertificateMapEntriesRequest): + The initial request object. + response (google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesResponse): + 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 = certificate_manager.ListCertificateMapEntriesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[certificate_manager.ListCertificateMapEntriesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[certificate_manager.CertificateMapEntry]: + async def async_generator(): + async for page in self.pages: + for response in page.certificate_map_entries: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListDnsAuthorizationsPager: + """A pager for iterating through ``list_dns_authorizations`` requests. + + This class thinly wraps an initial + :class:`google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``dns_authorizations`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListDnsAuthorizations`` requests and continue to iterate + through the ``dns_authorizations`` field on the + corresponding responses. + + All the usual :class:`google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsResponse` + 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[..., certificate_manager.ListDnsAuthorizationsResponse], + request: certificate_manager.ListDnsAuthorizationsRequest, + response: certificate_manager.ListDnsAuthorizationsResponse, + *, + 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.certificate_manager_v1.types.ListDnsAuthorizationsRequest): + The initial request object. + response (google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsResponse): + 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 = certificate_manager.ListDnsAuthorizationsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[certificate_manager.ListDnsAuthorizationsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[certificate_manager.DnsAuthorization]: + for page in self.pages: + yield from page.dns_authorizations + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListDnsAuthorizationsAsyncPager: + """A pager for iterating through ``list_dns_authorizations`` requests. + + This class thinly wraps an initial + :class:`google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``dns_authorizations`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListDnsAuthorizations`` requests and continue to iterate + through the ``dns_authorizations`` field on the + corresponding responses. + + All the usual :class:`google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsResponse` + 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[certificate_manager.ListDnsAuthorizationsResponse]], + request: certificate_manager.ListDnsAuthorizationsRequest, + response: certificate_manager.ListDnsAuthorizationsResponse, + *, + 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.certificate_manager_v1.types.ListDnsAuthorizationsRequest): + The initial request object. + response (google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsResponse): + 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 = certificate_manager.ListDnsAuthorizationsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[certificate_manager.ListDnsAuthorizationsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[certificate_manager.DnsAuthorization]: + async def async_generator(): + async for page in self.pages: + for response in page.dns_authorizations: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateIssuanceConfigsPager: + """A pager for iterating through ``list_certificate_issuance_configs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``certificate_issuance_configs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCertificateIssuanceConfigs`` requests and continue to iterate + through the ``certificate_issuance_configs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsResponse` + 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[..., certificate_issuance_config.ListCertificateIssuanceConfigsResponse], + request: certificate_issuance_config.ListCertificateIssuanceConfigsRequest, + response: certificate_issuance_config.ListCertificateIssuanceConfigsResponse, + *, + 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.certificate_manager_v1.types.ListCertificateIssuanceConfigsRequest): + The initial request object. + response (google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsResponse): + 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 = certificate_issuance_config.ListCertificateIssuanceConfigsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[certificate_issuance_config.ListCertificateIssuanceConfigsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[certificate_issuance_config.CertificateIssuanceConfig]: + for page in self.pages: + yield from page.certificate_issuance_configs + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateIssuanceConfigsAsyncPager: + """A pager for iterating through ``list_certificate_issuance_configs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``certificate_issuance_configs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCertificateIssuanceConfigs`` requests and continue to iterate + through the ``certificate_issuance_configs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsResponse` + 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[certificate_issuance_config.ListCertificateIssuanceConfigsResponse]], + request: certificate_issuance_config.ListCertificateIssuanceConfigsRequest, + response: certificate_issuance_config.ListCertificateIssuanceConfigsResponse, + *, + 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.certificate_manager_v1.types.ListCertificateIssuanceConfigsRequest): + The initial request object. + response (google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsResponse): + 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 = certificate_issuance_config.ListCertificateIssuanceConfigsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[certificate_issuance_config.ListCertificateIssuanceConfigsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[certificate_issuance_config.CertificateIssuanceConfig]: + async def async_generator(): + async for page in self.pages: + for response in page.certificate_issuance_configs: + 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/certificate_manager_v1/services/certificate_manager/transports/__init__.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/__init__.py new file mode 100644 index 0000000..2dc03cd --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/__init__.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +from typing import Dict, Type + +from .base import CertificateManagerTransport +from .grpc import CertificateManagerGrpcTransport +from .grpc_asyncio import CertificateManagerGrpcAsyncIOTransport +from .rest import CertificateManagerRestTransport +from .rest import CertificateManagerRestInterceptor + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[CertificateManagerTransport]] +_transport_registry['grpc'] = CertificateManagerGrpcTransport +_transport_registry['grpc_asyncio'] = CertificateManagerGrpcAsyncIOTransport +_transport_registry['rest'] = CertificateManagerRestTransport + +__all__ = ( + 'CertificateManagerTransport', + 'CertificateManagerGrpcTransport', + 'CertificateManagerGrpcAsyncIOTransport', + 'CertificateManagerRestTransport', + 'CertificateManagerRestInterceptor', +) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/base.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/base.py new file mode 100644 index 0000000..5d56c3e --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/base.py @@ -0,0 +1,677 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union + +from google.cloud.certificate_manager_v1 import gapic_version as package_version + +import google.auth # type: ignore +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.certificate_manager_v1.types import certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_manager +from google.cloud.location import locations_pb2 # type: ignore +from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + + +class CertificateManagerTransport(abc.ABC): + """Abstract transport class for CertificateManager.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'certificatemanager.googleapis.com' + def __init__( + self, *, + host: str = DEFAULT_HOST, + credentials: Optional[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, + api_audience: Optional[str] = None, + **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. + """ + + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_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) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience(api_audience if api_audience else host) + + # If the credentials are 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 + + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ':' not in host: + host += ':443' + self._host = host + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.list_certificates: gapic_v1.method.wrap_method( + self.list_certificates, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_certificate: gapic_v1.method.wrap_method( + self.get_certificate, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_certificate: gapic_v1.method.wrap_method( + self.create_certificate, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.update_certificate: gapic_v1.method.wrap_method( + self.update_certificate, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.delete_certificate: gapic_v1.method.wrap_method( + self.delete_certificate, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_certificate_maps: gapic_v1.method.wrap_method( + self.list_certificate_maps, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_certificate_map: gapic_v1.method.wrap_method( + self.get_certificate_map, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_certificate_map: gapic_v1.method.wrap_method( + self.create_certificate_map, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.update_certificate_map: gapic_v1.method.wrap_method( + self.update_certificate_map, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.delete_certificate_map: gapic_v1.method.wrap_method( + self.delete_certificate_map, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_certificate_map_entries: gapic_v1.method.wrap_method( + self.list_certificate_map_entries, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_certificate_map_entry: gapic_v1.method.wrap_method( + self.get_certificate_map_entry, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_certificate_map_entry: gapic_v1.method.wrap_method( + self.create_certificate_map_entry, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.update_certificate_map_entry: gapic_v1.method.wrap_method( + self.update_certificate_map_entry, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.delete_certificate_map_entry: gapic_v1.method.wrap_method( + self.delete_certificate_map_entry, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_dns_authorizations: gapic_v1.method.wrap_method( + self.list_dns_authorizations, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_dns_authorization: gapic_v1.method.wrap_method( + self.get_dns_authorization, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_dns_authorization: gapic_v1.method.wrap_method( + self.create_dns_authorization, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.update_dns_authorization: gapic_v1.method.wrap_method( + self.update_dns_authorization, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.delete_dns_authorization: gapic_v1.method.wrap_method( + self.delete_dns_authorization, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_certificate_issuance_configs: gapic_v1.method.wrap_method( + self.list_certificate_issuance_configs, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_certificate_issuance_config: gapic_v1.method.wrap_method( + self.get_certificate_issuance_config, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_certificate_issuance_config: gapic_v1.method.wrap_method( + self.create_certificate_issuance_config, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.delete_certificate_issuance_config: gapic_v1.method.wrap_method( + self.delete_certificate_issuance_config, + default_retry=retries.Retry( +initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + } + + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + + @property + def operations_client(self): + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def list_certificates(self) -> Callable[ + [certificate_manager.ListCertificatesRequest], + Union[ + certificate_manager.ListCertificatesResponse, + Awaitable[certificate_manager.ListCertificatesResponse] + ]]: + raise NotImplementedError() + + @property + def get_certificate(self) -> Callable[ + [certificate_manager.GetCertificateRequest], + Union[ + certificate_manager.Certificate, + Awaitable[certificate_manager.Certificate] + ]]: + raise NotImplementedError() + + @property + def create_certificate(self) -> Callable[ + [certificate_manager.CreateCertificateRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_certificate(self) -> Callable[ + [certificate_manager.UpdateCertificateRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_certificate(self) -> Callable[ + [certificate_manager.DeleteCertificateRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_certificate_maps(self) -> Callable[ + [certificate_manager.ListCertificateMapsRequest], + Union[ + certificate_manager.ListCertificateMapsResponse, + Awaitable[certificate_manager.ListCertificateMapsResponse] + ]]: + raise NotImplementedError() + + @property + def get_certificate_map(self) -> Callable[ + [certificate_manager.GetCertificateMapRequest], + Union[ + certificate_manager.CertificateMap, + Awaitable[certificate_manager.CertificateMap] + ]]: + raise NotImplementedError() + + @property + def create_certificate_map(self) -> Callable[ + [certificate_manager.CreateCertificateMapRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_certificate_map(self) -> Callable[ + [certificate_manager.UpdateCertificateMapRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_certificate_map(self) -> Callable[ + [certificate_manager.DeleteCertificateMapRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_certificate_map_entries(self) -> Callable[ + [certificate_manager.ListCertificateMapEntriesRequest], + Union[ + certificate_manager.ListCertificateMapEntriesResponse, + Awaitable[certificate_manager.ListCertificateMapEntriesResponse] + ]]: + raise NotImplementedError() + + @property + def get_certificate_map_entry(self) -> Callable[ + [certificate_manager.GetCertificateMapEntryRequest], + Union[ + certificate_manager.CertificateMapEntry, + Awaitable[certificate_manager.CertificateMapEntry] + ]]: + raise NotImplementedError() + + @property + def create_certificate_map_entry(self) -> Callable[ + [certificate_manager.CreateCertificateMapEntryRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_certificate_map_entry(self) -> Callable[ + [certificate_manager.UpdateCertificateMapEntryRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_certificate_map_entry(self) -> Callable[ + [certificate_manager.DeleteCertificateMapEntryRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_dns_authorizations(self) -> Callable[ + [certificate_manager.ListDnsAuthorizationsRequest], + Union[ + certificate_manager.ListDnsAuthorizationsResponse, + Awaitable[certificate_manager.ListDnsAuthorizationsResponse] + ]]: + raise NotImplementedError() + + @property + def get_dns_authorization(self) -> Callable[ + [certificate_manager.GetDnsAuthorizationRequest], + Union[ + certificate_manager.DnsAuthorization, + Awaitable[certificate_manager.DnsAuthorization] + ]]: + raise NotImplementedError() + + @property + def create_dns_authorization(self) -> Callable[ + [certificate_manager.CreateDnsAuthorizationRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_dns_authorization(self) -> Callable[ + [certificate_manager.UpdateDnsAuthorizationRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_dns_authorization(self) -> Callable[ + [certificate_manager.DeleteDnsAuthorizationRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_certificate_issuance_configs(self) -> Callable[ + [certificate_issuance_config.ListCertificateIssuanceConfigsRequest], + Union[ + certificate_issuance_config.ListCertificateIssuanceConfigsResponse, + Awaitable[certificate_issuance_config.ListCertificateIssuanceConfigsResponse] + ]]: + raise NotImplementedError() + + @property + def get_certificate_issuance_config(self) -> Callable[ + [certificate_issuance_config.GetCertificateIssuanceConfigRequest], + Union[ + certificate_issuance_config.CertificateIssuanceConfig, + Awaitable[certificate_issuance_config.CertificateIssuanceConfig] + ]]: + raise NotImplementedError() + + @property + def create_certificate_issuance_config(self) -> Callable[ + [gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_certificate_issuance_config(self) -> Callable[ + [certificate_issuance_config.DeleteCertificateIssuanceConfigRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_operations( + self, + ) -> Callable[ + [operations_pb2.ListOperationsRequest], + Union[operations_pb2.ListOperationsResponse, Awaitable[operations_pb2.ListOperationsResponse]], + ]: + raise NotImplementedError() + + @property + def get_operation( + self, + ) -> Callable[ + [operations_pb2.GetOperationRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def cancel_operation( + self, + ) -> Callable[ + [operations_pb2.CancelOperationRequest], + None, + ]: + raise NotImplementedError() + + @property + def delete_operation( + self, + ) -> Callable[ + [operations_pb2.DeleteOperationRequest], + None, + ]: + raise NotImplementedError() + + @property + def get_location(self, + ) -> Callable[ + [locations_pb2.GetLocationRequest], + Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], + ]: + raise NotImplementedError() + + @property + def list_locations(self, + ) -> Callable[ + [locations_pb2.ListLocationsRequest], + Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], + ]: + raise NotImplementedError() + + @property + def kind(self) -> str: + raise NotImplementedError() + + +__all__ = ( + 'CertificateManagerTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc.py new file mode 100644 index 0000000..a6daa67 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc.py @@ -0,0 +1,1036 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import operations_v1 +from google.api_core import gapic_v1 +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.certificate_manager_v1.types import certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_manager +from google.cloud.location import locations_pb2 # type: ignore +from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore +from .base import CertificateManagerTransport, DEFAULT_CLIENT_INFO + + +class CertificateManagerGrpcTransport(CertificateManagerTransport): + """gRPC backend transport for CertificateManager. + + API Overview + + Certificates Manager API allows customers to see and manage all + their TLS certificates. + + Certificates Manager API service provides methods to manage + certificates, group them into collections, and create serving + configuration that can be easily applied to other Cloud resources + e.g. Target Proxies. + + Data Model + + The Certificates Manager service exposes the following resources: + + - ``Certificate`` that describes a single TLS certificate. + - ``CertificateMap`` that describes a collection of certificates + that can be attached to a target resource. + - ``CertificateMapEntry`` that describes a single configuration + entry that consists of a SNI and a group of certificates. It's a + subresource of CertificateMap. + + Certificate, CertificateMap and CertificateMapEntry IDs have to + fully match the regexp ``[a-z0-9-]{1,63}``. In other words, + + - only lower case letters, digits, and hyphen are allowed + - length of the resource ID has to be in [1,63] range. + + Provides methods to manage Cloud Certificate Manager entities. + + 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 = 'certificatemanager.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[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, + api_audience: Optional[str] = None, + ) -> 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 application 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 the 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 a 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. + 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 + 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: Optional[operations_v1.OperationsClient] = 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=always_use_jwt_access, + api_audience=api_audience, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + # use the credentials which are saved + credentials=self._credentials, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, + 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 = 'certificatemanager.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[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. + """ + # Quick 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_certificates(self) -> Callable[ + [certificate_manager.ListCertificatesRequest], + certificate_manager.ListCertificatesResponse]: + r"""Return a callable for the list certificates method over gRPC. + + Lists Certificates in a given project and location. + + Returns: + Callable[[~.ListCertificatesRequest], + ~.ListCertificatesResponse]: + 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_certificates' not in self._stubs: + self._stubs['list_certificates'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificates', + request_serializer=certificate_manager.ListCertificatesRequest.serialize, + response_deserializer=certificate_manager.ListCertificatesResponse.deserialize, + ) + return self._stubs['list_certificates'] + + @property + def get_certificate(self) -> Callable[ + [certificate_manager.GetCertificateRequest], + certificate_manager.Certificate]: + r"""Return a callable for the get certificate method over gRPC. + + Gets details of a single Certificate. + + Returns: + Callable[[~.GetCertificateRequest], + ~.Certificate]: + 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_certificate' not in self._stubs: + self._stubs['get_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificate', + request_serializer=certificate_manager.GetCertificateRequest.serialize, + response_deserializer=certificate_manager.Certificate.deserialize, + ) + return self._stubs['get_certificate'] + + @property + def create_certificate(self) -> Callable[ + [certificate_manager.CreateCertificateRequest], + operations_pb2.Operation]: + r"""Return a callable for the create certificate method over gRPC. + + Creates a new Certificate in a given project and + location. + + Returns: + Callable[[~.CreateCertificateRequest], + ~.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_certificate' not in self._stubs: + self._stubs['create_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificate', + request_serializer=certificate_manager.CreateCertificateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate'] + + @property + def update_certificate(self) -> Callable[ + [certificate_manager.UpdateCertificateRequest], + operations_pb2.Operation]: + r"""Return a callable for the update certificate method over gRPC. + + Updates a Certificate. + + Returns: + Callable[[~.UpdateCertificateRequest], + ~.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_certificate' not in self._stubs: + self._stubs['update_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificate', + request_serializer=certificate_manager.UpdateCertificateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate'] + + @property + def delete_certificate(self) -> Callable[ + [certificate_manager.DeleteCertificateRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete certificate method over gRPC. + + Deletes a single Certificate. + + Returns: + Callable[[~.DeleteCertificateRequest], + ~.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_certificate' not in self._stubs: + self._stubs['delete_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificate', + request_serializer=certificate_manager.DeleteCertificateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_certificate'] + + @property + def list_certificate_maps(self) -> Callable[ + [certificate_manager.ListCertificateMapsRequest], + certificate_manager.ListCertificateMapsResponse]: + r"""Return a callable for the list certificate maps method over gRPC. + + Lists CertificateMaps in a given project and + location. + + Returns: + Callable[[~.ListCertificateMapsRequest], + ~.ListCertificateMapsResponse]: + 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_certificate_maps' not in self._stubs: + self._stubs['list_certificate_maps'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateMaps', + request_serializer=certificate_manager.ListCertificateMapsRequest.serialize, + response_deserializer=certificate_manager.ListCertificateMapsResponse.deserialize, + ) + return self._stubs['list_certificate_maps'] + + @property + def get_certificate_map(self) -> Callable[ + [certificate_manager.GetCertificateMapRequest], + certificate_manager.CertificateMap]: + r"""Return a callable for the get certificate map method over gRPC. + + Gets details of a single CertificateMap. + + Returns: + Callable[[~.GetCertificateMapRequest], + ~.CertificateMap]: + 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_certificate_map' not in self._stubs: + self._stubs['get_certificate_map'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateMap', + request_serializer=certificate_manager.GetCertificateMapRequest.serialize, + response_deserializer=certificate_manager.CertificateMap.deserialize, + ) + return self._stubs['get_certificate_map'] + + @property + def create_certificate_map(self) -> Callable[ + [certificate_manager.CreateCertificateMapRequest], + operations_pb2.Operation]: + r"""Return a callable for the create certificate map method over gRPC. + + Creates a new CertificateMap in a given project and + location. + + Returns: + Callable[[~.CreateCertificateMapRequest], + ~.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_certificate_map' not in self._stubs: + self._stubs['create_certificate_map'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateMap', + request_serializer=certificate_manager.CreateCertificateMapRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate_map'] + + @property + def update_certificate_map(self) -> Callable[ + [certificate_manager.UpdateCertificateMapRequest], + operations_pb2.Operation]: + r"""Return a callable for the update certificate map method over gRPC. + + Updates a CertificateMap. + + Returns: + Callable[[~.UpdateCertificateMapRequest], + ~.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_certificate_map' not in self._stubs: + self._stubs['update_certificate_map'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificateMap', + request_serializer=certificate_manager.UpdateCertificateMapRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_map'] + + @property + def delete_certificate_map(self) -> Callable[ + [certificate_manager.DeleteCertificateMapRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete certificate map method over gRPC. + + Deletes a single CertificateMap. A Certificate Map + can't be deleted if it contains Certificate Map Entries. + Remove all the entries from the map before calling this + method. + + Returns: + Callable[[~.DeleteCertificateMapRequest], + ~.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_certificate_map' not in self._stubs: + self._stubs['delete_certificate_map'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateMap', + request_serializer=certificate_manager.DeleteCertificateMapRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_certificate_map'] + + @property + def list_certificate_map_entries(self) -> Callable[ + [certificate_manager.ListCertificateMapEntriesRequest], + certificate_manager.ListCertificateMapEntriesResponse]: + r"""Return a callable for the list certificate map entries method over gRPC. + + Lists CertificateMapEntries in a given project and + location. + + Returns: + Callable[[~.ListCertificateMapEntriesRequest], + ~.ListCertificateMapEntriesResponse]: + 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_certificate_map_entries' not in self._stubs: + self._stubs['list_certificate_map_entries'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateMapEntries', + request_serializer=certificate_manager.ListCertificateMapEntriesRequest.serialize, + response_deserializer=certificate_manager.ListCertificateMapEntriesResponse.deserialize, + ) + return self._stubs['list_certificate_map_entries'] + + @property + def get_certificate_map_entry(self) -> Callable[ + [certificate_manager.GetCertificateMapEntryRequest], + certificate_manager.CertificateMapEntry]: + r"""Return a callable for the get certificate map entry method over gRPC. + + Gets details of a single CertificateMapEntry. + + Returns: + Callable[[~.GetCertificateMapEntryRequest], + ~.CertificateMapEntry]: + 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_certificate_map_entry' not in self._stubs: + self._stubs['get_certificate_map_entry'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateMapEntry', + request_serializer=certificate_manager.GetCertificateMapEntryRequest.serialize, + response_deserializer=certificate_manager.CertificateMapEntry.deserialize, + ) + return self._stubs['get_certificate_map_entry'] + + @property + def create_certificate_map_entry(self) -> Callable[ + [certificate_manager.CreateCertificateMapEntryRequest], + operations_pb2.Operation]: + r"""Return a callable for the create certificate map entry method over gRPC. + + Creates a new CertificateMapEntry in a given project + and location. + + Returns: + Callable[[~.CreateCertificateMapEntryRequest], + ~.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_certificate_map_entry' not in self._stubs: + self._stubs['create_certificate_map_entry'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateMapEntry', + request_serializer=certificate_manager.CreateCertificateMapEntryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate_map_entry'] + + @property + def update_certificate_map_entry(self) -> Callable[ + [certificate_manager.UpdateCertificateMapEntryRequest], + operations_pb2.Operation]: + r"""Return a callable for the update certificate map entry method over gRPC. + + Updates a CertificateMapEntry. + + Returns: + Callable[[~.UpdateCertificateMapEntryRequest], + ~.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_certificate_map_entry' not in self._stubs: + self._stubs['update_certificate_map_entry'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificateMapEntry', + request_serializer=certificate_manager.UpdateCertificateMapEntryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_map_entry'] + + @property + def delete_certificate_map_entry(self) -> Callable[ + [certificate_manager.DeleteCertificateMapEntryRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete certificate map entry method over gRPC. + + Deletes a single CertificateMapEntry. + + Returns: + Callable[[~.DeleteCertificateMapEntryRequest], + ~.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_certificate_map_entry' not in self._stubs: + self._stubs['delete_certificate_map_entry'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateMapEntry', + request_serializer=certificate_manager.DeleteCertificateMapEntryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_certificate_map_entry'] + + @property + def list_dns_authorizations(self) -> Callable[ + [certificate_manager.ListDnsAuthorizationsRequest], + certificate_manager.ListDnsAuthorizationsResponse]: + r"""Return a callable for the list dns authorizations method over gRPC. + + Lists DnsAuthorizations in a given project and + location. + + Returns: + Callable[[~.ListDnsAuthorizationsRequest], + ~.ListDnsAuthorizationsResponse]: + 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_dns_authorizations' not in self._stubs: + self._stubs['list_dns_authorizations'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/ListDnsAuthorizations', + request_serializer=certificate_manager.ListDnsAuthorizationsRequest.serialize, + response_deserializer=certificate_manager.ListDnsAuthorizationsResponse.deserialize, + ) + return self._stubs['list_dns_authorizations'] + + @property + def get_dns_authorization(self) -> Callable[ + [certificate_manager.GetDnsAuthorizationRequest], + certificate_manager.DnsAuthorization]: + r"""Return a callable for the get dns authorization method over gRPC. + + Gets details of a single DnsAuthorization. + + Returns: + Callable[[~.GetDnsAuthorizationRequest], + ~.DnsAuthorization]: + 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_dns_authorization' not in self._stubs: + self._stubs['get_dns_authorization'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/GetDnsAuthorization', + request_serializer=certificate_manager.GetDnsAuthorizationRequest.serialize, + response_deserializer=certificate_manager.DnsAuthorization.deserialize, + ) + return self._stubs['get_dns_authorization'] + + @property + def create_dns_authorization(self) -> Callable[ + [certificate_manager.CreateDnsAuthorizationRequest], + operations_pb2.Operation]: + r"""Return a callable for the create dns authorization method over gRPC. + + Creates a new DnsAuthorization in a given project and + location. + + Returns: + Callable[[~.CreateDnsAuthorizationRequest], + ~.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_dns_authorization' not in self._stubs: + self._stubs['create_dns_authorization'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/CreateDnsAuthorization', + request_serializer=certificate_manager.CreateDnsAuthorizationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_dns_authorization'] + + @property + def update_dns_authorization(self) -> Callable[ + [certificate_manager.UpdateDnsAuthorizationRequest], + operations_pb2.Operation]: + r"""Return a callable for the update dns authorization method over gRPC. + + Updates a DnsAuthorization. + + Returns: + Callable[[~.UpdateDnsAuthorizationRequest], + ~.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_dns_authorization' not in self._stubs: + self._stubs['update_dns_authorization'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/UpdateDnsAuthorization', + request_serializer=certificate_manager.UpdateDnsAuthorizationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_dns_authorization'] + + @property + def delete_dns_authorization(self) -> Callable[ + [certificate_manager.DeleteDnsAuthorizationRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete dns authorization method over gRPC. + + Deletes a single DnsAuthorization. + + Returns: + Callable[[~.DeleteDnsAuthorizationRequest], + ~.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_dns_authorization' not in self._stubs: + self._stubs['delete_dns_authorization'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/DeleteDnsAuthorization', + request_serializer=certificate_manager.DeleteDnsAuthorizationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_dns_authorization'] + + @property + def list_certificate_issuance_configs(self) -> Callable[ + [certificate_issuance_config.ListCertificateIssuanceConfigsRequest], + certificate_issuance_config.ListCertificateIssuanceConfigsResponse]: + r"""Return a callable for the list certificate issuance + configs method over gRPC. + + Lists CertificateIssuanceConfigs in a given project + and location. + + Returns: + Callable[[~.ListCertificateIssuanceConfigsRequest], + ~.ListCertificateIssuanceConfigsResponse]: + 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_certificate_issuance_configs' not in self._stubs: + self._stubs['list_certificate_issuance_configs'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateIssuanceConfigs', + request_serializer=certificate_issuance_config.ListCertificateIssuanceConfigsRequest.serialize, + response_deserializer=certificate_issuance_config.ListCertificateIssuanceConfigsResponse.deserialize, + ) + return self._stubs['list_certificate_issuance_configs'] + + @property + def get_certificate_issuance_config(self) -> Callable[ + [certificate_issuance_config.GetCertificateIssuanceConfigRequest], + certificate_issuance_config.CertificateIssuanceConfig]: + r"""Return a callable for the get certificate issuance + config method over gRPC. + + Gets details of a single CertificateIssuanceConfig. + + Returns: + Callable[[~.GetCertificateIssuanceConfigRequest], + ~.CertificateIssuanceConfig]: + 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_certificate_issuance_config' not in self._stubs: + self._stubs['get_certificate_issuance_config'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateIssuanceConfig', + request_serializer=certificate_issuance_config.GetCertificateIssuanceConfigRequest.serialize, + response_deserializer=certificate_issuance_config.CertificateIssuanceConfig.deserialize, + ) + return self._stubs['get_certificate_issuance_config'] + + @property + def create_certificate_issuance_config(self) -> Callable[ + [gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest], + operations_pb2.Operation]: + r"""Return a callable for the create certificate issuance + config method over gRPC. + + Creates a new CertificateIssuanceConfig in a given + project and location. + + Returns: + Callable[[~.CreateCertificateIssuanceConfigRequest], + ~.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_certificate_issuance_config' not in self._stubs: + self._stubs['create_certificate_issuance_config'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateIssuanceConfig', + request_serializer=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate_issuance_config'] + + @property + def delete_certificate_issuance_config(self) -> Callable[ + [certificate_issuance_config.DeleteCertificateIssuanceConfigRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete certificate issuance + config method over gRPC. + + Deletes a single CertificateIssuanceConfig. + + Returns: + Callable[[~.DeleteCertificateIssuanceConfigRequest], + ~.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_certificate_issuance_config' not in self._stubs: + self._stubs['delete_certificate_issuance_config'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateIssuanceConfig', + request_serializer=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_certificate_issuance_config'] + + def close(self): + self.grpc_channel.close() + + @property + def delete_operation( + self, + ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: + r"""Return a callable for the delete_operation method over gRPC. + """ + # 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_operation" not in self._stubs: + self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/DeleteOperation", + request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, + response_deserializer=None, + ) + return self._stubs["delete_operation"] + + @property + def cancel_operation( + self, + ) -> Callable[[operations_pb2.CancelOperationRequest], None]: + r"""Return a callable for the cancel_operation method over gRPC. + """ + # 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 "cancel_operation" not in self._stubs: + self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/CancelOperation", + request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, + response_deserializer=None, + ) + return self._stubs["cancel_operation"] + + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC. + """ + # 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_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + + @property + def list_operations( + self, + ) -> Callable[[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse]: + r"""Return a callable for the list_operations method over gRPC. + """ + # 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_operations" not in self._stubs: + self._stubs["list_operations"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/ListOperations", + request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, + response_deserializer=operations_pb2.ListOperationsResponse.FromString, + ) + return self._stubs["list_operations"] + + @property + def list_locations( + self, + ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: + r"""Return a callable for the list locations method over gRPC. + """ + # 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_locations" not in self._stubs: + self._stubs["list_locations"] = self.grpc_channel.unary_unary( + "/google.cloud.location.Locations/ListLocations", + request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, + response_deserializer=locations_pb2.ListLocationsResponse.FromString, + ) + return self._stubs["list_locations"] + + @property + def get_location( + self, + ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: + r"""Return a callable for the list locations method over gRPC. + """ + # 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_location" not in self._stubs: + self._stubs["get_location"] = self.grpc_channel.unary_unary( + "/google.cloud.location.Locations/GetLocation", + request_serializer=locations_pb2.GetLocationRequest.SerializeToString, + response_deserializer=locations_pb2.Location.FromString, + ) + return self._stubs["get_location"] + + @property + def kind(self) -> str: + return "grpc" + + +__all__ = ( + 'CertificateManagerGrpcTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc_asyncio.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc_asyncio.py new file mode 100644 index 0000000..1c41990 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc_asyncio.py @@ -0,0 +1,1035 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.certificate_manager_v1.types import certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_manager +from google.cloud.location import locations_pb2 # type: ignore +from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore +from .base import CertificateManagerTransport, DEFAULT_CLIENT_INFO +from .grpc import CertificateManagerGrpcTransport + + +class CertificateManagerGrpcAsyncIOTransport(CertificateManagerTransport): + """gRPC AsyncIO backend transport for CertificateManager. + + API Overview + + Certificates Manager API allows customers to see and manage all + their TLS certificates. + + Certificates Manager API service provides methods to manage + certificates, group them into collections, and create serving + configuration that can be easily applied to other Cloud resources + e.g. Target Proxies. + + Data Model + + The Certificates Manager service exposes the following resources: + + - ``Certificate`` that describes a single TLS certificate. + - ``CertificateMap`` that describes a collection of certificates + that can be attached to a target resource. + - ``CertificateMapEntry`` that describes a single configuration + entry that consists of a SNI and a group of certificates. It's a + subresource of CertificateMap. + + Certificate, CertificateMap and CertificateMapEntry IDs have to + fully match the regexp ``[a-z0-9-]{1,63}``. In other words, + + - only lower case letters, digits, and hyphen are allowed + - length of the resource ID has to be in [1,63] range. + + Provides methods to manage Cloud Certificate Manager entities. + + 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 = 'certificatemanager.googleapis.com', + credentials: Optional[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 = 'certificatemanager.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[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, + api_audience: Optional[str] = None, + ) -> 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 application 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 the 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 a 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. + 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 + 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: Optional[operations_v1.OperationsAsyncClient] = 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=always_use_jwt_access, + api_audience=api_audience, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + # use the credentials which are saved + credentials=self._credentials, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, + 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. + """ + # Quick 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_certificates(self) -> Callable[ + [certificate_manager.ListCertificatesRequest], + Awaitable[certificate_manager.ListCertificatesResponse]]: + r"""Return a callable for the list certificates method over gRPC. + + Lists Certificates in a given project and location. + + Returns: + Callable[[~.ListCertificatesRequest], + Awaitable[~.ListCertificatesResponse]]: + 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_certificates' not in self._stubs: + self._stubs['list_certificates'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificates', + request_serializer=certificate_manager.ListCertificatesRequest.serialize, + response_deserializer=certificate_manager.ListCertificatesResponse.deserialize, + ) + return self._stubs['list_certificates'] + + @property + def get_certificate(self) -> Callable[ + [certificate_manager.GetCertificateRequest], + Awaitable[certificate_manager.Certificate]]: + r"""Return a callable for the get certificate method over gRPC. + + Gets details of a single Certificate. + + Returns: + Callable[[~.GetCertificateRequest], + Awaitable[~.Certificate]]: + 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_certificate' not in self._stubs: + self._stubs['get_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificate', + request_serializer=certificate_manager.GetCertificateRequest.serialize, + response_deserializer=certificate_manager.Certificate.deserialize, + ) + return self._stubs['get_certificate'] + + @property + def create_certificate(self) -> Callable[ + [certificate_manager.CreateCertificateRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create certificate method over gRPC. + + Creates a new Certificate in a given project and + location. + + Returns: + Callable[[~.CreateCertificateRequest], + 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_certificate' not in self._stubs: + self._stubs['create_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificate', + request_serializer=certificate_manager.CreateCertificateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate'] + + @property + def update_certificate(self) -> Callable[ + [certificate_manager.UpdateCertificateRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update certificate method over gRPC. + + Updates a Certificate. + + Returns: + Callable[[~.UpdateCertificateRequest], + 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_certificate' not in self._stubs: + self._stubs['update_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificate', + request_serializer=certificate_manager.UpdateCertificateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate'] + + @property + def delete_certificate(self) -> Callable[ + [certificate_manager.DeleteCertificateRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete certificate method over gRPC. + + Deletes a single Certificate. + + Returns: + Callable[[~.DeleteCertificateRequest], + 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_certificate' not in self._stubs: + self._stubs['delete_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificate', + request_serializer=certificate_manager.DeleteCertificateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_certificate'] + + @property + def list_certificate_maps(self) -> Callable[ + [certificate_manager.ListCertificateMapsRequest], + Awaitable[certificate_manager.ListCertificateMapsResponse]]: + r"""Return a callable for the list certificate maps method over gRPC. + + Lists CertificateMaps in a given project and + location. + + Returns: + Callable[[~.ListCertificateMapsRequest], + Awaitable[~.ListCertificateMapsResponse]]: + 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_certificate_maps' not in self._stubs: + self._stubs['list_certificate_maps'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateMaps', + request_serializer=certificate_manager.ListCertificateMapsRequest.serialize, + response_deserializer=certificate_manager.ListCertificateMapsResponse.deserialize, + ) + return self._stubs['list_certificate_maps'] + + @property + def get_certificate_map(self) -> Callable[ + [certificate_manager.GetCertificateMapRequest], + Awaitable[certificate_manager.CertificateMap]]: + r"""Return a callable for the get certificate map method over gRPC. + + Gets details of a single CertificateMap. + + Returns: + Callable[[~.GetCertificateMapRequest], + Awaitable[~.CertificateMap]]: + 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_certificate_map' not in self._stubs: + self._stubs['get_certificate_map'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateMap', + request_serializer=certificate_manager.GetCertificateMapRequest.serialize, + response_deserializer=certificate_manager.CertificateMap.deserialize, + ) + return self._stubs['get_certificate_map'] + + @property + def create_certificate_map(self) -> Callable[ + [certificate_manager.CreateCertificateMapRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create certificate map method over gRPC. + + Creates a new CertificateMap in a given project and + location. + + Returns: + Callable[[~.CreateCertificateMapRequest], + 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_certificate_map' not in self._stubs: + self._stubs['create_certificate_map'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateMap', + request_serializer=certificate_manager.CreateCertificateMapRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate_map'] + + @property + def update_certificate_map(self) -> Callable[ + [certificate_manager.UpdateCertificateMapRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update certificate map method over gRPC. + + Updates a CertificateMap. + + Returns: + Callable[[~.UpdateCertificateMapRequest], + 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_certificate_map' not in self._stubs: + self._stubs['update_certificate_map'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificateMap', + request_serializer=certificate_manager.UpdateCertificateMapRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_map'] + + @property + def delete_certificate_map(self) -> Callable[ + [certificate_manager.DeleteCertificateMapRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete certificate map method over gRPC. + + Deletes a single CertificateMap. A Certificate Map + can't be deleted if it contains Certificate Map Entries. + Remove all the entries from the map before calling this + method. + + Returns: + Callable[[~.DeleteCertificateMapRequest], + 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_certificate_map' not in self._stubs: + self._stubs['delete_certificate_map'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateMap', + request_serializer=certificate_manager.DeleteCertificateMapRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_certificate_map'] + + @property + def list_certificate_map_entries(self) -> Callable[ + [certificate_manager.ListCertificateMapEntriesRequest], + Awaitable[certificate_manager.ListCertificateMapEntriesResponse]]: + r"""Return a callable for the list certificate map entries method over gRPC. + + Lists CertificateMapEntries in a given project and + location. + + Returns: + Callable[[~.ListCertificateMapEntriesRequest], + Awaitable[~.ListCertificateMapEntriesResponse]]: + 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_certificate_map_entries' not in self._stubs: + self._stubs['list_certificate_map_entries'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateMapEntries', + request_serializer=certificate_manager.ListCertificateMapEntriesRequest.serialize, + response_deserializer=certificate_manager.ListCertificateMapEntriesResponse.deserialize, + ) + return self._stubs['list_certificate_map_entries'] + + @property + def get_certificate_map_entry(self) -> Callable[ + [certificate_manager.GetCertificateMapEntryRequest], + Awaitable[certificate_manager.CertificateMapEntry]]: + r"""Return a callable for the get certificate map entry method over gRPC. + + Gets details of a single CertificateMapEntry. + + Returns: + Callable[[~.GetCertificateMapEntryRequest], + Awaitable[~.CertificateMapEntry]]: + 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_certificate_map_entry' not in self._stubs: + self._stubs['get_certificate_map_entry'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateMapEntry', + request_serializer=certificate_manager.GetCertificateMapEntryRequest.serialize, + response_deserializer=certificate_manager.CertificateMapEntry.deserialize, + ) + return self._stubs['get_certificate_map_entry'] + + @property + def create_certificate_map_entry(self) -> Callable[ + [certificate_manager.CreateCertificateMapEntryRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create certificate map entry method over gRPC. + + Creates a new CertificateMapEntry in a given project + and location. + + Returns: + Callable[[~.CreateCertificateMapEntryRequest], + 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_certificate_map_entry' not in self._stubs: + self._stubs['create_certificate_map_entry'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateMapEntry', + request_serializer=certificate_manager.CreateCertificateMapEntryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate_map_entry'] + + @property + def update_certificate_map_entry(self) -> Callable[ + [certificate_manager.UpdateCertificateMapEntryRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update certificate map entry method over gRPC. + + Updates a CertificateMapEntry. + + Returns: + Callable[[~.UpdateCertificateMapEntryRequest], + 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_certificate_map_entry' not in self._stubs: + self._stubs['update_certificate_map_entry'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificateMapEntry', + request_serializer=certificate_manager.UpdateCertificateMapEntryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_map_entry'] + + @property + def delete_certificate_map_entry(self) -> Callable[ + [certificate_manager.DeleteCertificateMapEntryRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete certificate map entry method over gRPC. + + Deletes a single CertificateMapEntry. + + Returns: + Callable[[~.DeleteCertificateMapEntryRequest], + 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_certificate_map_entry' not in self._stubs: + self._stubs['delete_certificate_map_entry'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateMapEntry', + request_serializer=certificate_manager.DeleteCertificateMapEntryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_certificate_map_entry'] + + @property + def list_dns_authorizations(self) -> Callable[ + [certificate_manager.ListDnsAuthorizationsRequest], + Awaitable[certificate_manager.ListDnsAuthorizationsResponse]]: + r"""Return a callable for the list dns authorizations method over gRPC. + + Lists DnsAuthorizations in a given project and + location. + + Returns: + Callable[[~.ListDnsAuthorizationsRequest], + Awaitable[~.ListDnsAuthorizationsResponse]]: + 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_dns_authorizations' not in self._stubs: + self._stubs['list_dns_authorizations'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/ListDnsAuthorizations', + request_serializer=certificate_manager.ListDnsAuthorizationsRequest.serialize, + response_deserializer=certificate_manager.ListDnsAuthorizationsResponse.deserialize, + ) + return self._stubs['list_dns_authorizations'] + + @property + def get_dns_authorization(self) -> Callable[ + [certificate_manager.GetDnsAuthorizationRequest], + Awaitable[certificate_manager.DnsAuthorization]]: + r"""Return a callable for the get dns authorization method over gRPC. + + Gets details of a single DnsAuthorization. + + Returns: + Callable[[~.GetDnsAuthorizationRequest], + Awaitable[~.DnsAuthorization]]: + 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_dns_authorization' not in self._stubs: + self._stubs['get_dns_authorization'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/GetDnsAuthorization', + request_serializer=certificate_manager.GetDnsAuthorizationRequest.serialize, + response_deserializer=certificate_manager.DnsAuthorization.deserialize, + ) + return self._stubs['get_dns_authorization'] + + @property + def create_dns_authorization(self) -> Callable[ + [certificate_manager.CreateDnsAuthorizationRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create dns authorization method over gRPC. + + Creates a new DnsAuthorization in a given project and + location. + + Returns: + Callable[[~.CreateDnsAuthorizationRequest], + 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_dns_authorization' not in self._stubs: + self._stubs['create_dns_authorization'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/CreateDnsAuthorization', + request_serializer=certificate_manager.CreateDnsAuthorizationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_dns_authorization'] + + @property + def update_dns_authorization(self) -> Callable[ + [certificate_manager.UpdateDnsAuthorizationRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update dns authorization method over gRPC. + + Updates a DnsAuthorization. + + Returns: + Callable[[~.UpdateDnsAuthorizationRequest], + 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_dns_authorization' not in self._stubs: + self._stubs['update_dns_authorization'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/UpdateDnsAuthorization', + request_serializer=certificate_manager.UpdateDnsAuthorizationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_dns_authorization'] + + @property + def delete_dns_authorization(self) -> Callable[ + [certificate_manager.DeleteDnsAuthorizationRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete dns authorization method over gRPC. + + Deletes a single DnsAuthorization. + + Returns: + Callable[[~.DeleteDnsAuthorizationRequest], + 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_dns_authorization' not in self._stubs: + self._stubs['delete_dns_authorization'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/DeleteDnsAuthorization', + request_serializer=certificate_manager.DeleteDnsAuthorizationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_dns_authorization'] + + @property + def list_certificate_issuance_configs(self) -> Callable[ + [certificate_issuance_config.ListCertificateIssuanceConfigsRequest], + Awaitable[certificate_issuance_config.ListCertificateIssuanceConfigsResponse]]: + r"""Return a callable for the list certificate issuance + configs method over gRPC. + + Lists CertificateIssuanceConfigs in a given project + and location. + + Returns: + Callable[[~.ListCertificateIssuanceConfigsRequest], + Awaitable[~.ListCertificateIssuanceConfigsResponse]]: + 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_certificate_issuance_configs' not in self._stubs: + self._stubs['list_certificate_issuance_configs'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateIssuanceConfigs', + request_serializer=certificate_issuance_config.ListCertificateIssuanceConfigsRequest.serialize, + response_deserializer=certificate_issuance_config.ListCertificateIssuanceConfigsResponse.deserialize, + ) + return self._stubs['list_certificate_issuance_configs'] + + @property + def get_certificate_issuance_config(self) -> Callable[ + [certificate_issuance_config.GetCertificateIssuanceConfigRequest], + Awaitable[certificate_issuance_config.CertificateIssuanceConfig]]: + r"""Return a callable for the get certificate issuance + config method over gRPC. + + Gets details of a single CertificateIssuanceConfig. + + Returns: + Callable[[~.GetCertificateIssuanceConfigRequest], + Awaitable[~.CertificateIssuanceConfig]]: + 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_certificate_issuance_config' not in self._stubs: + self._stubs['get_certificate_issuance_config'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateIssuanceConfig', + request_serializer=certificate_issuance_config.GetCertificateIssuanceConfigRequest.serialize, + response_deserializer=certificate_issuance_config.CertificateIssuanceConfig.deserialize, + ) + return self._stubs['get_certificate_issuance_config'] + + @property + def create_certificate_issuance_config(self) -> Callable[ + [gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create certificate issuance + config method over gRPC. + + Creates a new CertificateIssuanceConfig in a given + project and location. + + Returns: + Callable[[~.CreateCertificateIssuanceConfigRequest], + 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_certificate_issuance_config' not in self._stubs: + self._stubs['create_certificate_issuance_config'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateIssuanceConfig', + request_serializer=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate_issuance_config'] + + @property + def delete_certificate_issuance_config(self) -> Callable[ + [certificate_issuance_config.DeleteCertificateIssuanceConfigRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete certificate issuance + config method over gRPC. + + Deletes a single CertificateIssuanceConfig. + + Returns: + Callable[[~.DeleteCertificateIssuanceConfigRequest], + 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_certificate_issuance_config' not in self._stubs: + self._stubs['delete_certificate_issuance_config'] = self.grpc_channel.unary_unary( + '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateIssuanceConfig', + request_serializer=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_certificate_issuance_config'] + + def close(self): + return self.grpc_channel.close() + + @property + def delete_operation( + self, + ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: + r"""Return a callable for the delete_operation method over gRPC. + """ + # 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_operation" not in self._stubs: + self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/DeleteOperation", + request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, + response_deserializer=None, + ) + return self._stubs["delete_operation"] + + @property + def cancel_operation( + self, + ) -> Callable[[operations_pb2.CancelOperationRequest], None]: + r"""Return a callable for the cancel_operation method over gRPC. + """ + # 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 "cancel_operation" not in self._stubs: + self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/CancelOperation", + request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, + response_deserializer=None, + ) + return self._stubs["cancel_operation"] + + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC. + """ + # 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_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + + @property + def list_operations( + self, + ) -> Callable[[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse]: + r"""Return a callable for the list_operations method over gRPC. + """ + # 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_operations" not in self._stubs: + self._stubs["list_operations"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/ListOperations", + request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, + response_deserializer=operations_pb2.ListOperationsResponse.FromString, + ) + return self._stubs["list_operations"] + + @property + def list_locations( + self, + ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: + r"""Return a callable for the list locations method over gRPC. + """ + # 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_locations" not in self._stubs: + self._stubs["list_locations"] = self.grpc_channel.unary_unary( + "/google.cloud.location.Locations/ListLocations", + request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, + response_deserializer=locations_pb2.ListLocationsResponse.FromString, + ) + return self._stubs["list_locations"] + + @property + def get_location( + self, + ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: + r"""Return a callable for the list locations method over gRPC. + """ + # 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_location" not in self._stubs: + self._stubs["get_location"] = self.grpc_channel.unary_unary( + "/google.cloud.location.Locations/GetLocation", + request_serializer=locations_pb2.GetLocationRequest.SerializeToString, + response_deserializer=locations_pb2.Location.FromString, + ) + return self._stubs["get_location"] + + +__all__ = ( + 'CertificateManagerGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py new file mode 100644 index 0000000..5ce38ee --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py @@ -0,0 +1,3498 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from google.auth.transport.requests import AuthorizedSession # type: ignore +import json # type: ignore +import grpc # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.api_core import exceptions as core_exceptions +from google.api_core import retry as retries +from google.api_core import rest_helpers +from google.api_core import rest_streaming +from google.api_core import path_template +from google.api_core import gapic_v1 + +from google.protobuf import json_format +from google.api_core import operations_v1 +from google.cloud.location import locations_pb2 # type: ignore +from google.longrunning import operations_pb2 +from requests import __version__ as requests_version +import dataclasses +import re +from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union +import warnings + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + + +from google.cloud.certificate_manager_v1.types import certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_manager +from google.longrunning import operations_pb2 # type: ignore + +from .base import CertificateManagerTransport, DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO + + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, + grpc_version=None, + rest_version=requests_version, +) + + +class CertificateManagerRestInterceptor: + """Interceptor for CertificateManager. + + Interceptors are used to manipulate requests, request metadata, and responses + in arbitrary ways. + Example use cases include: + * Logging + * Verifying requests according to service or custom semantics + * Stripping extraneous information from responses + + These use cases and more can be enabled by injecting an + instance of a custom subclass when constructing the CertificateManagerRestTransport. + + .. code-block:: python + class MyCustomCertificateManagerInterceptor(CertificateManagerRestInterceptor): + def pre_create_certificate(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_certificate(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_certificate_issuance_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_certificate_issuance_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_certificate_map(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_certificate_map(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_certificate_map_entry(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_certificate_map_entry(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_dns_authorization(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_dns_authorization(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_certificate(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_certificate(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_certificate_issuance_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_certificate_issuance_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_certificate_map(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_certificate_map(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_certificate_map_entry(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_certificate_map_entry(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_dns_authorization(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_dns_authorization(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_certificate(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_certificate(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_certificate_issuance_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_certificate_issuance_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_certificate_map(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_certificate_map(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_certificate_map_entry(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_certificate_map_entry(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_dns_authorization(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_dns_authorization(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_certificate_issuance_configs(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_certificate_issuance_configs(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_certificate_map_entries(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_certificate_map_entries(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_certificate_maps(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_certificate_maps(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_certificates(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_certificates(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_dns_authorizations(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_dns_authorizations(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_certificate(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_certificate(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_certificate_map(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_certificate_map(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_certificate_map_entry(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_certificate_map_entry(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_dns_authorization(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_dns_authorization(self, response): + logging.log(f"Received response: {response}") + return response + + transport = CertificateManagerRestTransport(interceptor=MyCustomCertificateManagerInterceptor()) + client = CertificateManagerClient(transport=transport) + + + """ + def pre_create_certificate(self, request: certificate_manager.CreateCertificateRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.CreateCertificateRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_certificate + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_create_certificate(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_certificate + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_create_certificate_issuance_config(self, request: gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_certificate_issuance_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_create_certificate_issuance_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_certificate_issuance_config + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_create_certificate_map(self, request: certificate_manager.CreateCertificateMapRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.CreateCertificateMapRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_certificate_map + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_create_certificate_map(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_certificate_map + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_create_certificate_map_entry(self, request: certificate_manager.CreateCertificateMapEntryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.CreateCertificateMapEntryRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_certificate_map_entry + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_create_certificate_map_entry(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_certificate_map_entry + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_create_dns_authorization(self, request: certificate_manager.CreateDnsAuthorizationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.CreateDnsAuthorizationRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_dns_authorization + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_create_dns_authorization(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_dns_authorization + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_delete_certificate(self, request: certificate_manager.DeleteCertificateRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.DeleteCertificateRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_certificate + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_delete_certificate(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_certificate + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_delete_certificate_issuance_config(self, request: certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_certificate_issuance_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_delete_certificate_issuance_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_certificate_issuance_config + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_delete_certificate_map(self, request: certificate_manager.DeleteCertificateMapRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.DeleteCertificateMapRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_certificate_map + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_delete_certificate_map(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_certificate_map + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_delete_certificate_map_entry(self, request: certificate_manager.DeleteCertificateMapEntryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.DeleteCertificateMapEntryRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_certificate_map_entry + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_delete_certificate_map_entry(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_certificate_map_entry + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_delete_dns_authorization(self, request: certificate_manager.DeleteDnsAuthorizationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.DeleteDnsAuthorizationRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_dns_authorization + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_delete_dns_authorization(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_dns_authorization + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_get_certificate(self, request: certificate_manager.GetCertificateRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.GetCertificateRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_certificate + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_get_certificate(self, response: certificate_manager.Certificate) -> certificate_manager.Certificate: + """Post-rpc interceptor for get_certificate + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_get_certificate_issuance_config(self, request: certificate_issuance_config.GetCertificateIssuanceConfigRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_issuance_config.GetCertificateIssuanceConfigRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_certificate_issuance_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_get_certificate_issuance_config(self, response: certificate_issuance_config.CertificateIssuanceConfig) -> certificate_issuance_config.CertificateIssuanceConfig: + """Post-rpc interceptor for get_certificate_issuance_config + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_get_certificate_map(self, request: certificate_manager.GetCertificateMapRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.GetCertificateMapRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_certificate_map + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_get_certificate_map(self, response: certificate_manager.CertificateMap) -> certificate_manager.CertificateMap: + """Post-rpc interceptor for get_certificate_map + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_get_certificate_map_entry(self, request: certificate_manager.GetCertificateMapEntryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.GetCertificateMapEntryRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_certificate_map_entry + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_get_certificate_map_entry(self, response: certificate_manager.CertificateMapEntry) -> certificate_manager.CertificateMapEntry: + """Post-rpc interceptor for get_certificate_map_entry + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_get_dns_authorization(self, request: certificate_manager.GetDnsAuthorizationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.GetDnsAuthorizationRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_dns_authorization + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_get_dns_authorization(self, response: certificate_manager.DnsAuthorization) -> certificate_manager.DnsAuthorization: + """Post-rpc interceptor for get_dns_authorization + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_list_certificate_issuance_configs(self, request: certificate_issuance_config.ListCertificateIssuanceConfigsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_issuance_config.ListCertificateIssuanceConfigsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_certificate_issuance_configs + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_list_certificate_issuance_configs(self, response: certificate_issuance_config.ListCertificateIssuanceConfigsResponse) -> certificate_issuance_config.ListCertificateIssuanceConfigsResponse: + """Post-rpc interceptor for list_certificate_issuance_configs + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_list_certificate_map_entries(self, request: certificate_manager.ListCertificateMapEntriesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.ListCertificateMapEntriesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_certificate_map_entries + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_list_certificate_map_entries(self, response: certificate_manager.ListCertificateMapEntriesResponse) -> certificate_manager.ListCertificateMapEntriesResponse: + """Post-rpc interceptor for list_certificate_map_entries + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_list_certificate_maps(self, request: certificate_manager.ListCertificateMapsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.ListCertificateMapsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_certificate_maps + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_list_certificate_maps(self, response: certificate_manager.ListCertificateMapsResponse) -> certificate_manager.ListCertificateMapsResponse: + """Post-rpc interceptor for list_certificate_maps + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_list_certificates(self, request: certificate_manager.ListCertificatesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.ListCertificatesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_certificates + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_list_certificates(self, response: certificate_manager.ListCertificatesResponse) -> certificate_manager.ListCertificatesResponse: + """Post-rpc interceptor for list_certificates + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_list_dns_authorizations(self, request: certificate_manager.ListDnsAuthorizationsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.ListDnsAuthorizationsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_dns_authorizations + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_list_dns_authorizations(self, response: certificate_manager.ListDnsAuthorizationsResponse) -> certificate_manager.ListDnsAuthorizationsResponse: + """Post-rpc interceptor for list_dns_authorizations + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_update_certificate(self, request: certificate_manager.UpdateCertificateRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.UpdateCertificateRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_certificate + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_update_certificate(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_certificate + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_update_certificate_map(self, request: certificate_manager.UpdateCertificateMapRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.UpdateCertificateMapRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_certificate_map + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_update_certificate_map(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_certificate_map + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_update_certificate_map_entry(self, request: certificate_manager.UpdateCertificateMapEntryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.UpdateCertificateMapEntryRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_certificate_map_entry + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_update_certificate_map_entry(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_certificate_map_entry + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_update_dns_authorization(self, request: certificate_manager.UpdateDnsAuthorizationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.UpdateDnsAuthorizationRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_dns_authorization + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_update_dns_authorization(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_dns_authorization + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + + def pre_get_location(self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]]) -> locations_pb2.Location: + """Pre-rpc interceptor for get_location + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_get_location(self, response: locations_pb2.GetLocationRequest) -> locations_pb2.Location: + """Post-rpc interceptor for get_location + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_list_locations(self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]]) -> locations_pb2.ListLocationsResponse: + """Pre-rpc interceptor for list_locations + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_list_locations(self, response: locations_pb2.ListLocationsRequest) -> locations_pb2.ListLocationsResponse: + """Post-rpc interceptor for list_locations + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_cancel_operation(self, request: operations_pb2.CancelOperationRequest, metadata: Sequence[Tuple[str, str]]) -> None: + """Pre-rpc interceptor for cancel_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_cancel_operation(self, response: operations_pb2.CancelOperationRequest) -> None: + """Post-rpc interceptor for cancel_operation + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_delete_operation(self, request: operations_pb2.DeleteOperationRequest, metadata: Sequence[Tuple[str, str]]) -> None: + """Pre-rpc interceptor for delete_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_delete_operation(self, response: operations_pb2.DeleteOperationRequest) -> None: + """Post-rpc interceptor for delete_operation + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_get_operation(self, request: operations_pb2.GetOperationRequest, metadata: Sequence[Tuple[str, str]]) -> operations_pb2.Operation: + """Pre-rpc interceptor for get_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_get_operation(self, response: operations_pb2.GetOperationRequest) -> operations_pb2.Operation: + """Post-rpc interceptor for get_operation + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + def pre_list_operations(self, request: operations_pb2.ListOperationsRequest, metadata: Sequence[Tuple[str, str]]) -> operations_pb2.ListOperationsResponse: + """Pre-rpc interceptor for list_operations + + Override in a subclass to manipulate the request or metadata + before they are sent to the CertificateManager server. + """ + return request, metadata + + def post_list_operations(self, response: operations_pb2.ListOperationsRequest) -> operations_pb2.ListOperationsResponse: + """Post-rpc interceptor for list_operations + + Override in a subclass to manipulate the response + after it is returned by the CertificateManager server but before + it is returned to user code. + """ + return response + + +@dataclasses.dataclass +class CertificateManagerRestStub: + _session: AuthorizedSession + _host: str + _interceptor: CertificateManagerRestInterceptor + + +class CertificateManagerRestTransport(CertificateManagerTransport): + """REST backend transport for CertificateManager. + + API Overview + + Certificates Manager API allows customers to see and manage all + their TLS certificates. + + Certificates Manager API service provides methods to manage + certificates, group them into collections, and create serving + configuration that can be easily applied to other Cloud resources + e.g. Target Proxies. + + Data Model + + The Certificates Manager service exposes the following resources: + + - ``Certificate`` that describes a single TLS certificate. + - ``CertificateMap`` that describes a collection of certificates + that can be attached to a target resource. + - ``CertificateMapEntry`` that describes a single configuration + entry that consists of a SNI and a group of certificates. It's a + subresource of CertificateMap. + + Certificate, CertificateMap and CertificateMapEntry IDs have to + fully match the regexp ``[a-z0-9-]{1,63}``. In other words, + + - only lower case letters, digits, and hyphen are allowed + - length of the resource ID has to be in [1,63] range. + + Provides methods to manage Cloud Certificate Manager entities. + + 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 JSON representations of protocol buffers over HTTP/1.1 + + """ + + def __init__(self, *, + host: str = 'certificatemanager.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + client_cert_source_for_mtls: Optional[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, + url_scheme: str = 'https', + interceptor: Optional[CertificateManagerRestInterceptor] = None, + api_audience: Optional[str] = None, + ) -> 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 ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client + certificate to configure mutual TLS HTTP channel. It is ignored + if ``channel`` 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 are developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + url_scheme: the protocol scheme for the API endpoint. Normally + "https", but for testing or local servers, + "http" can be specified. + """ + # Run the base constructor + # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. + # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the + # credentials object + maybe_url_match = re.match("^(?Phttp(?:s)?://)?(?P.*)$", host) + if maybe_url_match is None: + raise ValueError(f"Unexpected hostname structure: {host}") # pragma: NO COVER + + url_match_items = maybe_url_match.groupdict() + + host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host + + super().__init__( + host=host, + credentials=credentials, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience + ) + self._session = AuthorizedSession( + self._credentials, default_host=self.DEFAULT_HOST) + self._operations_client: Optional[operations_v1.AbstractOperationsClient] = None + if client_cert_source_for_mtls: + self._session.configure_mtls_channel(client_cert_source_for_mtls) + self._interceptor = interceptor or CertificateManagerRestInterceptor() + self._prep_wrapped_messages(client_info) + + @property + def operations_client(self) -> operations_v1.AbstractOperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Only create a new client if we do not already have one. + if self._operations_client is None: + http_options: Dict[str, List[Dict[str, str]]] = { + 'google.longrunning.Operations.CancelOperation': [ + { + 'method': 'post', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', + 'body': '*', + }, + ], + 'google.longrunning.Operations.DeleteOperation': [ + { + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + }, + ], + 'google.longrunning.Operations.GetOperation': [ + { + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + }, + ], + 'google.longrunning.Operations.ListOperations': [ + { + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*}/operations', + }, + ], + } + + rest_transport = operations_v1.OperationsRestTransport( + host=self._host, + # use the credentials which are saved + credentials=self._credentials, + scopes=self._scopes, + http_options=http_options, + path_prefix="v1") + + self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) + + # Return the client from cache. + return self._operations_client + + class _CreateCertificate(CertificateManagerRestStub): + def __hash__(self): + return hash("CreateCertificate") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "certificateId" : "", } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.CreateCertificateRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the create certificate method over HTTP. + + Args: + request (~.certificate_manager.CreateCertificateRequest): + The request object. Request for the ``CreateCertificate`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/certificates', + 'body': 'certificate', + }, + ] + request, metadata = self._interceptor.pre_create_certificate(request, metadata) + pb_request = certificate_manager.CreateCertificateRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_certificate(resp) + return resp + + class _CreateCertificateIssuanceConfig(CertificateManagerRestStub): + def __hash__(self): + return hash("CreateCertificateIssuanceConfig") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "certificateIssuanceConfigId" : "", } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the create certificate + issuance config method over HTTP. + + Args: + request (~.gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest): + The request object. Request for the ``CreateCertificateIssuanceConfig`` + 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/certificateIssuanceConfigs', + 'body': 'certificate_issuance_config', + }, + ] + request, metadata = self._interceptor.pre_create_certificate_issuance_config(request, metadata) + pb_request = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_certificate_issuance_config(resp) + return resp + + class _CreateCertificateMap(CertificateManagerRestStub): + def __hash__(self): + return hash("CreateCertificateMap") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "certificateMapId" : "", } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.CreateCertificateMapRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the create certificate map method over HTTP. + + Args: + request (~.certificate_manager.CreateCertificateMapRequest): + The request object. Request for the ``CreateCertificateMap`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/certificateMaps', + 'body': 'certificate_map', + }, + ] + request, metadata = self._interceptor.pre_create_certificate_map(request, metadata) + pb_request = certificate_manager.CreateCertificateMapRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_certificate_map(resp) + return resp + + class _CreateCertificateMapEntry(CertificateManagerRestStub): + def __hash__(self): + return hash("CreateCertificateMapEntry") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "certificateMapEntryId" : "", } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.CreateCertificateMapEntryRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the create certificate map + entry method over HTTP. + + Args: + request (~.certificate_manager.CreateCertificateMapEntryRequest): + The request object. Request for the ``CreateCertificateMapEntry`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*/certificateMaps/*}/certificateMapEntries', + 'body': 'certificate_map_entry', + }, + ] + request, metadata = self._interceptor.pre_create_certificate_map_entry(request, metadata) + pb_request = certificate_manager.CreateCertificateMapEntryRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_certificate_map_entry(resp) + return resp + + class _CreateDnsAuthorization(CertificateManagerRestStub): + def __hash__(self): + return hash("CreateDnsAuthorization") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "dnsAuthorizationId" : "", } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.CreateDnsAuthorizationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the create dns authorization method over HTTP. + + Args: + request (~.certificate_manager.CreateDnsAuthorizationRequest): + The request object. Request for the ``CreateDnsAuthorization`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/dnsAuthorizations', + 'body': 'dns_authorization', + }, + ] + request, metadata = self._interceptor.pre_create_dns_authorization(request, metadata) + pb_request = certificate_manager.CreateDnsAuthorizationRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_dns_authorization(resp) + return resp + + class _DeleteCertificate(CertificateManagerRestStub): + def __hash__(self): + return hash("DeleteCertificate") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.DeleteCertificateRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete certificate method over HTTP. + + Args: + request (~.certificate_manager.DeleteCertificateRequest): + The request object. Request for the ``DeleteCertificate`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/certificates/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_certificate(request, metadata) + pb_request = certificate_manager.DeleteCertificateRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_certificate(resp) + return resp + + class _DeleteCertificateIssuanceConfig(CertificateManagerRestStub): + def __hash__(self): + return hash("DeleteCertificateIssuanceConfig") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete certificate + issuance config method over HTTP. + + Args: + request (~.certificate_issuance_config.DeleteCertificateIssuanceConfigRequest): + The request object. Request for the ``DeleteCertificateIssuanceConfig`` + 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/certificateIssuanceConfigs/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_certificate_issuance_config(request, metadata) + pb_request = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_certificate_issuance_config(resp) + return resp + + class _DeleteCertificateMap(CertificateManagerRestStub): + def __hash__(self): + return hash("DeleteCertificateMap") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.DeleteCertificateMapRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete certificate map method over HTTP. + + Args: + request (~.certificate_manager.DeleteCertificateMapRequest): + The request object. Request for the ``DeleteCertificateMap`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/certificateMaps/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_certificate_map(request, metadata) + pb_request = certificate_manager.DeleteCertificateMapRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_certificate_map(resp) + return resp + + class _DeleteCertificateMapEntry(CertificateManagerRestStub): + def __hash__(self): + return hash("DeleteCertificateMapEntry") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.DeleteCertificateMapEntryRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete certificate map + entry method over HTTP. + + Args: + request (~.certificate_manager.DeleteCertificateMapEntryRequest): + The request object. Request for the ``DeleteCertificateMapEntry`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_certificate_map_entry(request, metadata) + pb_request = certificate_manager.DeleteCertificateMapEntryRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_certificate_map_entry(resp) + return resp + + class _DeleteDnsAuthorization(CertificateManagerRestStub): + def __hash__(self): + return hash("DeleteDnsAuthorization") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.DeleteDnsAuthorizationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete dns authorization method over HTTP. + + Args: + request (~.certificate_manager.DeleteDnsAuthorizationRequest): + The request object. Request for the ``DeleteDnsAuthorization`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/dnsAuthorizations/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_dns_authorization(request, metadata) + pb_request = certificate_manager.DeleteDnsAuthorizationRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_dns_authorization(resp) + return resp + + class _GetCertificate(CertificateManagerRestStub): + def __hash__(self): + return hash("GetCertificate") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.GetCertificateRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> certificate_manager.Certificate: + r"""Call the get certificate method over HTTP. + + Args: + request (~.certificate_manager.GetCertificateRequest): + The request object. Request for the ``GetCertificate`` 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: + ~.certificate_manager.Certificate: + Defines TLS certificate. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/certificates/*}', + }, + ] + request, metadata = self._interceptor.pre_get_certificate(request, metadata) + pb_request = certificate_manager.GetCertificateRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = certificate_manager.Certificate() + pb_resp = certificate_manager.Certificate.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate(resp) + return resp + + class _GetCertificateIssuanceConfig(CertificateManagerRestStub): + def __hash__(self): + return hash("GetCertificateIssuanceConfig") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_issuance_config.GetCertificateIssuanceConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> certificate_issuance_config.CertificateIssuanceConfig: + r"""Call the get certificate issuance + config method over HTTP. + + Args: + request (~.certificate_issuance_config.GetCertificateIssuanceConfigRequest): + The request object. Request for the ``GetCertificateIssuanceConfig`` 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: + ~.certificate_issuance_config.CertificateIssuanceConfig: + CertificateIssuanceConfig specifies + how to issue and manage a certificate. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/certificateIssuanceConfigs/*}', + }, + ] + request, metadata = self._interceptor.pre_get_certificate_issuance_config(request, metadata) + pb_request = certificate_issuance_config.GetCertificateIssuanceConfigRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = certificate_issuance_config.CertificateIssuanceConfig() + pb_resp = certificate_issuance_config.CertificateIssuanceConfig.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate_issuance_config(resp) + return resp + + class _GetCertificateMap(CertificateManagerRestStub): + def __hash__(self): + return hash("GetCertificateMap") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.GetCertificateMapRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> certificate_manager.CertificateMap: + r"""Call the get certificate map method over HTTP. + + Args: + request (~.certificate_manager.GetCertificateMapRequest): + The request object. Request for the ``GetCertificateMap`` 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: + ~.certificate_manager.CertificateMap: + Defines a collection of certificate + configurations. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/certificateMaps/*}', + }, + ] + request, metadata = self._interceptor.pre_get_certificate_map(request, metadata) + pb_request = certificate_manager.GetCertificateMapRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = certificate_manager.CertificateMap() + pb_resp = certificate_manager.CertificateMap.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate_map(resp) + return resp + + class _GetCertificateMapEntry(CertificateManagerRestStub): + def __hash__(self): + return hash("GetCertificateMapEntry") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.GetCertificateMapEntryRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> certificate_manager.CertificateMapEntry: + r"""Call the get certificate map entry method over HTTP. + + Args: + request (~.certificate_manager.GetCertificateMapEntryRequest): + The request object. Request for the ``GetCertificateMapEntry`` 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: + ~.certificate_manager.CertificateMapEntry: + Defines a certificate map entry. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}', + }, + ] + request, metadata = self._interceptor.pre_get_certificate_map_entry(request, metadata) + pb_request = certificate_manager.GetCertificateMapEntryRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = certificate_manager.CertificateMapEntry() + pb_resp = certificate_manager.CertificateMapEntry.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate_map_entry(resp) + return resp + + class _GetDnsAuthorization(CertificateManagerRestStub): + def __hash__(self): + return hash("GetDnsAuthorization") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.GetDnsAuthorizationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> certificate_manager.DnsAuthorization: + r"""Call the get dns authorization method over HTTP. + + Args: + request (~.certificate_manager.GetDnsAuthorizationRequest): + The request object. Request for the ``GetDnsAuthorization`` 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: + ~.certificate_manager.DnsAuthorization: + A DnsAuthorization resource describes + a way to perform domain authorization + for certificate issuance. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/dnsAuthorizations/*}', + }, + ] + request, metadata = self._interceptor.pre_get_dns_authorization(request, metadata) + pb_request = certificate_manager.GetDnsAuthorizationRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = certificate_manager.DnsAuthorization() + pb_resp = certificate_manager.DnsAuthorization.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_dns_authorization(resp) + return resp + + class _ListCertificateIssuanceConfigs(CertificateManagerRestStub): + def __hash__(self): + return hash("ListCertificateIssuanceConfigs") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_issuance_config.ListCertificateIssuanceConfigsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> certificate_issuance_config.ListCertificateIssuanceConfigsResponse: + r"""Call the list certificate issuance + configs method over HTTP. + + Args: + request (~.certificate_issuance_config.ListCertificateIssuanceConfigsRequest): + The request object. Request for the ``ListCertificateIssuanceConfigs`` + 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: + ~.certificate_issuance_config.ListCertificateIssuanceConfigsResponse: + Response for the ``ListCertificateIssuanceConfigs`` + method. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/certificateIssuanceConfigs', + }, + ] + request, metadata = self._interceptor.pre_list_certificate_issuance_configs(request, metadata) + pb_request = certificate_issuance_config.ListCertificateIssuanceConfigsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() + pb_resp = certificate_issuance_config.ListCertificateIssuanceConfigsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificate_issuance_configs(resp) + return resp + + class _ListCertificateMapEntries(CertificateManagerRestStub): + def __hash__(self): + return hash("ListCertificateMapEntries") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.ListCertificateMapEntriesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> certificate_manager.ListCertificateMapEntriesResponse: + r"""Call the list certificate map + entries method over HTTP. + + Args: + request (~.certificate_manager.ListCertificateMapEntriesRequest): + The request object. Request for the ``ListCertificateMapEntries`` 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: + ~.certificate_manager.ListCertificateMapEntriesResponse: + Response for the ``ListCertificateMapEntries`` method. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*/certificateMaps/*}/certificateMapEntries', + }, + ] + request, metadata = self._interceptor.pre_list_certificate_map_entries(request, metadata) + pb_request = certificate_manager.ListCertificateMapEntriesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = certificate_manager.ListCertificateMapEntriesResponse() + pb_resp = certificate_manager.ListCertificateMapEntriesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificate_map_entries(resp) + return resp + + class _ListCertificateMaps(CertificateManagerRestStub): + def __hash__(self): + return hash("ListCertificateMaps") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.ListCertificateMapsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> certificate_manager.ListCertificateMapsResponse: + r"""Call the list certificate maps method over HTTP. + + Args: + request (~.certificate_manager.ListCertificateMapsRequest): + The request object. Request for the ``ListCertificateMaps`` 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: + ~.certificate_manager.ListCertificateMapsResponse: + Response for the ``ListCertificateMaps`` method. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/certificateMaps', + }, + ] + request, metadata = self._interceptor.pre_list_certificate_maps(request, metadata) + pb_request = certificate_manager.ListCertificateMapsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = certificate_manager.ListCertificateMapsResponse() + pb_resp = certificate_manager.ListCertificateMapsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificate_maps(resp) + return resp + + class _ListCertificates(CertificateManagerRestStub): + def __hash__(self): + return hash("ListCertificates") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.ListCertificatesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> certificate_manager.ListCertificatesResponse: + r"""Call the list certificates method over HTTP. + + Args: + request (~.certificate_manager.ListCertificatesRequest): + The request object. Request for the ``ListCertificates`` 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: + ~.certificate_manager.ListCertificatesResponse: + Response for the ``ListCertificates`` method. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/certificates', + }, + ] + request, metadata = self._interceptor.pre_list_certificates(request, metadata) + pb_request = certificate_manager.ListCertificatesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = certificate_manager.ListCertificatesResponse() + pb_resp = certificate_manager.ListCertificatesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificates(resp) + return resp + + class _ListDnsAuthorizations(CertificateManagerRestStub): + def __hash__(self): + return hash("ListDnsAuthorizations") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.ListDnsAuthorizationsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> certificate_manager.ListDnsAuthorizationsResponse: + r"""Call the list dns authorizations method over HTTP. + + Args: + request (~.certificate_manager.ListDnsAuthorizationsRequest): + The request object. Request for the ``ListDnsAuthorizations`` 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: + ~.certificate_manager.ListDnsAuthorizationsResponse: + Response for the ``ListDnsAuthorizations`` method. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/dnsAuthorizations', + }, + ] + request, metadata = self._interceptor.pre_list_dns_authorizations(request, metadata) + pb_request = certificate_manager.ListDnsAuthorizationsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = certificate_manager.ListDnsAuthorizationsResponse() + pb_resp = certificate_manager.ListDnsAuthorizationsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_dns_authorizations(resp) + return resp + + class _UpdateCertificate(CertificateManagerRestStub): + def __hash__(self): + return hash("UpdateCertificate") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "updateMask" : {}, } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.UpdateCertificateRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the update certificate method over HTTP. + + Args: + request (~.certificate_manager.UpdateCertificateRequest): + The request object. Request for the ``UpdateCertificate`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{certificate.name=projects/*/locations/*/certificates/*}', + 'body': 'certificate', + }, + ] + request, metadata = self._interceptor.pre_update_certificate(request, metadata) + pb_request = certificate_manager.UpdateCertificateRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_certificate(resp) + return resp + + class _UpdateCertificateMap(CertificateManagerRestStub): + def __hash__(self): + return hash("UpdateCertificateMap") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "updateMask" : {}, } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.UpdateCertificateMapRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the update certificate map method over HTTP. + + Args: + request (~.certificate_manager.UpdateCertificateMapRequest): + The request object. Request for the ``UpdateCertificateMap`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{certificate_map.name=projects/*/locations/*/certificateMaps/*}', + 'body': 'certificate_map', + }, + ] + request, metadata = self._interceptor.pre_update_certificate_map(request, metadata) + pb_request = certificate_manager.UpdateCertificateMapRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_certificate_map(resp) + return resp + + class _UpdateCertificateMapEntry(CertificateManagerRestStub): + def __hash__(self): + return hash("UpdateCertificateMapEntry") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "updateMask" : {}, } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.UpdateCertificateMapEntryRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the update certificate map + entry method over HTTP. + + Args: + request (~.certificate_manager.UpdateCertificateMapEntryRequest): + The request object. Request for the ``UpdateCertificateMapEntry`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{certificate_map_entry.name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}', + 'body': 'certificate_map_entry', + }, + ] + request, metadata = self._interceptor.pre_update_certificate_map_entry(request, metadata) + pb_request = certificate_manager.UpdateCertificateMapEntryRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_certificate_map_entry(resp) + return resp + + class _UpdateDnsAuthorization(CertificateManagerRestStub): + def __hash__(self): + return hash("UpdateDnsAuthorization") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "updateMask" : {}, } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: certificate_manager.UpdateDnsAuthorizationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the update dns authorization method over HTTP. + + Args: + request (~.certificate_manager.UpdateDnsAuthorizationRequest): + The request object. Request for the ``UpdateDnsAuthorization`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{dns_authorization.name=projects/*/locations/*/dnsAuthorizations/*}', + 'body': 'dns_authorization', + }, + ] + request, metadata = self._interceptor.pre_update_dns_authorization(request, metadata) + pb_request = certificate_manager.UpdateDnsAuthorizationRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_dns_authorization(resp) + return resp + + @property + def create_certificate(self) -> Callable[ + [certificate_manager.CreateCertificateRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateCertificate(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_certificate_issuance_config(self) -> Callable[ + [gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateCertificateIssuanceConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_certificate_map(self) -> Callable[ + [certificate_manager.CreateCertificateMapRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateCertificateMap(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_certificate_map_entry(self) -> Callable[ + [certificate_manager.CreateCertificateMapEntryRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateCertificateMapEntry(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_dns_authorization(self) -> Callable[ + [certificate_manager.CreateDnsAuthorizationRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateDnsAuthorization(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_certificate(self) -> Callable[ + [certificate_manager.DeleteCertificateRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteCertificate(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_certificate_issuance_config(self) -> Callable[ + [certificate_issuance_config.DeleteCertificateIssuanceConfigRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteCertificateIssuanceConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_certificate_map(self) -> Callable[ + [certificate_manager.DeleteCertificateMapRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteCertificateMap(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_certificate_map_entry(self) -> Callable[ + [certificate_manager.DeleteCertificateMapEntryRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteCertificateMapEntry(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_dns_authorization(self) -> Callable[ + [certificate_manager.DeleteDnsAuthorizationRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteDnsAuthorization(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_certificate(self) -> Callable[ + [certificate_manager.GetCertificateRequest], + certificate_manager.Certificate]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetCertificate(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_certificate_issuance_config(self) -> Callable[ + [certificate_issuance_config.GetCertificateIssuanceConfigRequest], + certificate_issuance_config.CertificateIssuanceConfig]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetCertificateIssuanceConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_certificate_map(self) -> Callable[ + [certificate_manager.GetCertificateMapRequest], + certificate_manager.CertificateMap]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetCertificateMap(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_certificate_map_entry(self) -> Callable[ + [certificate_manager.GetCertificateMapEntryRequest], + certificate_manager.CertificateMapEntry]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetCertificateMapEntry(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_dns_authorization(self) -> Callable[ + [certificate_manager.GetDnsAuthorizationRequest], + certificate_manager.DnsAuthorization]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetDnsAuthorization(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_certificate_issuance_configs(self) -> Callable[ + [certificate_issuance_config.ListCertificateIssuanceConfigsRequest], + certificate_issuance_config.ListCertificateIssuanceConfigsResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListCertificateIssuanceConfigs(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_certificate_map_entries(self) -> Callable[ + [certificate_manager.ListCertificateMapEntriesRequest], + certificate_manager.ListCertificateMapEntriesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListCertificateMapEntries(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_certificate_maps(self) -> Callable[ + [certificate_manager.ListCertificateMapsRequest], + certificate_manager.ListCertificateMapsResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListCertificateMaps(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_certificates(self) -> Callable[ + [certificate_manager.ListCertificatesRequest], + certificate_manager.ListCertificatesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListCertificates(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_dns_authorizations(self) -> Callable[ + [certificate_manager.ListDnsAuthorizationsRequest], + certificate_manager.ListDnsAuthorizationsResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListDnsAuthorizations(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_certificate(self) -> Callable[ + [certificate_manager.UpdateCertificateRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateCertificate(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_certificate_map(self) -> Callable[ + [certificate_manager.UpdateCertificateMapRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateCertificateMap(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_certificate_map_entry(self) -> Callable[ + [certificate_manager.UpdateCertificateMapEntryRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateCertificateMapEntry(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_dns_authorization(self) -> Callable[ + [certificate_manager.UpdateDnsAuthorizationRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateDnsAuthorization(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_location(self): + return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore + + class _GetLocation(CertificateManagerRestStub): + def __call__(self, + request: locations_pb2.GetLocationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> locations_pb2.Location: + + r"""Call the get location method over HTTP. + + Args: + request (locations_pb2.GetLocationRequest): + The request object for GetLocation 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: + locations_pb2.Location: Response from GetLocation method. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*}', + }, + ] + + request, metadata = self._interceptor.pre_get_location(request, metadata) + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + resp = locations_pb2.Location() + resp = json_format.Parse(response.content.decode("utf-8"), resp) + resp = self._interceptor.post_get_location(resp) + return resp + + @property + def list_locations(self): + return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore + + class _ListLocations(CertificateManagerRestStub): + def __call__(self, + request: locations_pb2.ListLocationsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> locations_pb2.ListLocationsResponse: + + r"""Call the list locations method over HTTP. + + Args: + request (locations_pb2.ListLocationsRequest): + The request object for ListLocations 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: + locations_pb2.ListLocationsResponse: Response from ListLocations method. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*}/locations', + }, + ] + + request, metadata = self._interceptor.pre_list_locations(request, metadata) + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + resp = locations_pb2.ListLocationsResponse() + resp = json_format.Parse(response.content.decode("utf-8"), resp) + resp = self._interceptor.post_list_locations(resp) + return resp + + @property + def cancel_operation(self): + return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore + + class _CancelOperation(CertificateManagerRestStub): + def __call__(self, + request: operations_pb2.CancelOperationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> None: + + r"""Call the cancel operation method over HTTP. + + Args: + request (operations_pb2.CancelOperationRequest): + The request object for CancelOperation 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. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', + 'body': '*', + }, + ] + + request, metadata = self._interceptor.pre_cancel_operation(request, metadata) + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + + body = json.loads(json.dumps(transcoded_request['body'])) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + return self._interceptor.post_cancel_operation(None) + + @property + def delete_operation(self): + return self._DeleteOperation(self._session, self._host, self._interceptor) # type: ignore + + class _DeleteOperation(CertificateManagerRestStub): + def __call__(self, + request: operations_pb2.DeleteOperationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> None: + + r"""Call the delete operation method over HTTP. + + Args: + request (operations_pb2.DeleteOperationRequest): + The request object for DeleteOperation 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. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + }, + ] + + request, metadata = self._interceptor.pre_delete_operation(request, metadata) + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + return self._interceptor.post_delete_operation(None) + + @property + def get_operation(self): + return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore + + class _GetOperation(CertificateManagerRestStub): + def __call__(self, + request: operations_pb2.GetOperationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + + r"""Call the get operation method over HTTP. + + Args: + request (operations_pb2.GetOperationRequest): + The request object for GetOperation 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: + operations_pb2.Operation: Response from GetOperation method. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + }, + ] + + request, metadata = self._interceptor.pre_get_operation(request, metadata) + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + resp = operations_pb2.Operation() + resp = json_format.Parse(response.content.decode("utf-8"), resp) + resp = self._interceptor.post_get_operation(resp) + return resp + + @property + def list_operations(self): + return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore + + class _ListOperations(CertificateManagerRestStub): + def __call__(self, + request: operations_pb2.ListOperationsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.ListOperationsResponse: + + r"""Call the list operations method over HTTP. + + Args: + request (operations_pb2.ListOperationsRequest): + The request object for ListOperations 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: + operations_pb2.ListOperationsResponse: Response from ListOperations method. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*}/operations', + }, + ] + + request, metadata = self._interceptor.pre_list_operations(request, metadata) + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + resp = operations_pb2.ListOperationsResponse() + resp = json_format.Parse(response.content.decode("utf-8"), resp) + resp = self._interceptor.post_list_operations(resp) + return resp + + @property + def kind(self) -> str: + return "rest" + + def close(self): + self._session.close() + + +__all__=( + 'CertificateManagerRestTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/__init__.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/__init__.py new file mode 100644 index 0000000..5a613a2 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/__init__.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from .certificate_issuance_config import ( + CertificateIssuanceConfig, + CreateCertificateIssuanceConfigRequest, + DeleteCertificateIssuanceConfigRequest, + GetCertificateIssuanceConfigRequest, + ListCertificateIssuanceConfigsRequest, + ListCertificateIssuanceConfigsResponse, +) +from .certificate_manager import ( + Certificate, + CertificateMap, + CertificateMapEntry, + CreateCertificateMapEntryRequest, + CreateCertificateMapRequest, + CreateCertificateRequest, + CreateDnsAuthorizationRequest, + DeleteCertificateMapEntryRequest, + DeleteCertificateMapRequest, + DeleteCertificateRequest, + DeleteDnsAuthorizationRequest, + DnsAuthorization, + GetCertificateMapEntryRequest, + GetCertificateMapRequest, + GetCertificateRequest, + GetDnsAuthorizationRequest, + ListCertificateMapEntriesRequest, + ListCertificateMapEntriesResponse, + ListCertificateMapsRequest, + ListCertificateMapsResponse, + ListCertificatesRequest, + ListCertificatesResponse, + ListDnsAuthorizationsRequest, + ListDnsAuthorizationsResponse, + OperationMetadata, + UpdateCertificateMapEntryRequest, + UpdateCertificateMapRequest, + UpdateCertificateRequest, + UpdateDnsAuthorizationRequest, + ServingState, +) + +__all__ = ( + 'CertificateIssuanceConfig', + 'CreateCertificateIssuanceConfigRequest', + 'DeleteCertificateIssuanceConfigRequest', + 'GetCertificateIssuanceConfigRequest', + 'ListCertificateIssuanceConfigsRequest', + 'ListCertificateIssuanceConfigsResponse', + 'Certificate', + 'CertificateMap', + 'CertificateMapEntry', + 'CreateCertificateMapEntryRequest', + 'CreateCertificateMapRequest', + 'CreateCertificateRequest', + 'CreateDnsAuthorizationRequest', + 'DeleteCertificateMapEntryRequest', + 'DeleteCertificateMapRequest', + 'DeleteCertificateRequest', + 'DeleteDnsAuthorizationRequest', + 'DnsAuthorization', + 'GetCertificateMapEntryRequest', + 'GetCertificateMapRequest', + 'GetCertificateRequest', + 'GetDnsAuthorizationRequest', + 'ListCertificateMapEntriesRequest', + 'ListCertificateMapEntriesResponse', + 'ListCertificateMapsRequest', + 'ListCertificateMapsResponse', + 'ListCertificatesRequest', + 'ListCertificatesResponse', + 'ListDnsAuthorizationsRequest', + 'ListDnsAuthorizationsResponse', + 'OperationMetadata', + 'UpdateCertificateMapEntryRequest', + 'UpdateCertificateMapRequest', + 'UpdateCertificateRequest', + 'UpdateDnsAuthorizationRequest', + 'ServingState', +) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_issuance_config.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_issuance_config.py new file mode 100644 index 0000000..bdec673 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_issuance_config.py @@ -0,0 +1,318 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import MutableMapping, MutableSequence + +import proto # type: ignore + +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.certificatemanager.v1', + manifest={ + 'ListCertificateIssuanceConfigsRequest', + 'ListCertificateIssuanceConfigsResponse', + 'GetCertificateIssuanceConfigRequest', + 'CreateCertificateIssuanceConfigRequest', + 'DeleteCertificateIssuanceConfigRequest', + 'CertificateIssuanceConfig', + }, +) + + +class ListCertificateIssuanceConfigsRequest(proto.Message): + r"""Request for the ``ListCertificateIssuanceConfigs`` method. + + Attributes: + parent (str): + Required. The project and location from which the + certificate should be listed, specified in the format + ``projects/*/locations/*``. + page_size (int): + Maximum number of certificate configs to + return per call. + page_token (str): + The value returned by the last + ``ListCertificateIssuanceConfigsResponse``. Indicates that + this is a continuation of a prior + ``ListCertificateIssuanceConfigs`` call, and that the system + should return the next page of data. + filter (str): + Filter expression to restrict the + Certificates Configs returned. + order_by (str): + A list of Certificate Config field names used + to specify the order of the returned results. + The default sorting order is ascending. To + specify descending order for a field, add a + suffix " desc". + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCertificateIssuanceConfigsResponse(proto.Message): + r"""Response for the ``ListCertificateIssuanceConfigs`` method. + + Attributes: + certificate_issuance_configs (MutableSequence[google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig]): + A list of certificate configs for the parent + resource. + next_page_token (str): + If there might be more results than those appearing in this + response, then ``next_page_token`` is included. To get the + next set of results, call this method again using the value + of ``next_page_token`` as ``page_token``. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + certificate_issuance_configs: MutableSequence['CertificateIssuanceConfig'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='CertificateIssuanceConfig', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetCertificateIssuanceConfigRequest(proto.Message): + r"""Request for the ``GetCertificateIssuanceConfig`` method. + + Attributes: + name (str): + Required. A name of the certificate issuance config to + describe. Must be in the format + ``projects/*/locations/*/certificateIssuanceConfigs/*``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateCertificateIssuanceConfigRequest(proto.Message): + r"""Request for the ``CreateCertificateIssuanceConfig`` method. + + Attributes: + parent (str): + Required. The parent resource of the certificate issuance + config. Must be in the format ``projects/*/locations/*``. + certificate_issuance_config_id (str): + Required. A user-provided name of the + certificate config. + certificate_issuance_config (google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig): + Required. A definition of the certificate + issuance config to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + certificate_issuance_config_id: str = proto.Field( + proto.STRING, + number=2, + ) + certificate_issuance_config: 'CertificateIssuanceConfig' = proto.Field( + proto.MESSAGE, + number=3, + message='CertificateIssuanceConfig', + ) + + +class DeleteCertificateIssuanceConfigRequest(proto.Message): + r"""Request for the ``DeleteCertificateIssuanceConfig`` method. + + Attributes: + name (str): + Required. A name of the certificate issuance config to + delete. Must be in the format + ``projects/*/locations/*/certificateIssuanceConfigs/*``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CertificateIssuanceConfig(proto.Message): + r"""CertificateIssuanceConfig specifies how to issue and manage a + certificate. + + Attributes: + name (str): + A user-defined name of the certificate issuance config. + CertificateIssuanceConfig names must be unique globally and + match pattern + ``projects/*/locations/*/certificateIssuanceConfigs/*``. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The creation timestamp of a + CertificateIssuanceConfig. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The last update timestamp of a + CertificateIssuanceConfig. + labels (MutableMapping[str, str]): + Set of labels associated with a + CertificateIssuanceConfig. + description (str): + One or more paragraphs of text description of + a CertificateIssuanceConfig. + certificate_authority_config (google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig.CertificateAuthorityConfig): + Required. The CA that issues the workload + certificate. It includes the CA address, type, + authentication to CA service, etc. + lifetime (google.protobuf.duration_pb2.Duration): + Required. Workload certificate lifetime + requested. + rotation_window_percentage (int): + Required. Specifies the percentage of elapsed + time of the certificate lifetime to wait before + renewing the certificate. Must be a number + between 1-99, inclusive. + key_algorithm (google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig.KeyAlgorithm): + Required. The key algorithm to use when + generating the private key. + """ + class KeyAlgorithm(proto.Enum): + r"""The type of keypair to generate. + + Values: + KEY_ALGORITHM_UNSPECIFIED (0): + Unspecified key algorithm. + RSA_2048 (1): + Specifies RSA with a 2048-bit modulus. + ECDSA_P256 (4): + Specifies ECDSA with curve P256. + """ + KEY_ALGORITHM_UNSPECIFIED = 0 + RSA_2048 = 1 + ECDSA_P256 = 4 + + class CertificateAuthorityConfig(proto.Message): + r"""The CA that issues the workload certificate. It includes CA + address, type, authentication to CA service, etc. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + certificate_authority_service_config (google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig.CertificateAuthorityConfig.CertificateAuthorityServiceConfig): + Defines a CertificateAuthorityServiceConfig. + + This field is a member of `oneof`_ ``kind``. + """ + + class CertificateAuthorityServiceConfig(proto.Message): + r"""Contains information required to contact CA service. + + Attributes: + ca_pool (str): + Required. A CA pool resource used to issue a certificate. + The CA pool string has a relative resource path following + the form + "projects/{project}/locations/{location}/caPools/{ca_pool}". + """ + + ca_pool: str = proto.Field( + proto.STRING, + number=1, + ) + + certificate_authority_service_config: 'CertificateIssuanceConfig.CertificateAuthorityConfig.CertificateAuthorityServiceConfig' = proto.Field( + proto.MESSAGE, + number=1, + oneof='kind', + message='CertificateIssuanceConfig.CertificateAuthorityConfig.CertificateAuthorityServiceConfig', + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + description: str = proto.Field( + proto.STRING, + number=5, + ) + certificate_authority_config: CertificateAuthorityConfig = proto.Field( + proto.MESSAGE, + number=6, + message=CertificateAuthorityConfig, + ) + lifetime: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=7, + message=duration_pb2.Duration, + ) + rotation_window_percentage: int = proto.Field( + proto.INT32, + number=8, + ) + key_algorithm: KeyAlgorithm = proto.Field( + proto.ENUM, + number=9, + enum=KeyAlgorithm, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_manager.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_manager.py new file mode 100644 index 0000000..f03dd6f --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_manager.py @@ -0,0 +1,1514 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import MutableMapping, MutableSequence + +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.certificatemanager.v1', + manifest={ + 'ServingState', + 'ListCertificatesRequest', + 'ListCertificatesResponse', + 'GetCertificateRequest', + 'CreateCertificateRequest', + 'UpdateCertificateRequest', + 'DeleteCertificateRequest', + 'ListCertificateMapsRequest', + 'ListCertificateMapsResponse', + 'GetCertificateMapRequest', + 'CreateCertificateMapRequest', + 'UpdateCertificateMapRequest', + 'DeleteCertificateMapRequest', + 'ListCertificateMapEntriesRequest', + 'ListCertificateMapEntriesResponse', + 'GetCertificateMapEntryRequest', + 'CreateCertificateMapEntryRequest', + 'UpdateCertificateMapEntryRequest', + 'DeleteCertificateMapEntryRequest', + 'ListDnsAuthorizationsRequest', + 'ListDnsAuthorizationsResponse', + 'GetDnsAuthorizationRequest', + 'CreateDnsAuthorizationRequest', + 'UpdateDnsAuthorizationRequest', + 'DeleteDnsAuthorizationRequest', + 'OperationMetadata', + 'Certificate', + 'CertificateMap', + 'CertificateMapEntry', + 'DnsAuthorization', + }, +) + + +class ServingState(proto.Enum): + r"""Defines set of serving states associated with a resource. + + Values: + SERVING_STATE_UNSPECIFIED (0): + The status is undefined. + ACTIVE (1): + The configuration is serving. + PENDING (2): + Update is in progress. Some frontends may + serve this configuration. + """ + SERVING_STATE_UNSPECIFIED = 0 + ACTIVE = 1 + PENDING = 2 + + +class ListCertificatesRequest(proto.Message): + r"""Request for the ``ListCertificates`` method. + + Attributes: + parent (str): + Required. The project and location from which the + certificate should be listed, specified in the format + ``projects/*/locations/*``. + page_size (int): + Maximum number of certificates to return per + call. + page_token (str): + The value returned by the last ``ListCertificatesResponse``. + Indicates that this is a continuation of a prior + ``ListCertificates`` call, and that the system should return + the next page of data. + filter (str): + Filter expression to restrict the + Certificates returned. + order_by (str): + A list of Certificate field names used to + specify the order of the returned results. The + default sorting order is ascending. To specify + descending order for a field, add a suffix " + desc". + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCertificatesResponse(proto.Message): + r"""Response for the ``ListCertificates`` method. + + Attributes: + certificates (MutableSequence[google.cloud.certificate_manager_v1.types.Certificate]): + A list of certificates for the parent + resource. + next_page_token (str): + If there might be more results than those appearing in this + response, then ``next_page_token`` is included. To get the + next set of results, call this method again using the value + of ``next_page_token`` as ``page_token``. + unreachable (MutableSequence[str]): + A list of locations that could not be + reached. + """ + + @property + def raw_page(self): + return self + + certificates: MutableSequence['Certificate'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='Certificate', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetCertificateRequest(proto.Message): + r"""Request for the ``GetCertificate`` method. + + Attributes: + name (str): + Required. A name of the certificate to describe. Must be in + the format ``projects/*/locations/*/certificates/*``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateCertificateRequest(proto.Message): + r"""Request for the ``CreateCertificate`` method. + + Attributes: + parent (str): + Required. The parent resource of the certificate. Must be in + the format ``projects/*/locations/*``. + certificate_id (str): + Required. A user-provided name of the + certificate. + certificate (google.cloud.certificate_manager_v1.types.Certificate): + Required. A definition of the certificate to + create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + certificate_id: str = proto.Field( + proto.STRING, + number=2, + ) + certificate: 'Certificate' = proto.Field( + proto.MESSAGE, + number=3, + message='Certificate', + ) + + +class UpdateCertificateRequest(proto.Message): + r"""Request for the ``UpdateCertificate`` method. + + Attributes: + certificate (google.cloud.certificate_manager_v1.types.Certificate): + Required. A definition of the certificate to + update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + """ + + certificate: 'Certificate' = proto.Field( + proto.MESSAGE, + number=1, + message='Certificate', + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteCertificateRequest(proto.Message): + r"""Request for the ``DeleteCertificate`` method. + + Attributes: + name (str): + Required. A name of the certificate to delete. Must be in + the format ``projects/*/locations/*/certificates/*``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListCertificateMapsRequest(proto.Message): + r"""Request for the ``ListCertificateMaps`` method. + + Attributes: + parent (str): + Required. The project and location from which the + certificate maps should be listed, specified in the format + ``projects/*/locations/*``. + page_size (int): + Maximum number of certificate maps to return + per call. + page_token (str): + The value returned by the last + ``ListCertificateMapsResponse``. Indicates that this is a + continuation of a prior ``ListCertificateMaps`` call, and + that the system should return the next page of data. + filter (str): + Filter expression to restrict the + Certificates Maps returned. + order_by (str): + A list of Certificate Map field names used to + specify the order of the returned results. The + default sorting order is ascending. To specify + descending order for a field, add a suffix " + desc". + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCertificateMapsResponse(proto.Message): + r"""Response for the ``ListCertificateMaps`` method. + + Attributes: + certificate_maps (MutableSequence[google.cloud.certificate_manager_v1.types.CertificateMap]): + A list of certificate maps for the parent + resource. + next_page_token (str): + If there might be more results than those appearing in this + response, then ``next_page_token`` is included. To get the + next set of results, call this method again using the value + of ``next_page_token`` as ``page_token``. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + certificate_maps: MutableSequence['CertificateMap'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='CertificateMap', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetCertificateMapRequest(proto.Message): + r"""Request for the ``GetCertificateMap`` method. + + Attributes: + name (str): + Required. A name of the certificate map to describe. Must be + in the format ``projects/*/locations/*/certificateMaps/*``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateCertificateMapRequest(proto.Message): + r"""Request for the ``CreateCertificateMap`` method. + + Attributes: + parent (str): + Required. The parent resource of the certificate map. Must + be in the format ``projects/*/locations/*``. + certificate_map_id (str): + Required. A user-provided name of the + certificate map. + certificate_map (google.cloud.certificate_manager_v1.types.CertificateMap): + Required. A definition of the certificate map + to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + certificate_map_id: str = proto.Field( + proto.STRING, + number=2, + ) + certificate_map: 'CertificateMap' = proto.Field( + proto.MESSAGE, + number=3, + message='CertificateMap', + ) + + +class UpdateCertificateMapRequest(proto.Message): + r"""Request for the ``UpdateCertificateMap`` method. + + Attributes: + certificate_map (google.cloud.certificate_manager_v1.types.CertificateMap): + Required. A definition of the certificate map + to update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + """ + + certificate_map: 'CertificateMap' = proto.Field( + proto.MESSAGE, + number=1, + message='CertificateMap', + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteCertificateMapRequest(proto.Message): + r"""Request for the ``DeleteCertificateMap`` method. + + Attributes: + name (str): + Required. A name of the certificate map to delete. Must be + in the format ``projects/*/locations/*/certificateMaps/*``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListCertificateMapEntriesRequest(proto.Message): + r"""Request for the ``ListCertificateMapEntries`` method. + + Attributes: + parent (str): + Required. The project, location and certificate map from + which the certificate map entries should be listed, + specified in the format + ``projects/*/locations/*/certificateMaps/*``. + page_size (int): + Maximum number of certificate map entries to + return. The service may return fewer than this + value. If unspecified, at most 50 certificate + map entries will be returned. The maximum value + is 1000; values above 1000 will be coerced to + 1000. + page_token (str): + The value returned by the last + ``ListCertificateMapEntriesResponse``. Indicates that this + is a continuation of a prior ``ListCertificateMapEntries`` + call, and that the system should return the next page of + data. + filter (str): + Filter expression to restrict the returned + Certificate Map Entries. + order_by (str): + A list of Certificate Map Entry field names + used to specify the order of the returned + results. The default sorting order is ascending. + To specify descending order for a field, add a + suffix " desc". + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCertificateMapEntriesResponse(proto.Message): + r"""Response for the ``ListCertificateMapEntries`` method. + + Attributes: + certificate_map_entries (MutableSequence[google.cloud.certificate_manager_v1.types.CertificateMapEntry]): + A list of certificate map entries for the + parent resource. + next_page_token (str): + If there might be more results than those appearing in this + response, then ``next_page_token`` is included. To get the + next set of results, call this method again using the value + of ``next_page_token`` as ``page_token``. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + certificate_map_entries: MutableSequence['CertificateMapEntry'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='CertificateMapEntry', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetCertificateMapEntryRequest(proto.Message): + r"""Request for the ``GetCertificateMapEntry`` method. + + Attributes: + name (str): + Required. A name of the certificate map entry to describe. + Must be in the format + ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateCertificateMapEntryRequest(proto.Message): + r"""Request for the ``CreateCertificateMapEntry`` method. + + Attributes: + parent (str): + Required. The parent resource of the certificate map entry. + Must be in the format + ``projects/*/locations/*/certificateMaps/*``. + certificate_map_entry_id (str): + Required. A user-provided name of the + certificate map entry. + certificate_map_entry (google.cloud.certificate_manager_v1.types.CertificateMapEntry): + Required. A definition of the certificate map + entry to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + certificate_map_entry_id: str = proto.Field( + proto.STRING, + number=2, + ) + certificate_map_entry: 'CertificateMapEntry' = proto.Field( + proto.MESSAGE, + number=3, + message='CertificateMapEntry', + ) + + +class UpdateCertificateMapEntryRequest(proto.Message): + r"""Request for the ``UpdateCertificateMapEntry`` method. + + Attributes: + certificate_map_entry (google.cloud.certificate_manager_v1.types.CertificateMapEntry): + Required. A definition of the certificate map + entry to create map entry. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + """ + + certificate_map_entry: 'CertificateMapEntry' = proto.Field( + proto.MESSAGE, + number=1, + message='CertificateMapEntry', + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteCertificateMapEntryRequest(proto.Message): + r"""Request for the ``DeleteCertificateMapEntry`` method. + + Attributes: + name (str): + Required. A name of the certificate map entry to delete. + Must be in the format + ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListDnsAuthorizationsRequest(proto.Message): + r"""Request for the ``ListDnsAuthorizations`` method. + + Attributes: + parent (str): + Required. The project and location from which the dns + authorizations should be listed, specified in the format + ``projects/*/locations/*``. + page_size (int): + Maximum number of dns authorizations to + return per call. + page_token (str): + The value returned by the last + ``ListDnsAuthorizationsResponse``. Indicates that this is a + continuation of a prior ``ListDnsAuthorizations`` call, and + that the system should return the next page of data. + filter (str): + Filter expression to restrict the Dns + Authorizations returned. + order_by (str): + A list of Dns Authorization field names used + to specify the order of the returned results. + The default sorting order is ascending. To + specify descending order for a field, add a + suffix " desc". + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListDnsAuthorizationsResponse(proto.Message): + r"""Response for the ``ListDnsAuthorizations`` method. + + Attributes: + dns_authorizations (MutableSequence[google.cloud.certificate_manager_v1.types.DnsAuthorization]): + A list of dns authorizations for the parent + resource. + next_page_token (str): + If there might be more results than those appearing in this + response, then ``next_page_token`` is included. To get the + next set of results, call this method again using the value + of ``next_page_token`` as ``page_token``. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + dns_authorizations: MutableSequence['DnsAuthorization'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='DnsAuthorization', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetDnsAuthorizationRequest(proto.Message): + r"""Request for the ``GetDnsAuthorization`` method. + + Attributes: + name (str): + Required. A name of the dns authorization to describe. Must + be in the format + ``projects/*/locations/*/dnsAuthorizations/*``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateDnsAuthorizationRequest(proto.Message): + r"""Request for the ``CreateDnsAuthorization`` method. + + Attributes: + parent (str): + Required. The parent resource of the dns authorization. Must + be in the format ``projects/*/locations/*``. + dns_authorization_id (str): + Required. A user-provided name of the dns + authorization. + dns_authorization (google.cloud.certificate_manager_v1.types.DnsAuthorization): + Required. A definition of the dns + authorization to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + dns_authorization_id: str = proto.Field( + proto.STRING, + number=2, + ) + dns_authorization: 'DnsAuthorization' = proto.Field( + proto.MESSAGE, + number=3, + message='DnsAuthorization', + ) + + +class UpdateDnsAuthorizationRequest(proto.Message): + r"""Request for the ``UpdateDnsAuthorization`` method. + + Attributes: + dns_authorization (google.cloud.certificate_manager_v1.types.DnsAuthorization): + Required. A definition of the dns + authorization to update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + """ + + dns_authorization: 'DnsAuthorization' = proto.Field( + proto.MESSAGE, + number=1, + message='DnsAuthorization', + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteDnsAuthorizationRequest(proto.Message): + r"""Request for the ``DeleteDnsAuthorization`` method. + + Attributes: + name (str): + Required. A name of the dns authorization to delete. Must be + in the format + ``projects/*/locations/*/dnsAuthorizations/*``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class OperationMetadata(proto.Message): + r"""Represents the metadata of the long-running operation. Output + only. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + The time the operation was created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + The time the operation finished running. + target (str): + Server-defined resource path for the target + of the operation. + verb (str): + Name of the verb executed by the operation. + status_message (str): + Human-readable status of the operation, if + any. + requested_cancellation (bool): + 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): + API version used to start the operation. + """ + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + target: str = proto.Field( + proto.STRING, + number=3, + ) + verb: str = proto.Field( + proto.STRING, + number=4, + ) + status_message: str = proto.Field( + proto.STRING, + number=5, + ) + requested_cancellation: bool = proto.Field( + proto.BOOL, + number=6, + ) + api_version: str = proto.Field( + proto.STRING, + number=7, + ) + + +class Certificate(proto.Message): + r"""Defines TLS certificate. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + A user-defined name of the certificate. Certificate names + must be unique globally and match pattern + ``projects/*/locations/*/certificates/*``. + description (str): + One or more paragraphs of text description of + a certificate. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The creation timestamp of a + Certificate. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The last update timestamp of a + Certificate. + labels (MutableMapping[str, str]): + Set of labels associated with a Certificate. + self_managed (google.cloud.certificate_manager_v1.types.Certificate.SelfManagedCertificate): + If set, defines data of a self-managed + certificate. + + This field is a member of `oneof`_ ``type``. + managed (google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate): + If set, contains configuration and state of a + managed certificate. + + This field is a member of `oneof`_ ``type``. + san_dnsnames (MutableSequence[str]): + Output only. The list of Subject Alternative + Names of dnsName type defined in the certificate + (see RFC 5280 4.2.1.6). Managed certificates + that haven't been provisioned yet have this + field populated with a value of the + managed.domains field. + pem_certificate (str): + Output only. The PEM-encoded certificate + chain. + expire_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The expiry timestamp of a + Certificate. + scope (google.cloud.certificate_manager_v1.types.Certificate.Scope): + Immutable. The scope of the certificate. + """ + class Scope(proto.Enum): + r"""Certificate scope. + + Values: + DEFAULT (0): + Certificates with default scope are served + from core Google data centers. If unsure, choose + this option. + EDGE_CACHE (1): + Certificates with scope EDGE_CACHE are special-purposed + certificates, served from non-core Google data centers. + """ + DEFAULT = 0 + EDGE_CACHE = 1 + + class SelfManagedCertificate(proto.Message): + r"""Certificate data for a SelfManaged Certificate. + SelfManaged Certificates are uploaded by the user. Updating such + certificates before they expire remains the user's + responsibility. + + Attributes: + pem_certificate (str): + Input only. The PEM-encoded certificate + chain. Leaf certificate comes first, followed by + intermediate ones if any. + pem_private_key (str): + Input only. The PEM-encoded private key of + the leaf certificate. + """ + + pem_certificate: str = proto.Field( + proto.STRING, + number=1, + ) + pem_private_key: str = proto.Field( + proto.STRING, + number=2, + ) + + class ManagedCertificate(proto.Message): + r"""Configuration and state of a Managed Certificate. + Certificate Manager provisions and renews Managed Certificates + automatically, for as long as it's authorized to do so. + + Attributes: + domains (MutableSequence[str]): + Immutable. The domains for which a managed + SSL certificate will be generated. Wildcard + domains are only supported with DNS challenge + resolution. + dns_authorizations (MutableSequence[str]): + Immutable. Authorizations that will be used + for performing domain authorization. + issuance_config (str): + Immutable. The resource name for a + [CertificateIssuanceConfig][google.cloud.certificatemanager.v1.CertificateIssuanceConfig] + used to configure private PKI certificates in the format + ``projects/*/locations/*/certificateIssuanceConfigs/*``. If + this field is not set, the certificates will instead be + publicly signed as documented at + https://cloud.google.com/load-balancing/docs/ssl-certificates/google-managed-certs#caa. + state (google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate.State): + Output only. State of the managed certificate + resource. + provisioning_issue (google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate.ProvisioningIssue): + Output only. Information about issues with + provisioning a Managed Certificate. + authorization_attempt_info (MutableSequence[google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate.AuthorizationAttemptInfo]): + Output only. Detailed state of the latest + authorization attempt for each domain specified + for managed certificate resource. + """ + class State(proto.Enum): + r"""State of the managed certificate resource. + + Values: + STATE_UNSPECIFIED (0): + State is unspecified. + PROVISIONING (1): + Certificate Manager attempts to provision or renew the + certificate. If the process takes longer than expected, + consult the ``provisioning_issue`` field. + FAILED (2): + Multiple certificate provisioning attempts failed and + Certificate Manager gave up. To try again, delete and create + a new managed Certificate resource. For details see the + ``provisioning_issue`` field. + ACTIVE (3): + The certificate management is working, and a + certificate has been provisioned. + """ + STATE_UNSPECIFIED = 0 + PROVISIONING = 1 + FAILED = 2 + ACTIVE = 3 + + class ProvisioningIssue(proto.Message): + r"""Information about issues with provisioning a Managed + Certificate. + + Attributes: + reason (google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate.ProvisioningIssue.Reason): + Output only. Reason for provisioning + failures. + details (str): + Output only. Human readable explanation about + the issue. Provided to help address the + configuration issues. Not guaranteed to be + stable. For programmatic access use Reason enum. + """ + class Reason(proto.Enum): + r"""Reason for provisioning failures. + + Values: + REASON_UNSPECIFIED (0): + Reason is unspecified. + AUTHORIZATION_ISSUE (1): + Certificate provisioning failed due to an issue with one or + more of the domains on the certificate. For details of which + domains failed, consult the ``authorization_attempt_info`` + field. + RATE_LIMITED (2): + Exceeded Certificate Authority quotas or + internal rate limits of the system. Provisioning + may take longer to complete. + """ + REASON_UNSPECIFIED = 0 + AUTHORIZATION_ISSUE = 1 + RATE_LIMITED = 2 + + reason: 'Certificate.ManagedCertificate.ProvisioningIssue.Reason' = proto.Field( + proto.ENUM, + number=1, + enum='Certificate.ManagedCertificate.ProvisioningIssue.Reason', + ) + details: str = proto.Field( + proto.STRING, + number=2, + ) + + class AuthorizationAttemptInfo(proto.Message): + r"""State of the latest attempt to authorize a domain for + certificate issuance. + + Attributes: + domain (str): + Domain name of the authorization attempt. + state (google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate.AuthorizationAttemptInfo.State): + Output only. State of the domain for managed + certificate issuance. + failure_reason (google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate.AuthorizationAttemptInfo.FailureReason): + Output only. Reason for failure of the + authorization attempt for the domain. + details (str): + Output only. Human readable explanation for + reaching the state. Provided to help address the + configuration issues. Not guaranteed to be + stable. For programmatic access use + FailureReason enum. + """ + class State(proto.Enum): + r"""State of the domain for managed certificate issuance. + + Values: + STATE_UNSPECIFIED (0): + State is unspecified. + AUTHORIZING (1): + Certificate provisioning for this domain is + under way. GCP will attempt to authorize the + domain. + AUTHORIZED (6): + A managed certificate can be provisioned, no + issues for this domain. + FAILED (7): + Attempt to authorize the domain failed. This prevents the + Managed Certificate from being issued. See + ``failure_reason`` and ``details`` fields for more + information. + """ + STATE_UNSPECIFIED = 0 + AUTHORIZING = 1 + AUTHORIZED = 6 + FAILED = 7 + + class FailureReason(proto.Enum): + r"""Reason for failure of the authorization attempt for the + domain. + + Values: + FAILURE_REASON_UNSPECIFIED (0): + FailureReason is unspecified. + CONFIG (1): + There was a problem with the user's DNS or + load balancer configuration for this domain. + CAA (2): + Certificate issuance forbidden by an explicit + CAA record for the domain or a failure to check + CAA records for the domain. + RATE_LIMITED (3): + Reached a CA or internal rate-limit for the + domain, e.g. for certificates per top-level + private domain. + """ + FAILURE_REASON_UNSPECIFIED = 0 + CONFIG = 1 + CAA = 2 + RATE_LIMITED = 3 + + domain: str = proto.Field( + proto.STRING, + number=1, + ) + state: 'Certificate.ManagedCertificate.AuthorizationAttemptInfo.State' = proto.Field( + proto.ENUM, + number=2, + enum='Certificate.ManagedCertificate.AuthorizationAttemptInfo.State', + ) + failure_reason: 'Certificate.ManagedCertificate.AuthorizationAttemptInfo.FailureReason' = proto.Field( + proto.ENUM, + number=3, + enum='Certificate.ManagedCertificate.AuthorizationAttemptInfo.FailureReason', + ) + details: str = proto.Field( + proto.STRING, + number=4, + ) + + domains: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=1, + ) + dns_authorizations: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=2, + ) + issuance_config: str = proto.Field( + proto.STRING, + number=6, + ) + state: 'Certificate.ManagedCertificate.State' = proto.Field( + proto.ENUM, + number=4, + enum='Certificate.ManagedCertificate.State', + ) + provisioning_issue: 'Certificate.ManagedCertificate.ProvisioningIssue' = proto.Field( + proto.MESSAGE, + number=3, + message='Certificate.ManagedCertificate.ProvisioningIssue', + ) + authorization_attempt_info: MutableSequence['Certificate.ManagedCertificate.AuthorizationAttemptInfo'] = proto.RepeatedField( + proto.MESSAGE, + number=5, + message='Certificate.ManagedCertificate.AuthorizationAttemptInfo', + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + description: str = proto.Field( + proto.STRING, + number=8, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + self_managed: SelfManagedCertificate = proto.Field( + proto.MESSAGE, + number=5, + oneof='type', + message=SelfManagedCertificate, + ) + managed: ManagedCertificate = proto.Field( + proto.MESSAGE, + number=11, + oneof='type', + message=ManagedCertificate, + ) + san_dnsnames: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=6, + ) + pem_certificate: str = proto.Field( + proto.STRING, + number=9, + ) + expire_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + scope: Scope = proto.Field( + proto.ENUM, + number=12, + enum=Scope, + ) + + +class CertificateMap(proto.Message): + r"""Defines a collection of certificate configurations. + + Attributes: + name (str): + A user-defined name of the Certificate Map. Certificate Map + names must be unique globally and match pattern + ``projects/*/locations/*/certificateMaps/*``. + description (str): + One or more paragraphs of text description of + a certificate map. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The creation timestamp of a + Certificate Map. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The update timestamp of a + Certificate Map. + labels (MutableMapping[str, str]): + Set of labels associated with a Certificate + Map. + gclb_targets (MutableSequence[google.cloud.certificate_manager_v1.types.CertificateMap.GclbTarget]): + Output only. A list of GCLB targets that use + this Certificate Map. A Target Proxy is only + present on this list if it's attached to a + Forwarding Rule. + """ + + class GclbTarget(proto.Message): + r"""Describes a Target Proxy that uses this Certificate Map. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + target_https_proxy (str): + Output only. This field returns the resource name in the + following format: + ``//compute.googleapis.com/projects/*/global/targetHttpsProxies/*``. + + This field is a member of `oneof`_ ``target_proxy``. + target_ssl_proxy (str): + Output only. This field returns the resource name in the + following format: + ``//compute.googleapis.com/projects/*/global/targetSslProxies/*``. + + This field is a member of `oneof`_ ``target_proxy``. + ip_configs (MutableSequence[google.cloud.certificate_manager_v1.types.CertificateMap.GclbTarget.IpConfig]): + Output only. IP configurations for this + Target Proxy where the Certificate Map is + serving. + """ + + class IpConfig(proto.Message): + r"""Defines IP configuration where this Certificate Map is + serving. + + Attributes: + ip_address (str): + Output only. An external IP address. + ports (MutableSequence[int]): + Output only. Ports. + """ + + ip_address: str = proto.Field( + proto.STRING, + number=1, + ) + ports: MutableSequence[int] = proto.RepeatedField( + proto.UINT32, + number=3, + ) + + target_https_proxy: str = proto.Field( + proto.STRING, + number=1, + oneof='target_proxy', + ) + target_ssl_proxy: str = proto.Field( + proto.STRING, + number=3, + oneof='target_proxy', + ) + ip_configs: MutableSequence['CertificateMap.GclbTarget.IpConfig'] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='CertificateMap.GclbTarget.IpConfig', + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + description: str = proto.Field( + proto.STRING, + number=5, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) + gclb_targets: MutableSequence[GclbTarget] = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=GclbTarget, + ) + + +class CertificateMapEntry(proto.Message): + r"""Defines a certificate map entry. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + A user-defined name of the Certificate Map Entry. + Certificate Map Entry names must be unique globally and + match pattern + ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. + description (str): + One or more paragraphs of text description of + a certificate map entry. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The creation timestamp of a + Certificate Map Entry. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The update timestamp of a + Certificate Map Entry. + labels (MutableMapping[str, str]): + Set of labels associated with a Certificate + Map Entry. + hostname (str): + A Hostname (FQDN, e.g. ``example.com``) or a wildcard + hostname expression (``*.example.com``) for a set of + hostnames with common suffix. Used as Server Name Indication + (SNI) for selecting a proper certificate. + + This field is a member of `oneof`_ ``match``. + matcher (google.cloud.certificate_manager_v1.types.CertificateMapEntry.Matcher): + A predefined matcher for particular cases, + other than SNI selection. + + This field is a member of `oneof`_ ``match``. + certificates (MutableSequence[str]): + A set of Certificates defines for the given ``hostname``. + There can be defined up to fifteen certificates in each + Certificate Map Entry. Each certificate must match pattern + ``projects/*/locations/*/certificates/*``. + state (google.cloud.certificate_manager_v1.types.ServingState): + Output only. A serving state of this + Certificate Map Entry. + """ + class Matcher(proto.Enum): + r"""Defines predefined cases other than SNI-hostname match when + this configuration should be applied. + + Values: + MATCHER_UNSPECIFIED (0): + A matcher has't been recognized. + PRIMARY (1): + A primary certificate that is served when SNI + wasn't specified in the request or SNI couldn't + be found in the map. + """ + MATCHER_UNSPECIFIED = 0 + PRIMARY = 1 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + description: str = proto.Field( + proto.STRING, + number=9, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + hostname: str = proto.Field( + proto.STRING, + number=5, + oneof='match', + ) + matcher: Matcher = proto.Field( + proto.ENUM, + number=10, + oneof='match', + enum=Matcher, + ) + certificates: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=7, + ) + state: 'ServingState' = proto.Field( + proto.ENUM, + number=8, + enum='ServingState', + ) + + +class DnsAuthorization(proto.Message): + r"""A DnsAuthorization resource describes a way to perform domain + authorization for certificate issuance. + + Attributes: + name (str): + A user-defined name of the dns authorization. + DnsAuthorization names must be unique globally and match + pattern ``projects/*/locations/*/dnsAuthorizations/*``. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The creation timestamp of a + DnsAuthorization. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The last update timestamp of a + DnsAuthorization. + labels (MutableMapping[str, str]): + Set of labels associated with a + DnsAuthorization. + description (str): + One or more paragraphs of text description of + a DnsAuthorization. + domain (str): + Required. Immutable. A domain that is being authorized. A + DnsAuthorization resource covers a single domain and its + wildcard, e.g. authorization for ``example.com`` can be used + to issue certificates for ``example.com`` and + ``*.example.com``. + dns_resource_record (google.cloud.certificate_manager_v1.types.DnsAuthorization.DnsResourceRecord): + Output only. DNS Resource Record that needs + to be added to DNS configuration. + """ + + class DnsResourceRecord(proto.Message): + r"""The structure describing the DNS Resource Record that needs + to be added to DNS configuration for the authorization to be + usable by certificate. + + Attributes: + name (str): + Output only. Fully qualified name of the DNS Resource + Record. e.g. ``_acme-challenge.example.com`` + type_ (str): + Output only. Type of the DNS Resource Record. + Currently always set to "CNAME". + data (str): + Output only. Data of the DNS Resource Record. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + type_: str = proto.Field( + proto.STRING, + number=2, + ) + data: str = proto.Field( + proto.STRING, + number=3, + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + description: str = proto.Field( + proto.STRING, + number=5, + ) + domain: str = proto.Field( + proto.STRING, + number=6, + ) + dns_resource_record: DnsResourceRecord = proto.Field( + proto.MESSAGE, + number=10, + message=DnsResourceRecord, + ) + + +__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..574c5ae --- /dev/null +++ b/owl-bot-staging/v1/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.7 +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..43a96c5 --- /dev/null +++ b/owl-bot-staging/v1/noxfile.py @@ -0,0 +1,184 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +ALL_PYTHON = [ + "3.7", + "3.8", + "3.9", + "3.10", + "3.11", +] + +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") + +BLACK_VERSION = "black==22.3.0" +BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"] +DEFAULT_PYTHON_VERSION = "3.11" + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", + "blacken", + "lint", + "lint_setup_py", +] + +@nox.session(python=ALL_PYTHON) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/cloud/certificate_manager_v1/', + '--cov=tests/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +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=ALL_PYTHON) +def mypy(session): + """Run the type checker.""" + session.install( + 'mypy', + 'types-requests', + 'types-protobuf' + ) + 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=DEFAULT_PYTHON_VERSION) +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx==4.0.1", "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", ""), + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint(session): + """Run linters. + + Returns a failure if the linters find linting errors or sufficiently + serious code quality issues. + """ + session.install("flake8", BLACK_VERSION) + session.run( + "black", + "--check", + *BLACK_PATHS, + ) + session.run("flake8", "google", "tests", "samples") + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def blacken(session): + """Run black. Format code to uniform standard.""" + session.install(BLACK_VERSION) + session.run( + "black", + *BLACK_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint_setup_py(session): + """Verify that setup.py is valid (including RST check).""" + session.install("docutils", "pygments") + session.run("python", "setup.py", "check", "--restructuredtext", "--strict") diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_async.py new file mode 100644 index 0000000..c612eb1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateCertificate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_CreateCertificate_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_create_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.CreateCertificateRequest( + parent="parent_value", + certificate_id="certificate_id_value", + ) + + # Make the request + operation = client.create_certificate(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_CreateCertificate_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_async.py new file mode 100644 index 0000000..f1b3371 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_async.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateCertificateIssuanceConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_CreateCertificateIssuanceConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_create_certificate_issuance_config(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + certificate_issuance_config = certificate_manager_v1.CertificateIssuanceConfig() + certificate_issuance_config.certificate_authority_config.certificate_authority_service_config.ca_pool = "ca_pool_value" + certificate_issuance_config.rotation_window_percentage = 2788 + certificate_issuance_config.key_algorithm = "ECDSA_P256" + + request = certificate_manager_v1.CreateCertificateIssuanceConfigRequest( + parent="parent_value", + certificate_issuance_config_id="certificate_issuance_config_id_value", + certificate_issuance_config=certificate_issuance_config, + ) + + # Make the request + operation = client.create_certificate_issuance_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_CreateCertificateIssuanceConfig_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_sync.py new file mode 100644 index 0000000..76b5165 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_sync.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateCertificateIssuanceConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_CreateCertificateIssuanceConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_create_certificate_issuance_config(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + certificate_issuance_config = certificate_manager_v1.CertificateIssuanceConfig() + certificate_issuance_config.certificate_authority_config.certificate_authority_service_config.ca_pool = "ca_pool_value" + certificate_issuance_config.rotation_window_percentage = 2788 + certificate_issuance_config.key_algorithm = "ECDSA_P256" + + request = certificate_manager_v1.CreateCertificateIssuanceConfigRequest( + parent="parent_value", + certificate_issuance_config_id="certificate_issuance_config_id_value", + certificate_issuance_config=certificate_issuance_config, + ) + + # Make the request + operation = client.create_certificate_issuance_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_CreateCertificateIssuanceConfig_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_async.py new file mode 100644 index 0000000..87dc105 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateCertificateMap +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_CreateCertificateMap_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_create_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.CreateCertificateMapRequest( + parent="parent_value", + certificate_map_id="certificate_map_id_value", + ) + + # Make the request + operation = client.create_certificate_map(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_CreateCertificateMap_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_async.py new file mode 100644 index 0000000..bdc6dd7 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_async.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateCertificateMapEntry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_CreateCertificateMapEntry_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_create_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + certificate_map_entry = certificate_manager_v1.CertificateMapEntry() + certificate_map_entry.hostname = "hostname_value" + + request = certificate_manager_v1.CreateCertificateMapEntryRequest( + parent="parent_value", + certificate_map_entry_id="certificate_map_entry_id_value", + certificate_map_entry=certificate_map_entry, + ) + + # Make the request + operation = client.create_certificate_map_entry(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_CreateCertificateMapEntry_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_sync.py new file mode 100644 index 0000000..de41ed5 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_sync.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateCertificateMapEntry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_CreateCertificateMapEntry_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_create_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + certificate_map_entry = certificate_manager_v1.CertificateMapEntry() + certificate_map_entry.hostname = "hostname_value" + + request = certificate_manager_v1.CreateCertificateMapEntryRequest( + parent="parent_value", + certificate_map_entry_id="certificate_map_entry_id_value", + certificate_map_entry=certificate_map_entry, + ) + + # Make the request + operation = client.create_certificate_map_entry(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_CreateCertificateMapEntry_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_sync.py new file mode 100644 index 0000000..bb7888e --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateCertificateMap +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_CreateCertificateMap_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_create_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.CreateCertificateMapRequest( + parent="parent_value", + certificate_map_id="certificate_map_id_value", + ) + + # Make the request + operation = client.create_certificate_map(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_CreateCertificateMap_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_sync.py new file mode 100644 index 0000000..1250dd6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateCertificate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_CreateCertificate_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_create_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.CreateCertificateRequest( + parent="parent_value", + certificate_id="certificate_id_value", + ) + + # Make the request + operation = client.create_certificate(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_CreateCertificate_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_async.py new file mode 100644 index 0000000..8f9d3f1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_async.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDnsAuthorization +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_CreateDnsAuthorization_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_create_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + dns_authorization = certificate_manager_v1.DnsAuthorization() + dns_authorization.domain = "domain_value" + + request = certificate_manager_v1.CreateDnsAuthorizationRequest( + parent="parent_value", + dns_authorization_id="dns_authorization_id_value", + dns_authorization=dns_authorization, + ) + + # Make the request + operation = client.create_dns_authorization(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_CreateDnsAuthorization_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_sync.py new file mode 100644 index 0000000..8bd5da0 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_sync.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDnsAuthorization +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_CreateDnsAuthorization_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_create_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + dns_authorization = certificate_manager_v1.DnsAuthorization() + dns_authorization.domain = "domain_value" + + request = certificate_manager_v1.CreateDnsAuthorizationRequest( + parent="parent_value", + dns_authorization_id="dns_authorization_id_value", + dns_authorization=dns_authorization, + ) + + # Make the request + operation = client.create_dns_authorization(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_CreateDnsAuthorization_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_async.py new file mode 100644 index 0000000..b839f86 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteCertificate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificate_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_delete_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificate_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_async.py new file mode 100644 index 0000000..ed57ab2 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteCertificateIssuanceConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificateIssuanceConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_delete_certificate_issuance_config(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateIssuanceConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate_issuance_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificateIssuanceConfig_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_sync.py new file mode 100644 index 0000000..3353075 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteCertificateIssuanceConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificateIssuanceConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_delete_certificate_issuance_config(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateIssuanceConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate_issuance_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificateIssuanceConfig_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_async.py new file mode 100644 index 0000000..72a92d3 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteCertificateMap +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificateMap_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_delete_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateMapRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate_map(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificateMap_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_async.py new file mode 100644 index 0000000..7241c67 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteCertificateMapEntry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificateMapEntry_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_delete_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateMapEntryRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate_map_entry(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificateMapEntry_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_sync.py new file mode 100644 index 0000000..9263aec --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteCertificateMapEntry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificateMapEntry_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_delete_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateMapEntryRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate_map_entry(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificateMapEntry_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_sync.py new file mode 100644 index 0000000..dcfedde --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteCertificateMap +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificateMap_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_delete_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateMapRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate_map(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificateMap_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_sync.py new file mode 100644 index 0000000..a290457 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteCertificate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificate_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_delete_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteCertificateRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_certificate(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificate_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_async.py new file mode 100644 index 0000000..adea72f --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDnsAuthorization +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_DeleteDnsAuthorization_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_delete_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteDnsAuthorizationRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_dns_authorization(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_DeleteDnsAuthorization_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_sync.py new file mode 100644 index 0000000..6ca0b46 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDnsAuthorization +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_DeleteDnsAuthorization_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_delete_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.DeleteDnsAuthorizationRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_dns_authorization(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_DeleteDnsAuthorization_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_async.py new file mode 100644 index 0000000..04d5915 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetCertificate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_GetCertificate_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_get_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateRequest( + name="name_value", + ) + + # Make the request + response = await client.get_certificate(request=request) + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_GetCertificate_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_async.py new file mode 100644 index 0000000..ac5d338 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetCertificateIssuanceConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_GetCertificateIssuanceConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_get_certificate_issuance_config(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateIssuanceConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.get_certificate_issuance_config(request=request) + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_GetCertificateIssuanceConfig_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_sync.py new file mode 100644 index 0000000..5cb7f3d --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetCertificateIssuanceConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_GetCertificateIssuanceConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_get_certificate_issuance_config(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateIssuanceConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_certificate_issuance_config(request=request) + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_GetCertificateIssuanceConfig_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_async.py new file mode 100644 index 0000000..7e93854 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetCertificateMap +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_GetCertificateMap_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_get_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateMapRequest( + name="name_value", + ) + + # Make the request + response = await client.get_certificate_map(request=request) + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_GetCertificateMap_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_async.py new file mode 100644 index 0000000..0642b83 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetCertificateMapEntry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_GetCertificateMapEntry_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_get_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateMapEntryRequest( + name="name_value", + ) + + # Make the request + response = await client.get_certificate_map_entry(request=request) + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_GetCertificateMapEntry_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_sync.py new file mode 100644 index 0000000..769b4b0 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetCertificateMapEntry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_GetCertificateMapEntry_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_get_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateMapEntryRequest( + name="name_value", + ) + + # Make the request + response = client.get_certificate_map_entry(request=request) + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_GetCertificateMapEntry_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_sync.py new file mode 100644 index 0000000..163a307 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetCertificateMap +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_GetCertificateMap_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_get_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateMapRequest( + name="name_value", + ) + + # Make the request + response = client.get_certificate_map(request=request) + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_GetCertificateMap_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_sync.py new file mode 100644 index 0000000..d472501 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetCertificate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_GetCertificate_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_get_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetCertificateRequest( + name="name_value", + ) + + # Make the request + response = client.get_certificate(request=request) + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_GetCertificate_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_async.py new file mode 100644 index 0000000..f0848b7 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDnsAuthorization +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_GetDnsAuthorization_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_get_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetDnsAuthorizationRequest( + name="name_value", + ) + + # Make the request + response = await client.get_dns_authorization(request=request) + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_GetDnsAuthorization_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_sync.py new file mode 100644 index 0000000..4da758c --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDnsAuthorization +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_GetDnsAuthorization_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_get_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.GetDnsAuthorizationRequest( + name="name_value", + ) + + # Make the request + response = client.get_dns_authorization(request=request) + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_GetDnsAuthorization_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_async.py new file mode 100644 index 0000000..3790495 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListCertificateIssuanceConfigs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_ListCertificateIssuanceConfigs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_list_certificate_issuance_configs(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificateIssuanceConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificate_issuance_configs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_ListCertificateIssuanceConfigs_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_sync.py new file mode 100644 index 0000000..a1cdc39 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListCertificateIssuanceConfigs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_ListCertificateIssuanceConfigs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_list_certificate_issuance_configs(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificateIssuanceConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificate_issuance_configs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_ListCertificateIssuanceConfigs_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_async.py new file mode 100644 index 0000000..99f430c --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListCertificateMapEntries +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_ListCertificateMapEntries_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_list_certificate_map_entries(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificateMapEntriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificate_map_entries(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_ListCertificateMapEntries_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_sync.py new file mode 100644 index 0000000..fab24bd --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListCertificateMapEntries +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_ListCertificateMapEntries_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_list_certificate_map_entries(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificateMapEntriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificate_map_entries(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_ListCertificateMapEntries_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_async.py new file mode 100644 index 0000000..295c19f --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListCertificateMaps +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_ListCertificateMaps_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_list_certificate_maps(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificateMapsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificate_maps(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_ListCertificateMaps_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_sync.py new file mode 100644 index 0000000..8c87aa3 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListCertificateMaps +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_ListCertificateMaps_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_list_certificate_maps(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificateMapsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificate_maps(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_ListCertificateMaps_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_async.py new file mode 100644 index 0000000..8177eba --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListCertificates +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_ListCertificates_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_list_certificates(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificatesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificates(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_ListCertificates_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_sync.py new file mode 100644 index 0000000..5b913d3 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListCertificates +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_ListCertificates_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_list_certificates(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListCertificatesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_certificates(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_ListCertificates_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_async.py new file mode 100644 index 0000000..ca6d58a --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDnsAuthorizations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_ListDnsAuthorizations_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_list_dns_authorizations(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListDnsAuthorizationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_dns_authorizations(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_ListDnsAuthorizations_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_sync.py new file mode 100644 index 0000000..479ba53 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDnsAuthorizations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_ListDnsAuthorizations_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_list_dns_authorizations(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.ListDnsAuthorizationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_dns_authorizations(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_ListDnsAuthorizations_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_async.py new file mode 100644 index 0000000..1687d61 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateCertificate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_UpdateCertificate_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_update_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.UpdateCertificateRequest( + ) + + # Make the request + operation = client.update_certificate(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_UpdateCertificate_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_async.py new file mode 100644 index 0000000..ee7727c --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateCertificateMap +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_UpdateCertificateMap_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_update_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + request = certificate_manager_v1.UpdateCertificateMapRequest( + ) + + # Make the request + operation = client.update_certificate_map(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_UpdateCertificateMap_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_async.py new file mode 100644 index 0000000..05f7389 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_async.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateCertificateMapEntry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_UpdateCertificateMapEntry_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_update_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + certificate_map_entry = certificate_manager_v1.CertificateMapEntry() + certificate_map_entry.hostname = "hostname_value" + + request = certificate_manager_v1.UpdateCertificateMapEntryRequest( + certificate_map_entry=certificate_map_entry, + ) + + # Make the request + operation = client.update_certificate_map_entry(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_UpdateCertificateMapEntry_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_sync.py new file mode 100644 index 0000000..ec7c65f --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_sync.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateCertificateMapEntry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_UpdateCertificateMapEntry_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_update_certificate_map_entry(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + certificate_map_entry = certificate_manager_v1.CertificateMapEntry() + certificate_map_entry.hostname = "hostname_value" + + request = certificate_manager_v1.UpdateCertificateMapEntryRequest( + certificate_map_entry=certificate_map_entry, + ) + + # Make the request + operation = client.update_certificate_map_entry(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_UpdateCertificateMapEntry_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_sync.py new file mode 100644 index 0000000..7c89104 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateCertificateMap +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_UpdateCertificateMap_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_update_certificate_map(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.UpdateCertificateMapRequest( + ) + + # Make the request + operation = client.update_certificate_map(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_UpdateCertificateMap_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_sync.py new file mode 100644 index 0000000..4d399ba --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateCertificate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_UpdateCertificate_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_update_certificate(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + request = certificate_manager_v1.UpdateCertificateRequest( + ) + + # Make the request + operation = client.update_certificate(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_UpdateCertificate_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_async.py new file mode 100644 index 0000000..7764a3b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_async.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDnsAuthorization +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_UpdateDnsAuthorization_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +async def sample_update_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerAsyncClient() + + # Initialize request argument(s) + dns_authorization = certificate_manager_v1.DnsAuthorization() + dns_authorization.domain = "domain_value" + + request = certificate_manager_v1.UpdateDnsAuthorizationRequest( + dns_authorization=dns_authorization, + ) + + # Make the request + operation = client.update_dns_authorization(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_UpdateDnsAuthorization_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_sync.py new file mode 100644 index 0000000..d4750c1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_sync.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDnsAuthorization +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-certificate-manager + + +# [START certificatemanager_v1_generated_CertificateManager_UpdateDnsAuthorization_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import certificate_manager_v1 + + +def sample_update_dns_authorization(): + # Create a client + client = certificate_manager_v1.CertificateManagerClient() + + # Initialize request argument(s) + dns_authorization = certificate_manager_v1.DnsAuthorization() + dns_authorization.domain = "domain_value" + + request = certificate_manager_v1.UpdateDnsAuthorizationRequest( + dns_authorization=dns_authorization, + ) + + # Make the request + operation = client.update_dns_authorization(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END certificatemanager_v1_generated_CertificateManager_UpdateDnsAuthorization_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/snippet_metadata_google.cloud.certificatemanager.v1.json b/owl-bot-staging/v1/samples/generated_samples/snippet_metadata_google.cloud.certificatemanager.v1.json new file mode 100644 index 0000000..8721c43 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated_samples/snippet_metadata_google.cloud.certificatemanager.v1.json @@ -0,0 +1,3991 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.certificatemanager.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-certificate-manager", + "version": "0.1.0" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.create_certificate_issuance_config", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificateIssuanceConfig", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "CreateCertificateIssuanceConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.CreateCertificateIssuanceConfigRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "certificate_issuance_config", + "type": "google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig" + }, + { + "name": "certificate_issuance_config_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_certificate_issuance_config" + }, + "description": "Sample for CreateCertificateIssuanceConfig", + "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificateIssuanceConfig_async", + "segments": [ + { + "end": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.create_certificate_issuance_config", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificateIssuanceConfig", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "CreateCertificateIssuanceConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.CreateCertificateIssuanceConfigRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "certificate_issuance_config", + "type": "google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig" + }, + { + "name": "certificate_issuance_config_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_certificate_issuance_config" + }, + "description": "Sample for CreateCertificateIssuanceConfig", + "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificateIssuanceConfig_sync", + "segments": [ + { + "end": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.create_certificate_map_entry", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificateMapEntry", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "CreateCertificateMapEntry" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.CreateCertificateMapEntryRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "certificate_map_entry", + "type": "google.cloud.certificate_manager_v1.types.CertificateMapEntry" + }, + { + "name": "certificate_map_entry_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_certificate_map_entry" + }, + "description": "Sample for CreateCertificateMapEntry", + "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificateMapEntry_async", + "segments": [ + { + "end": 60, + "start": 27, + "type": "FULL" + }, + { + "end": 60, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 57, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 61, + "start": 58, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.create_certificate_map_entry", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificateMapEntry", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "CreateCertificateMapEntry" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.CreateCertificateMapEntryRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "certificate_map_entry", + "type": "google.cloud.certificate_manager_v1.types.CertificateMapEntry" + }, + { + "name": "certificate_map_entry_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_certificate_map_entry" + }, + "description": "Sample for CreateCertificateMapEntry", + "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificateMapEntry_sync", + "segments": [ + { + "end": 60, + "start": 27, + "type": "FULL" + }, + { + "end": 60, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 57, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 61, + "start": 58, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.create_certificate_map", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificateMap", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "CreateCertificateMap" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.CreateCertificateMapRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "certificate_map", + "type": "google.cloud.certificate_manager_v1.types.CertificateMap" + }, + { + "name": "certificate_map_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_certificate_map" + }, + "description": "Sample for CreateCertificateMap", + "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificateMap_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.create_certificate_map", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificateMap", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "CreateCertificateMap" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.CreateCertificateMapRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "certificate_map", + "type": "google.cloud.certificate_manager_v1.types.CertificateMap" + }, + { + "name": "certificate_map_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_certificate_map" + }, + "description": "Sample for CreateCertificateMap", + "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificateMap_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.create_certificate", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificate", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "CreateCertificate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.CreateCertificateRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "certificate", + "type": "google.cloud.certificate_manager_v1.types.Certificate" + }, + { + "name": "certificate_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_certificate" + }, + "description": "Sample for CreateCertificate", + "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificate_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.create_certificate", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificate", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "CreateCertificate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.CreateCertificateRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "certificate", + "type": "google.cloud.certificate_manager_v1.types.Certificate" + }, + { + "name": "certificate_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_certificate" + }, + "description": "Sample for CreateCertificate", + "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificate_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.create_dns_authorization", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateDnsAuthorization", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "CreateDnsAuthorization" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.CreateDnsAuthorizationRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "dns_authorization", + "type": "google.cloud.certificate_manager_v1.types.DnsAuthorization" + }, + { + "name": "dns_authorization_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_dns_authorization" + }, + "description": "Sample for CreateDnsAuthorization", + "file": "certificatemanager_v1_generated_certificate_manager_create_dns_authorization_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateDnsAuthorization_async", + "segments": [ + { + "end": 60, + "start": 27, + "type": "FULL" + }, + { + "end": 60, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 57, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 61, + "start": 58, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_create_dns_authorization_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.create_dns_authorization", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateDnsAuthorization", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "CreateDnsAuthorization" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.CreateDnsAuthorizationRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "dns_authorization", + "type": "google.cloud.certificate_manager_v1.types.DnsAuthorization" + }, + { + "name": "dns_authorization_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_dns_authorization" + }, + "description": "Sample for CreateDnsAuthorization", + "file": "certificatemanager_v1_generated_certificate_manager_create_dns_authorization_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateDnsAuthorization_sync", + "segments": [ + { + "end": 60, + "start": 27, + "type": "FULL" + }, + { + "end": 60, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 57, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 61, + "start": 58, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_create_dns_authorization_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.delete_certificate_issuance_config", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificateIssuanceConfig", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "DeleteCertificateIssuanceConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateIssuanceConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_certificate_issuance_config" + }, + "description": "Sample for DeleteCertificateIssuanceConfig", + "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificateIssuanceConfig_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.delete_certificate_issuance_config", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificateIssuanceConfig", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "DeleteCertificateIssuanceConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateIssuanceConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_certificate_issuance_config" + }, + "description": "Sample for DeleteCertificateIssuanceConfig", + "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificateIssuanceConfig_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.delete_certificate_map_entry", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificateMapEntry", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "DeleteCertificateMapEntry" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateMapEntryRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_certificate_map_entry" + }, + "description": "Sample for DeleteCertificateMapEntry", + "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificateMapEntry_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.delete_certificate_map_entry", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificateMapEntry", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "DeleteCertificateMapEntry" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateMapEntryRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_certificate_map_entry" + }, + "description": "Sample for DeleteCertificateMapEntry", + "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificateMapEntry_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.delete_certificate_map", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificateMap", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "DeleteCertificateMap" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateMapRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_certificate_map" + }, + "description": "Sample for DeleteCertificateMap", + "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificateMap_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.delete_certificate_map", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificateMap", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "DeleteCertificateMap" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateMapRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_certificate_map" + }, + "description": "Sample for DeleteCertificateMap", + "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificateMap_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.delete_certificate", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificate", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "DeleteCertificate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_certificate" + }, + "description": "Sample for DeleteCertificate", + "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificate_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.delete_certificate", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificate", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "DeleteCertificate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_certificate" + }, + "description": "Sample for DeleteCertificate", + "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificate_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.delete_dns_authorization", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteDnsAuthorization", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "DeleteDnsAuthorization" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.DeleteDnsAuthorizationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_dns_authorization" + }, + "description": "Sample for DeleteDnsAuthorization", + "file": "certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteDnsAuthorization_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.delete_dns_authorization", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteDnsAuthorization", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "DeleteDnsAuthorization" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.DeleteDnsAuthorizationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_dns_authorization" + }, + "description": "Sample for DeleteDnsAuthorization", + "file": "certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteDnsAuthorization_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.get_certificate_issuance_config", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificateIssuanceConfig", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "GetCertificateIssuanceConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.GetCertificateIssuanceConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig", + "shortName": "get_certificate_issuance_config" + }, + "description": "Sample for GetCertificateIssuanceConfig", + "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificateIssuanceConfig_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.get_certificate_issuance_config", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificateIssuanceConfig", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "GetCertificateIssuanceConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.GetCertificateIssuanceConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig", + "shortName": "get_certificate_issuance_config" + }, + "description": "Sample for GetCertificateIssuanceConfig", + "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificateIssuanceConfig_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.get_certificate_map_entry", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificateMapEntry", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "GetCertificateMapEntry" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.GetCertificateMapEntryRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.types.CertificateMapEntry", + "shortName": "get_certificate_map_entry" + }, + "description": "Sample for GetCertificateMapEntry", + "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificateMapEntry_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.get_certificate_map_entry", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificateMapEntry", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "GetCertificateMapEntry" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.GetCertificateMapEntryRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.types.CertificateMapEntry", + "shortName": "get_certificate_map_entry" + }, + "description": "Sample for GetCertificateMapEntry", + "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificateMapEntry_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.get_certificate_map", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificateMap", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "GetCertificateMap" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.GetCertificateMapRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.types.CertificateMap", + "shortName": "get_certificate_map" + }, + "description": "Sample for GetCertificateMap", + "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificateMap_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.get_certificate_map", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificateMap", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "GetCertificateMap" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.GetCertificateMapRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.types.CertificateMap", + "shortName": "get_certificate_map" + }, + "description": "Sample for GetCertificateMap", + "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificateMap_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.get_certificate", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificate", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "GetCertificate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.GetCertificateRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.types.Certificate", + "shortName": "get_certificate" + }, + "description": "Sample for GetCertificate", + "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificate_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.get_certificate", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificate", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "GetCertificate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.GetCertificateRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.types.Certificate", + "shortName": "get_certificate" + }, + "description": "Sample for GetCertificate", + "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificate_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.get_dns_authorization", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetDnsAuthorization", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "GetDnsAuthorization" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.GetDnsAuthorizationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.types.DnsAuthorization", + "shortName": "get_dns_authorization" + }, + "description": "Sample for GetDnsAuthorization", + "file": "certificatemanager_v1_generated_certificate_manager_get_dns_authorization_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_GetDnsAuthorization_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_get_dns_authorization_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.get_dns_authorization", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetDnsAuthorization", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "GetDnsAuthorization" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.GetDnsAuthorizationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.types.DnsAuthorization", + "shortName": "get_dns_authorization" + }, + "description": "Sample for GetDnsAuthorization", + "file": "certificatemanager_v1_generated_certificate_manager_get_dns_authorization_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_GetDnsAuthorization_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_get_dns_authorization_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.list_certificate_issuance_configs", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificateIssuanceConfigs", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "ListCertificateIssuanceConfigs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateIssuanceConfigsAsyncPager", + "shortName": "list_certificate_issuance_configs" + }, + "description": "Sample for ListCertificateIssuanceConfigs", + "file": "certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificateIssuanceConfigs_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.list_certificate_issuance_configs", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificateIssuanceConfigs", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "ListCertificateIssuanceConfigs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateIssuanceConfigsPager", + "shortName": "list_certificate_issuance_configs" + }, + "description": "Sample for ListCertificateIssuanceConfigs", + "file": "certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificateIssuanceConfigs_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.list_certificate_map_entries", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificateMapEntries", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "ListCertificateMapEntries" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapEntriesAsyncPager", + "shortName": "list_certificate_map_entries" + }, + "description": "Sample for ListCertificateMapEntries", + "file": "certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificateMapEntries_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.list_certificate_map_entries", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificateMapEntries", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "ListCertificateMapEntries" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapEntriesPager", + "shortName": "list_certificate_map_entries" + }, + "description": "Sample for ListCertificateMapEntries", + "file": "certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificateMapEntries_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.list_certificate_maps", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificateMaps", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "ListCertificateMaps" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.ListCertificateMapsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapsAsyncPager", + "shortName": "list_certificate_maps" + }, + "description": "Sample for ListCertificateMaps", + "file": "certificatemanager_v1_generated_certificate_manager_list_certificate_maps_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificateMaps_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_list_certificate_maps_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.list_certificate_maps", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificateMaps", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "ListCertificateMaps" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.ListCertificateMapsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapsPager", + "shortName": "list_certificate_maps" + }, + "description": "Sample for ListCertificateMaps", + "file": "certificatemanager_v1_generated_certificate_manager_list_certificate_maps_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificateMaps_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_list_certificate_maps_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.list_certificates", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificates", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "ListCertificates" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.ListCertificatesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificatesAsyncPager", + "shortName": "list_certificates" + }, + "description": "Sample for ListCertificates", + "file": "certificatemanager_v1_generated_certificate_manager_list_certificates_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificates_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_list_certificates_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.list_certificates", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificates", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "ListCertificates" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.ListCertificatesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificatesPager", + "shortName": "list_certificates" + }, + "description": "Sample for ListCertificates", + "file": "certificatemanager_v1_generated_certificate_manager_list_certificates_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificates_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_list_certificates_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.list_dns_authorizations", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListDnsAuthorizations", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "ListDnsAuthorizations" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListDnsAuthorizationsAsyncPager", + "shortName": "list_dns_authorizations" + }, + "description": "Sample for ListDnsAuthorizations", + "file": "certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_ListDnsAuthorizations_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.list_dns_authorizations", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListDnsAuthorizations", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "ListDnsAuthorizations" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListDnsAuthorizationsPager", + "shortName": "list_dns_authorizations" + }, + "description": "Sample for ListDnsAuthorizations", + "file": "certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_ListDnsAuthorizations_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.update_certificate_map_entry", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateCertificateMapEntry", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "UpdateCertificateMapEntry" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.UpdateCertificateMapEntryRequest" + }, + { + "name": "certificate_map_entry", + "type": "google.cloud.certificate_manager_v1.types.CertificateMapEntry" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_certificate_map_entry" + }, + "description": "Sample for UpdateCertificateMapEntry", + "file": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateCertificateMapEntry_async", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.update_certificate_map_entry", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateCertificateMapEntry", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "UpdateCertificateMapEntry" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.UpdateCertificateMapEntryRequest" + }, + { + "name": "certificate_map_entry", + "type": "google.cloud.certificate_manager_v1.types.CertificateMapEntry" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_certificate_map_entry" + }, + "description": "Sample for UpdateCertificateMapEntry", + "file": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateCertificateMapEntry_sync", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.update_certificate_map", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateCertificateMap", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "UpdateCertificateMap" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.UpdateCertificateMapRequest" + }, + { + "name": "certificate_map", + "type": "google.cloud.certificate_manager_v1.types.CertificateMap" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_certificate_map" + }, + "description": "Sample for UpdateCertificateMap", + "file": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateCertificateMap_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.update_certificate_map", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateCertificateMap", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "UpdateCertificateMap" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.UpdateCertificateMapRequest" + }, + { + "name": "certificate_map", + "type": "google.cloud.certificate_manager_v1.types.CertificateMap" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_certificate_map" + }, + "description": "Sample for UpdateCertificateMap", + "file": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateCertificateMap_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.update_certificate", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateCertificate", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "UpdateCertificate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.UpdateCertificateRequest" + }, + { + "name": "certificate", + "type": "google.cloud.certificate_manager_v1.types.Certificate" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_certificate" + }, + "description": "Sample for UpdateCertificate", + "file": "certificatemanager_v1_generated_certificate_manager_update_certificate_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateCertificate_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_update_certificate_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.update_certificate", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateCertificate", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "UpdateCertificate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.UpdateCertificateRequest" + }, + { + "name": "certificate", + "type": "google.cloud.certificate_manager_v1.types.Certificate" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_certificate" + }, + "description": "Sample for UpdateCertificate", + "file": "certificatemanager_v1_generated_certificate_manager_update_certificate_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateCertificate_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_update_certificate_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", + "shortName": "CertificateManagerAsyncClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.update_dns_authorization", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateDnsAuthorization", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "UpdateDnsAuthorization" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.UpdateDnsAuthorizationRequest" + }, + { + "name": "dns_authorization", + "type": "google.cloud.certificate_manager_v1.types.DnsAuthorization" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_dns_authorization" + }, + "description": "Sample for UpdateDnsAuthorization", + "file": "certificatemanager_v1_generated_certificate_manager_update_dns_authorization_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateDnsAuthorization_async", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_update_dns_authorization_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", + "shortName": "CertificateManagerClient" + }, + "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.update_dns_authorization", + "method": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateDnsAuthorization", + "service": { + "fullName": "google.cloud.certificatemanager.v1.CertificateManager", + "shortName": "CertificateManager" + }, + "shortName": "UpdateDnsAuthorization" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.certificate_manager_v1.types.UpdateDnsAuthorizationRequest" + }, + { + "name": "dns_authorization", + "type": "google.cloud.certificate_manager_v1.types.DnsAuthorization" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_dns_authorization" + }, + "description": "Sample for UpdateDnsAuthorization", + "file": "certificatemanager_v1_generated_certificate_manager_update_dns_authorization_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateDnsAuthorization_sync", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "certificatemanager_v1_generated_certificate_manager_update_dns_authorization_sync.py" + } + ] +} diff --git a/owl-bot-staging/v1/scripts/fixup_certificate_manager_v1_keywords.py b/owl-bot-staging/v1/scripts/fixup_certificate_manager_v1_keywords.py new file mode 100644 index 0000000..6d20e61 --- /dev/null +++ b/owl-bot-staging/v1/scripts/fixup_certificate_manager_v1_keywords.py @@ -0,0 +1,199 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +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 certificate_managerCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_certificate': ('parent', 'certificate_id', 'certificate', ), + 'create_certificate_issuance_config': ('parent', 'certificate_issuance_config_id', 'certificate_issuance_config', ), + 'create_certificate_map': ('parent', 'certificate_map_id', 'certificate_map', ), + 'create_certificate_map_entry': ('parent', 'certificate_map_entry_id', 'certificate_map_entry', ), + 'create_dns_authorization': ('parent', 'dns_authorization_id', 'dns_authorization', ), + 'delete_certificate': ('name', ), + 'delete_certificate_issuance_config': ('name', ), + 'delete_certificate_map': ('name', ), + 'delete_certificate_map_entry': ('name', ), + 'delete_dns_authorization': ('name', ), + 'get_certificate': ('name', ), + 'get_certificate_issuance_config': ('name', ), + 'get_certificate_map': ('name', ), + 'get_certificate_map_entry': ('name', ), + 'get_dns_authorization': ('name', ), + 'list_certificate_issuance_configs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificate_map_entries': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificate_maps': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_dns_authorizations': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'update_certificate': ('certificate', 'update_mask', ), + 'update_certificate_map': ('certificate_map', 'update_mask', ), + 'update_certificate_map_entry': ('certificate_map_entry', 'update_mask', ), + 'update_dns_authorization': ('dns_authorization', 'update_mask', ), + } + + 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: a.keyword.value not 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=certificate_managerCallTransformer(), +): + """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 certificate_manager 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..d97179b --- /dev/null +++ b/owl-bot-staging/v1/setup.py @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import io +import os + +import setuptools # type: ignore + +package_root = os.path.abspath(os.path.dirname(__file__)) + +name = 'google-cloud-certificate-manager' + + +description = "Google Cloud Certificate Manager API client library" + +version = {} +with open(os.path.join(package_root, 'google/cloud/certificate_manager/gapic_version.py')) as fp: + exec(fp.read(), version) +version = version["__version__"] + +if version[0] == "0": + release_status = "Development Status :: 4 - Beta" +else: + release_status = "Development Status :: 5 - Production/Stable" + +dependencies = [ + "google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", + "proto-plus >= 1.22.0, <2.0.0dev", + "proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'", + "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", +] +url = "https://github.com/googleapis/python-certificate-manager" + +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() + +packages = [ + package + for package in setuptools.PEP420PackageFinder.find() + if package.startswith("google") +] + +namespaces = ["google", "google.cloud"] + +setuptools.setup( + name=name, + version=version, + description=description, + long_description=readme, + author="Google LLC", + author_email="googleapis-packages@google.com", + license="Apache 2.0", + url=url, + classifiers=[ + release_status, + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Operating System :: OS Independent", + "Topic :: Internet", + ], + platforms="Posix; MacOS X; Windows", + packages=packages, + python_requires=">=3.7", + namespace_packages=namespaces, + install_requires=dependencies, + include_package_data=True, + zip_safe=False, +) diff --git a/owl-bot-staging/v1/testing/constraints-3.10.txt b/owl-bot-staging/v1/testing/constraints-3.10.txt new file mode 100644 index 0000000..ed7f9ae --- /dev/null +++ b/owl-bot-staging/v1/testing/constraints-3.10.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/v1/testing/constraints-3.11.txt b/owl-bot-staging/v1/testing/constraints-3.11.txt new file mode 100644 index 0000000..ed7f9ae --- /dev/null +++ b/owl-bot-staging/v1/testing/constraints-3.11.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/v1/testing/constraints-3.12.txt b/owl-bot-staging/v1/testing/constraints-3.12.txt new file mode 100644 index 0000000..ed7f9ae --- /dev/null +++ b/owl-bot-staging/v1/testing/constraints-3.12.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/v1/testing/constraints-3.7.txt b/owl-bot-staging/v1/testing/constraints-3.7.txt new file mode 100644 index 0000000..6c44adf --- /dev/null +++ b/owl-bot-staging/v1/testing/constraints-3.7.txt @@ -0,0 +1,9 @@ +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List all library dependencies and extras in this file. +# Pin the version to the lower bound. +# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", +# Then this file should have google-cloud-foo==1.14.0 +google-api-core==1.34.0 +proto-plus==1.22.0 +protobuf==3.19.5 diff --git a/owl-bot-staging/v1/testing/constraints-3.8.txt b/owl-bot-staging/v1/testing/constraints-3.8.txt new file mode 100644 index 0000000..ed7f9ae --- /dev/null +++ b/owl-bot-staging/v1/testing/constraints-3.8.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/v1/testing/constraints-3.9.txt b/owl-bot-staging/v1/testing/constraints-3.9.txt new file mode 100644 index 0000000..ed7f9ae --- /dev/null +++ b/owl-bot-staging/v1/testing/constraints-3.9.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/v1/tests/__init__.py b/owl-bot-staging/v1/tests/__init__.py new file mode 100644 index 0000000..231bc12 --- /dev/null +++ b/owl-bot-staging/v1/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# 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..231bc12 --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# 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..231bc12 --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/__init__.py new file mode 100644 index 0000000..231bc12 --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py b/owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py new file mode 100644 index 0000000..1816e3e --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py @@ -0,0 +1,15180 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock # pragma: NO COVER +except ImportError: # pragma: NO COVER + import mock + +import grpc +from grpc.experimental import aio +from collections.abc import Iterable +from google.protobuf import json_format +import json +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule +from proto.marshal.rules import wrappers +from requests import Response +from requests import Request, PreparedRequest +from requests.sessions import Session +from google.protobuf import json_format + +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 +from google.api_core import operation_async # type: ignore +from google.api_core import operations_v1 +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.certificate_manager_v1.services.certificate_manager import CertificateManagerAsyncClient +from google.cloud.certificate_manager_v1.services.certificate_manager import CertificateManagerClient +from google.cloud.certificate_manager_v1.services.certificate_manager import pagers +from google.cloud.certificate_manager_v1.services.certificate_manager import transports +from google.cloud.certificate_manager_v1.types import certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config +from google.cloud.certificate_manager_v1.types import certificate_manager +from google.cloud.location import locations_pb2 +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import duration_pb2 # type: ignore +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 +import google.auth + + +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 CertificateManagerClient._get_default_mtls_endpoint(None) is None + assert CertificateManagerClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert CertificateManagerClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert CertificateManagerClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert CertificateManagerClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert CertificateManagerClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (CertificateManagerClient, "grpc"), + (CertificateManagerAsyncClient, "grpc_asyncio"), + (CertificateManagerClient, "rest"), +]) +def test_certificate_manager_client_from_service_account_info(client_class, transport_name): + 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, transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == ( + 'certificatemanager.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else + 'https://certificatemanager.googleapis.com' + ) + + +@pytest.mark.parametrize("transport_class,transport_name", [ + (transports.CertificateManagerGrpcTransport, "grpc"), + (transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio"), + (transports.CertificateManagerRestTransport, "rest"), +]) +def test_certificate_manager_client_service_account_always_use_jwt(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) + + 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=False) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize("client_class,transport_name", [ + (CertificateManagerClient, "grpc"), + (CertificateManagerAsyncClient, "grpc_asyncio"), + (CertificateManagerClient, "rest"), +]) +def test_certificate_manager_client_from_service_account_file(client_class, transport_name): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: + factory.return_value = creds + client = client_class.from_service_account_file("dummy/file/path.json", transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json", transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == ( + 'certificatemanager.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else + 'https://certificatemanager.googleapis.com' + ) + + +def test_certificate_manager_client_get_transport_class(): + transport = CertificateManagerClient.get_transport_class() + available_transports = [ + transports.CertificateManagerGrpcTransport, + transports.CertificateManagerRestTransport, + ] + assert transport in available_transports + + transport = CertificateManagerClient.get_transport_class("grpc") + assert transport == transports.CertificateManagerGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CertificateManagerClient, transports.CertificateManagerGrpcTransport, "grpc"), + (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio"), + (CertificateManagerClient, transports.CertificateManagerRestTransport, "rest"), +]) +@mock.patch.object(CertificateManagerClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateManagerClient)) +@mock.patch.object(CertificateManagerAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateManagerAsyncClient)) +def test_certificate_manager_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(CertificateManagerClient, '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(CertificateManagerClient, '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(transport=transport_name, 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, + always_use_jwt_access=True, + api_audience=None, + ) + + # 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(transport=transport_name) + 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, + always_use_jwt_access=True, + api_audience=None, + ) + + # 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(transport=transport_name) + 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, + always_use_jwt_access=True, + api_audience=None, + ) + + # 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(transport=transport_name) + + # 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(transport=transport_name) + + # 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, transport=transport_name) + 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, + always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions(api_audience="https://language.googleapis.com") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + 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, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (CertificateManagerClient, transports.CertificateManagerGrpcTransport, "grpc", "true"), + (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (CertificateManagerClient, transports.CertificateManagerGrpcTransport, "grpc", "false"), + (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio", "false"), + (CertificateManagerClient, transports.CertificateManagerRestTransport, "rest", "true"), + (CertificateManagerClient, transports.CertificateManagerRestTransport, "rest", "false"), +]) +@mock.patch.object(CertificateManagerClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateManagerClient)) +@mock.patch.object(CertificateManagerAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateManagerAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_certificate_manager_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, transport=transport_name) + + 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, + always_use_jwt_access=True, + api_audience=None, + ) + + # 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(transport=transport_name) + 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, + always_use_jwt_access=True, + api_audience=None, + ) + + # 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(transport=transport_name) + 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, + always_use_jwt_access=True, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + CertificateManagerClient, CertificateManagerAsyncClient +]) +@mock.patch.object(CertificateManagerClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateManagerClient)) +@mock.patch.object(CertificateManagerAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateManagerAsyncClient)) +def test_certificate_manager_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=False): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + 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=mock_client_cert_source): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CertificateManagerClient, transports.CertificateManagerGrpcTransport, "grpc"), + (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio"), + (CertificateManagerClient, transports.CertificateManagerRestTransport, "rest"), +]) +def test_certificate_manager_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, transport=transport_name) + 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, + always_use_jwt_access=True, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (CertificateManagerClient, transports.CertificateManagerGrpcTransport, "grpc", grpc_helpers), + (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), + (CertificateManagerClient, transports.CertificateManagerRestTransport, "rest", None), +]) +def test_certificate_manager_client_client_options_credentials_file(client_class, transport_class, transport_name, grpc_helpers): + # 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, transport=transport_name) + 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, + always_use_jwt_access=True, + api_audience=None, + ) + +def test_certificate_manager_client_client_options_from_dict(): + with mock.patch('google.cloud.certificate_manager_v1.services.certificate_manager.transports.CertificateManagerGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = CertificateManagerClient( + 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, + always_use_jwt_access=True, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (CertificateManagerClient, transports.CertificateManagerGrpcTransport, "grpc", grpc_helpers), + (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_certificate_manager_client_create_channel_credentials_file(client_class, transport_class, transport_name, grpc_helpers): + # 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, transport=transport_name) + 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, + always_use_jwt_access=True, + api_audience=None, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "certificatemanager.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=None, + default_host="certificatemanager.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.ListCertificatesRequest, + dict, +]) +def test_list_certificates(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.ListCertificatesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_certificates(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.ListCertificatesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificatesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificates_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 = CertificateManagerClient( + 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_certificates), + '__call__') as call: + client.list_certificates() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.ListCertificatesRequest() + +@pytest.mark.asyncio +async def test_list_certificates_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.ListCertificatesRequest): + client = CertificateManagerAsyncClient( + 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_certificates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificatesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_certificates(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.ListCertificatesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificatesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_certificates_async_from_dict(): + await test_list_certificates_async(request_type=dict) + + +def test_list_certificates_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.ListCertificatesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificates), + '__call__') as call: + call.return_value = certificate_manager.ListCertificatesResponse() + client.list_certificates(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_certificates_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.ListCertificatesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificates), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificatesResponse()) + await client.list_certificates(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_certificates_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.ListCertificatesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_certificates( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_certificates_flattened_error(): + client = CertificateManagerClient( + 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_certificates( + certificate_manager.ListCertificatesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_certificates_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.ListCertificatesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificatesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_certificates( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_certificates_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificates( + certificate_manager.ListCertificatesRequest(), + parent='parent_value', + ) + + +def test_list_certificates_pager(transport_name: str = "grpc"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificates), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + certificate_manager.Certificate(), + certificate_manager.Certificate(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + certificate_manager.Certificate(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_certificates(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_manager.Certificate) + for i in results) +def test_list_certificates_pages(transport_name: str = "grpc"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificates), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + certificate_manager.Certificate(), + certificate_manager.Certificate(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + certificate_manager.Certificate(), + ], + ), + RuntimeError, + ) + pages = list(client.list_certificates(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_certificates_async_pager(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificates), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + certificate_manager.Certificate(), + certificate_manager.Certificate(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + certificate_manager.Certificate(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_certificates(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, certificate_manager.Certificate) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_certificates_async_pages(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificates), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + certificate_manager.Certificate(), + certificate_manager.Certificate(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + certificate_manager.Certificate(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_certificates(request={})).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + certificate_manager.GetCertificateRequest, + dict, +]) +def test_get_certificate(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.Certificate( + name='name_value', + description='description_value', + san_dnsnames=['san_dnsnames_value'], + pem_certificate='pem_certificate_value', + scope=certificate_manager.Certificate.Scope.EDGE_CACHE, + self_managed=certificate_manager.Certificate.SelfManagedCertificate(pem_certificate='pem_certificate_value'), + ) + response = client.get_certificate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.GetCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.Certificate) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.san_dnsnames == ['san_dnsnames_value'] + assert response.pem_certificate == 'pem_certificate_value' + assert response.scope == certificate_manager.Certificate.Scope.EDGE_CACHE + + +def test_get_certificate_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 = CertificateManagerClient( + 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_certificate), + '__call__') as call: + client.get_certificate() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.GetCertificateRequest() + +@pytest.mark.asyncio +async def test_get_certificate_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.GetCertificateRequest): + client = CertificateManagerAsyncClient( + 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_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.Certificate( + name='name_value', + description='description_value', + san_dnsnames=['san_dnsnames_value'], + pem_certificate='pem_certificate_value', + scope=certificate_manager.Certificate.Scope.EDGE_CACHE, + )) + response = await client.get_certificate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.GetCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.Certificate) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.san_dnsnames == ['san_dnsnames_value'] + assert response.pem_certificate == 'pem_certificate_value' + assert response.scope == certificate_manager.Certificate.Scope.EDGE_CACHE + + +@pytest.mark.asyncio +async def test_get_certificate_async_from_dict(): + await test_get_certificate_async(request_type=dict) + + +def test_get_certificate_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.GetCertificateRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate), + '__call__') as call: + call.return_value = certificate_manager.Certificate() + client.get_certificate(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_certificate_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.GetCertificateRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.Certificate()) + await client.get_certificate(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_certificate_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.Certificate() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_certificate( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_certificate_flattened_error(): + client = CertificateManagerClient( + 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_certificate( + certificate_manager.GetCertificateRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_certificate_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.Certificate() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.Certificate()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_certificate( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_certificate_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate( + certificate_manager.GetCertificateRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.CreateCertificateRequest, + dict, +]) +def test_create_certificate(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_certificate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.CreateCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_certificate_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 = CertificateManagerClient( + 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_certificate), + '__call__') as call: + client.create_certificate() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.CreateCertificateRequest() + +@pytest.mark.asyncio +async def test_create_certificate_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.CreateCertificateRequest): + client = CertificateManagerAsyncClient( + 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_certificate), + '__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_certificate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.CreateCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_certificate_async_from_dict(): + await test_create_certificate_async(request_type=dict) + + +def test_create_certificate_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.CreateCertificateRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_certificate(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_certificate_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.CreateCertificateRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_certificate(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_certificate_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate), + '__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_certificate( + parent='parent_value', + certificate=certificate_manager.Certificate(name='name_value'), + certificate_id='certificate_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].certificate + mock_val = certificate_manager.Certificate(name='name_value') + assert arg == mock_val + arg = args[0].certificate_id + mock_val = 'certificate_id_value' + assert arg == mock_val + + +def test_create_certificate_flattened_error(): + client = CertificateManagerClient( + 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_certificate( + certificate_manager.CreateCertificateRequest(), + parent='parent_value', + certificate=certificate_manager.Certificate(name='name_value'), + certificate_id='certificate_id_value', + ) + +@pytest.mark.asyncio +async def test_create_certificate_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate), + '__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_certificate( + parent='parent_value', + certificate=certificate_manager.Certificate(name='name_value'), + certificate_id='certificate_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].certificate + mock_val = certificate_manager.Certificate(name='name_value') + assert arg == mock_val + arg = args[0].certificate_id + mock_val = 'certificate_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_certificate_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate( + certificate_manager.CreateCertificateRequest(), + parent='parent_value', + certificate=certificate_manager.Certificate(name='name_value'), + certificate_id='certificate_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.UpdateCertificateRequest, + dict, +]) +def test_update_certificate(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_certificate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.UpdateCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_certificate_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 = CertificateManagerClient( + 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_certificate), + '__call__') as call: + client.update_certificate() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.UpdateCertificateRequest() + +@pytest.mark.asyncio +async def test_update_certificate_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.UpdateCertificateRequest): + client = CertificateManagerAsyncClient( + 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_certificate), + '__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_certificate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.UpdateCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_certificate_async_from_dict(): + await test_update_certificate_async(request_type=dict) + + +def test_update_certificate_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.UpdateCertificateRequest() + + request.certificate.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_certificate(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', + 'certificate.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_certificate_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.UpdateCertificateRequest() + + request.certificate.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_certificate(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', + 'certificate.name=name_value', + ) in kw['metadata'] + + +def test_update_certificate_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate), + '__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_certificate( + certificate=certificate_manager.Certificate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].certificate + mock_val = certificate_manager.Certificate(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_certificate_flattened_error(): + client = CertificateManagerClient( + 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_certificate( + certificate_manager.UpdateCertificateRequest(), + certificate=certificate_manager.Certificate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_certificate_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate), + '__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_certificate( + certificate=certificate_manager.Certificate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].certificate + mock_val = certificate_manager.Certificate(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_certificate_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate( + certificate_manager.UpdateCertificateRequest(), + certificate=certificate_manager.Certificate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.DeleteCertificateRequest, + dict, +]) +def test_delete_certificate(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_certificate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.DeleteCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_certificate_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 = CertificateManagerClient( + 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_certificate), + '__call__') as call: + client.delete_certificate() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.DeleteCertificateRequest() + +@pytest.mark.asyncio +async def test_delete_certificate_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.DeleteCertificateRequest): + client = CertificateManagerAsyncClient( + 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_certificate), + '__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_certificate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.DeleteCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_certificate_async_from_dict(): + await test_delete_certificate_async(request_type=dict) + + +def test_delete_certificate_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.DeleteCertificateRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_certificate(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_certificate_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.DeleteCertificateRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_certificate(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_certificate_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate), + '__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_certificate( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_certificate_flattened_error(): + client = CertificateManagerClient( + 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_certificate( + certificate_manager.DeleteCertificateRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_certificate_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate), + '__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_certificate( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_certificate_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate( + certificate_manager.DeleteCertificateRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.ListCertificateMapsRequest, + dict, +]) +def test_list_certificate_maps(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_maps), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.ListCertificateMapsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_certificate_maps(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.ListCertificateMapsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateMapsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificate_maps_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 = CertificateManagerClient( + 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_certificate_maps), + '__call__') as call: + client.list_certificate_maps() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.ListCertificateMapsRequest() + +@pytest.mark.asyncio +async def test_list_certificate_maps_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.ListCertificateMapsRequest): + client = CertificateManagerAsyncClient( + 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_certificate_maps), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificateMapsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_certificate_maps(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.ListCertificateMapsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateMapsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_certificate_maps_async_from_dict(): + await test_list_certificate_maps_async(request_type=dict) + + +def test_list_certificate_maps_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.ListCertificateMapsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_maps), + '__call__') as call: + call.return_value = certificate_manager.ListCertificateMapsResponse() + client.list_certificate_maps(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_certificate_maps_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.ListCertificateMapsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_maps), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificateMapsResponse()) + await client.list_certificate_maps(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_certificate_maps_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_maps), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.ListCertificateMapsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_certificate_maps( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_certificate_maps_flattened_error(): + client = CertificateManagerClient( + 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_certificate_maps( + certificate_manager.ListCertificateMapsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_certificate_maps_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_maps), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.ListCertificateMapsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificateMapsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_certificate_maps( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_certificate_maps_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_maps( + certificate_manager.ListCertificateMapsRequest(), + parent='parent_value', + ) + + +def test_list_certificate_maps_pager(transport_name: str = "grpc"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_maps), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[], + next_page_token='def', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_certificate_maps(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_manager.CertificateMap) + for i in results) +def test_list_certificate_maps_pages(transport_name: str = "grpc"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_maps), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[], + next_page_token='def', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + ], + ), + RuntimeError, + ) + pages = list(client.list_certificate_maps(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_certificate_maps_async_pager(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_maps), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[], + next_page_token='def', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_certificate_maps(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, certificate_manager.CertificateMap) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_certificate_maps_async_pages(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_maps), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[], + next_page_token='def', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_certificate_maps(request={})).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + certificate_manager.GetCertificateMapRequest, + dict, +]) +def test_get_certificate_map(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_map), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.CertificateMap( + name='name_value', + description='description_value', + ) + response = client.get_certificate_map(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.GetCertificateMapRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.CertificateMap) + assert response.name == 'name_value' + assert response.description == 'description_value' + + +def test_get_certificate_map_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 = CertificateManagerClient( + 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_certificate_map), + '__call__') as call: + client.get_certificate_map() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.GetCertificateMapRequest() + +@pytest.mark.asyncio +async def test_get_certificate_map_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.GetCertificateMapRequest): + client = CertificateManagerAsyncClient( + 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_certificate_map), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.CertificateMap( + name='name_value', + description='description_value', + )) + response = await client.get_certificate_map(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.GetCertificateMapRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.CertificateMap) + assert response.name == 'name_value' + assert response.description == 'description_value' + + +@pytest.mark.asyncio +async def test_get_certificate_map_async_from_dict(): + await test_get_certificate_map_async(request_type=dict) + + +def test_get_certificate_map_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.GetCertificateMapRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate_map), + '__call__') as call: + call.return_value = certificate_manager.CertificateMap() + client.get_certificate_map(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_certificate_map_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.GetCertificateMapRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate_map), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.CertificateMap()) + await client.get_certificate_map(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_certificate_map_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate_map), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.CertificateMap() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_certificate_map( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_certificate_map_flattened_error(): + client = CertificateManagerClient( + 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_certificate_map( + certificate_manager.GetCertificateMapRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_certificate_map_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate_map), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.CertificateMap() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.CertificateMap()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_certificate_map( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_certificate_map_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_map( + certificate_manager.GetCertificateMapRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.CreateCertificateMapRequest, + dict, +]) +def test_create_certificate_map(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_map), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_certificate_map(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.CreateCertificateMapRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_certificate_map_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 = CertificateManagerClient( + 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_certificate_map), + '__call__') as call: + client.create_certificate_map() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.CreateCertificateMapRequest() + +@pytest.mark.asyncio +async def test_create_certificate_map_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.CreateCertificateMapRequest): + client = CertificateManagerAsyncClient( + 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_certificate_map), + '__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_certificate_map(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.CreateCertificateMapRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_certificate_map_async_from_dict(): + await test_create_certificate_map_async(request_type=dict) + + +def test_create_certificate_map_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.CreateCertificateMapRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate_map), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_certificate_map(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_certificate_map_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.CreateCertificateMapRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate_map), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_certificate_map(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_certificate_map_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate_map), + '__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_certificate_map( + parent='parent_value', + certificate_map=certificate_manager.CertificateMap(name='name_value'), + certificate_map_id='certificate_map_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].certificate_map + mock_val = certificate_manager.CertificateMap(name='name_value') + assert arg == mock_val + arg = args[0].certificate_map_id + mock_val = 'certificate_map_id_value' + assert arg == mock_val + + +def test_create_certificate_map_flattened_error(): + client = CertificateManagerClient( + 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_certificate_map( + certificate_manager.CreateCertificateMapRequest(), + parent='parent_value', + certificate_map=certificate_manager.CertificateMap(name='name_value'), + certificate_map_id='certificate_map_id_value', + ) + +@pytest.mark.asyncio +async def test_create_certificate_map_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate_map), + '__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_certificate_map( + parent='parent_value', + certificate_map=certificate_manager.CertificateMap(name='name_value'), + certificate_map_id='certificate_map_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].certificate_map + mock_val = certificate_manager.CertificateMap(name='name_value') + assert arg == mock_val + arg = args[0].certificate_map_id + mock_val = 'certificate_map_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_certificate_map_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_map( + certificate_manager.CreateCertificateMapRequest(), + parent='parent_value', + certificate_map=certificate_manager.CertificateMap(name='name_value'), + certificate_map_id='certificate_map_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.UpdateCertificateMapRequest, + dict, +]) +def test_update_certificate_map(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_map), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_certificate_map(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.UpdateCertificateMapRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_certificate_map_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 = CertificateManagerClient( + 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_certificate_map), + '__call__') as call: + client.update_certificate_map() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.UpdateCertificateMapRequest() + +@pytest.mark.asyncio +async def test_update_certificate_map_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.UpdateCertificateMapRequest): + client = CertificateManagerAsyncClient( + 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_certificate_map), + '__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_certificate_map(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.UpdateCertificateMapRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_certificate_map_async_from_dict(): + await test_update_certificate_map_async(request_type=dict) + + +def test_update_certificate_map_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.UpdateCertificateMapRequest() + + request.certificate_map.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_map), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_certificate_map(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', + 'certificate_map.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_certificate_map_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.UpdateCertificateMapRequest() + + request.certificate_map.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_map), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_certificate_map(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', + 'certificate_map.name=name_value', + ) in kw['metadata'] + + +def test_update_certificate_map_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_map), + '__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_certificate_map( + certificate_map=certificate_manager.CertificateMap(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].certificate_map + mock_val = certificate_manager.CertificateMap(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_certificate_map_flattened_error(): + client = CertificateManagerClient( + 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_certificate_map( + certificate_manager.UpdateCertificateMapRequest(), + certificate_map=certificate_manager.CertificateMap(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_certificate_map_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_map), + '__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_certificate_map( + certificate_map=certificate_manager.CertificateMap(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].certificate_map + mock_val = certificate_manager.CertificateMap(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_certificate_map_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_map( + certificate_manager.UpdateCertificateMapRequest(), + certificate_map=certificate_manager.CertificateMap(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.DeleteCertificateMapRequest, + dict, +]) +def test_delete_certificate_map(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_map), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_certificate_map(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.DeleteCertificateMapRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_certificate_map_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 = CertificateManagerClient( + 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_certificate_map), + '__call__') as call: + client.delete_certificate_map() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.DeleteCertificateMapRequest() + +@pytest.mark.asyncio +async def test_delete_certificate_map_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.DeleteCertificateMapRequest): + client = CertificateManagerAsyncClient( + 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_certificate_map), + '__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_certificate_map(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.DeleteCertificateMapRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_certificate_map_async_from_dict(): + await test_delete_certificate_map_async(request_type=dict) + + +def test_delete_certificate_map_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.DeleteCertificateMapRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate_map), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_certificate_map(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_certificate_map_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.DeleteCertificateMapRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate_map), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_certificate_map(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_certificate_map_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate_map), + '__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_certificate_map( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_certificate_map_flattened_error(): + client = CertificateManagerClient( + 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_certificate_map( + certificate_manager.DeleteCertificateMapRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_certificate_map_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate_map), + '__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_certificate_map( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_certificate_map_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_map( + certificate_manager.DeleteCertificateMapRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.ListCertificateMapEntriesRequest, + dict, +]) +def test_list_certificate_map_entries(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_map_entries), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.ListCertificateMapEntriesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_certificate_map_entries(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.ListCertificateMapEntriesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateMapEntriesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificate_map_entries_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 = CertificateManagerClient( + 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_certificate_map_entries), + '__call__') as call: + client.list_certificate_map_entries() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.ListCertificateMapEntriesRequest() + +@pytest.mark.asyncio +async def test_list_certificate_map_entries_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.ListCertificateMapEntriesRequest): + client = CertificateManagerAsyncClient( + 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_certificate_map_entries), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificateMapEntriesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_certificate_map_entries(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.ListCertificateMapEntriesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateMapEntriesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_certificate_map_entries_async_from_dict(): + await test_list_certificate_map_entries_async(request_type=dict) + + +def test_list_certificate_map_entries_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.ListCertificateMapEntriesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_map_entries), + '__call__') as call: + call.return_value = certificate_manager.ListCertificateMapEntriesResponse() + client.list_certificate_map_entries(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_certificate_map_entries_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.ListCertificateMapEntriesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_map_entries), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificateMapEntriesResponse()) + await client.list_certificate_map_entries(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_certificate_map_entries_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_map_entries), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.ListCertificateMapEntriesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_certificate_map_entries( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_certificate_map_entries_flattened_error(): + client = CertificateManagerClient( + 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_certificate_map_entries( + certificate_manager.ListCertificateMapEntriesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_certificate_map_entries_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_map_entries), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.ListCertificateMapEntriesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificateMapEntriesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_certificate_map_entries( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_certificate_map_entries_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_map_entries( + certificate_manager.ListCertificateMapEntriesRequest(), + parent='parent_value', + ) + + +def test_list_certificate_map_entries_pager(transport_name: str = "grpc"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_map_entries), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[], + next_page_token='def', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_certificate_map_entries(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_manager.CertificateMapEntry) + for i in results) +def test_list_certificate_map_entries_pages(transport_name: str = "grpc"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_map_entries), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[], + next_page_token='def', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + ], + ), + RuntimeError, + ) + pages = list(client.list_certificate_map_entries(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_certificate_map_entries_async_pager(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_map_entries), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[], + next_page_token='def', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_certificate_map_entries(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, certificate_manager.CertificateMapEntry) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_certificate_map_entries_async_pages(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_map_entries), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[], + next_page_token='def', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_certificate_map_entries(request={})).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + certificate_manager.GetCertificateMapEntryRequest, + dict, +]) +def test_get_certificate_map_entry(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_map_entry), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.CertificateMapEntry( + name='name_value', + description='description_value', + certificates=['certificates_value'], + state=certificate_manager.ServingState.ACTIVE, + hostname='hostname_value', + ) + response = client.get_certificate_map_entry(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.GetCertificateMapEntryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.CertificateMapEntry) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.certificates == ['certificates_value'] + assert response.state == certificate_manager.ServingState.ACTIVE + + +def test_get_certificate_map_entry_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 = CertificateManagerClient( + 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_certificate_map_entry), + '__call__') as call: + client.get_certificate_map_entry() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.GetCertificateMapEntryRequest() + +@pytest.mark.asyncio +async def test_get_certificate_map_entry_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.GetCertificateMapEntryRequest): + client = CertificateManagerAsyncClient( + 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_certificate_map_entry), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.CertificateMapEntry( + name='name_value', + description='description_value', + certificates=['certificates_value'], + state=certificate_manager.ServingState.ACTIVE, + )) + response = await client.get_certificate_map_entry(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.GetCertificateMapEntryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.CertificateMapEntry) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.certificates == ['certificates_value'] + assert response.state == certificate_manager.ServingState.ACTIVE + + +@pytest.mark.asyncio +async def test_get_certificate_map_entry_async_from_dict(): + await test_get_certificate_map_entry_async(request_type=dict) + + +def test_get_certificate_map_entry_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.GetCertificateMapEntryRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate_map_entry), + '__call__') as call: + call.return_value = certificate_manager.CertificateMapEntry() + client.get_certificate_map_entry(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_certificate_map_entry_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.GetCertificateMapEntryRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate_map_entry), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.CertificateMapEntry()) + await client.get_certificate_map_entry(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_certificate_map_entry_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate_map_entry), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.CertificateMapEntry() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_certificate_map_entry( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_certificate_map_entry_flattened_error(): + client = CertificateManagerClient( + 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_certificate_map_entry( + certificate_manager.GetCertificateMapEntryRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_certificate_map_entry_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate_map_entry), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.CertificateMapEntry() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.CertificateMapEntry()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_certificate_map_entry( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_certificate_map_entry_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_map_entry( + certificate_manager.GetCertificateMapEntryRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.CreateCertificateMapEntryRequest, + dict, +]) +def test_create_certificate_map_entry(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_map_entry), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_certificate_map_entry(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.CreateCertificateMapEntryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_certificate_map_entry_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 = CertificateManagerClient( + 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_certificate_map_entry), + '__call__') as call: + client.create_certificate_map_entry() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.CreateCertificateMapEntryRequest() + +@pytest.mark.asyncio +async def test_create_certificate_map_entry_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.CreateCertificateMapEntryRequest): + client = CertificateManagerAsyncClient( + 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_certificate_map_entry), + '__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_certificate_map_entry(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.CreateCertificateMapEntryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_certificate_map_entry_async_from_dict(): + await test_create_certificate_map_entry_async(request_type=dict) + + +def test_create_certificate_map_entry_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.CreateCertificateMapEntryRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate_map_entry), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_certificate_map_entry(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_certificate_map_entry_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.CreateCertificateMapEntryRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate_map_entry), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_certificate_map_entry(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_certificate_map_entry_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate_map_entry), + '__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_certificate_map_entry( + parent='parent_value', + certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), + certificate_map_entry_id='certificate_map_entry_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].certificate_map_entry + mock_val = certificate_manager.CertificateMapEntry(name='name_value') + assert arg == mock_val + arg = args[0].certificate_map_entry_id + mock_val = 'certificate_map_entry_id_value' + assert arg == mock_val + + +def test_create_certificate_map_entry_flattened_error(): + client = CertificateManagerClient( + 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_certificate_map_entry( + certificate_manager.CreateCertificateMapEntryRequest(), + parent='parent_value', + certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), + certificate_map_entry_id='certificate_map_entry_id_value', + ) + +@pytest.mark.asyncio +async def test_create_certificate_map_entry_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate_map_entry), + '__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_certificate_map_entry( + parent='parent_value', + certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), + certificate_map_entry_id='certificate_map_entry_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].certificate_map_entry + mock_val = certificate_manager.CertificateMapEntry(name='name_value') + assert arg == mock_val + arg = args[0].certificate_map_entry_id + mock_val = 'certificate_map_entry_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_certificate_map_entry_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_map_entry( + certificate_manager.CreateCertificateMapEntryRequest(), + parent='parent_value', + certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), + certificate_map_entry_id='certificate_map_entry_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.UpdateCertificateMapEntryRequest, + dict, +]) +def test_update_certificate_map_entry(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_map_entry), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_certificate_map_entry(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.UpdateCertificateMapEntryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_certificate_map_entry_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 = CertificateManagerClient( + 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_certificate_map_entry), + '__call__') as call: + client.update_certificate_map_entry() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.UpdateCertificateMapEntryRequest() + +@pytest.mark.asyncio +async def test_update_certificate_map_entry_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.UpdateCertificateMapEntryRequest): + client = CertificateManagerAsyncClient( + 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_certificate_map_entry), + '__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_certificate_map_entry(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.UpdateCertificateMapEntryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_certificate_map_entry_async_from_dict(): + await test_update_certificate_map_entry_async(request_type=dict) + + +def test_update_certificate_map_entry_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.UpdateCertificateMapEntryRequest() + + request.certificate_map_entry.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_map_entry), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_certificate_map_entry(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', + 'certificate_map_entry.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_certificate_map_entry_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.UpdateCertificateMapEntryRequest() + + request.certificate_map_entry.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_map_entry), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_certificate_map_entry(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', + 'certificate_map_entry.name=name_value', + ) in kw['metadata'] + + +def test_update_certificate_map_entry_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_map_entry), + '__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_certificate_map_entry( + certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].certificate_map_entry + mock_val = certificate_manager.CertificateMapEntry(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_certificate_map_entry_flattened_error(): + client = CertificateManagerClient( + 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_certificate_map_entry( + certificate_manager.UpdateCertificateMapEntryRequest(), + certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_certificate_map_entry_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_map_entry), + '__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_certificate_map_entry( + certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].certificate_map_entry + mock_val = certificate_manager.CertificateMapEntry(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_certificate_map_entry_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_map_entry( + certificate_manager.UpdateCertificateMapEntryRequest(), + certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.DeleteCertificateMapEntryRequest, + dict, +]) +def test_delete_certificate_map_entry(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_map_entry), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_certificate_map_entry(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.DeleteCertificateMapEntryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_certificate_map_entry_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 = CertificateManagerClient( + 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_certificate_map_entry), + '__call__') as call: + client.delete_certificate_map_entry() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.DeleteCertificateMapEntryRequest() + +@pytest.mark.asyncio +async def test_delete_certificate_map_entry_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.DeleteCertificateMapEntryRequest): + client = CertificateManagerAsyncClient( + 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_certificate_map_entry), + '__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_certificate_map_entry(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.DeleteCertificateMapEntryRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_certificate_map_entry_async_from_dict(): + await test_delete_certificate_map_entry_async(request_type=dict) + + +def test_delete_certificate_map_entry_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.DeleteCertificateMapEntryRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate_map_entry), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_certificate_map_entry(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_certificate_map_entry_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.DeleteCertificateMapEntryRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate_map_entry), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_certificate_map_entry(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_certificate_map_entry_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate_map_entry), + '__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_certificate_map_entry( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_certificate_map_entry_flattened_error(): + client = CertificateManagerClient( + 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_certificate_map_entry( + certificate_manager.DeleteCertificateMapEntryRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_certificate_map_entry_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate_map_entry), + '__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_certificate_map_entry( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_certificate_map_entry_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_map_entry( + certificate_manager.DeleteCertificateMapEntryRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.ListDnsAuthorizationsRequest, + dict, +]) +def test_list_dns_authorizations(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_dns_authorizations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.ListDnsAuthorizationsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_dns_authorizations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.ListDnsAuthorizationsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDnsAuthorizationsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_dns_authorizations_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 = CertificateManagerClient( + 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_dns_authorizations), + '__call__') as call: + client.list_dns_authorizations() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.ListDnsAuthorizationsRequest() + +@pytest.mark.asyncio +async def test_list_dns_authorizations_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.ListDnsAuthorizationsRequest): + client = CertificateManagerAsyncClient( + 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_dns_authorizations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListDnsAuthorizationsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_dns_authorizations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.ListDnsAuthorizationsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDnsAuthorizationsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_dns_authorizations_async_from_dict(): + await test_list_dns_authorizations_async(request_type=dict) + + +def test_list_dns_authorizations_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.ListDnsAuthorizationsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_dns_authorizations), + '__call__') as call: + call.return_value = certificate_manager.ListDnsAuthorizationsResponse() + client.list_dns_authorizations(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_dns_authorizations_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.ListDnsAuthorizationsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_dns_authorizations), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListDnsAuthorizationsResponse()) + await client.list_dns_authorizations(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_dns_authorizations_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_dns_authorizations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.ListDnsAuthorizationsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_dns_authorizations( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_dns_authorizations_flattened_error(): + client = CertificateManagerClient( + 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_dns_authorizations( + certificate_manager.ListDnsAuthorizationsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_dns_authorizations_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_dns_authorizations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.ListDnsAuthorizationsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListDnsAuthorizationsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_dns_authorizations( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_dns_authorizations_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_dns_authorizations( + certificate_manager.ListDnsAuthorizationsRequest(), + parent='parent_value', + ) + + +def test_list_dns_authorizations_pager(transport_name: str = "grpc"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_dns_authorizations), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + ], + next_page_token='abc', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[], + next_page_token='def', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + ], + next_page_token='ghi', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_dns_authorizations(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_manager.DnsAuthorization) + for i in results) +def test_list_dns_authorizations_pages(transport_name: str = "grpc"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_dns_authorizations), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + ], + next_page_token='abc', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[], + next_page_token='def', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + ], + next_page_token='ghi', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + ], + ), + RuntimeError, + ) + pages = list(client.list_dns_authorizations(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_dns_authorizations_async_pager(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_dns_authorizations), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + ], + next_page_token='abc', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[], + next_page_token='def', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + ], + next_page_token='ghi', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_dns_authorizations(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, certificate_manager.DnsAuthorization) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_dns_authorizations_async_pages(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_dns_authorizations), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + ], + next_page_token='abc', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[], + next_page_token='def', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + ], + next_page_token='ghi', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_dns_authorizations(request={})).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + certificate_manager.GetDnsAuthorizationRequest, + dict, +]) +def test_get_dns_authorization(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_dns_authorization), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.DnsAuthorization( + name='name_value', + description='description_value', + domain='domain_value', + ) + response = client.get_dns_authorization(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.GetDnsAuthorizationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.DnsAuthorization) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.domain == 'domain_value' + + +def test_get_dns_authorization_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 = CertificateManagerClient( + 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_dns_authorization), + '__call__') as call: + client.get_dns_authorization() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.GetDnsAuthorizationRequest() + +@pytest.mark.asyncio +async def test_get_dns_authorization_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.GetDnsAuthorizationRequest): + client = CertificateManagerAsyncClient( + 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_dns_authorization), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.DnsAuthorization( + name='name_value', + description='description_value', + domain='domain_value', + )) + response = await client.get_dns_authorization(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.GetDnsAuthorizationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.DnsAuthorization) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.domain == 'domain_value' + + +@pytest.mark.asyncio +async def test_get_dns_authorization_async_from_dict(): + await test_get_dns_authorization_async(request_type=dict) + + +def test_get_dns_authorization_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.GetDnsAuthorizationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_dns_authorization), + '__call__') as call: + call.return_value = certificate_manager.DnsAuthorization() + client.get_dns_authorization(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_dns_authorization_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.GetDnsAuthorizationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_dns_authorization), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.DnsAuthorization()) + await client.get_dns_authorization(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_dns_authorization_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_dns_authorization), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.DnsAuthorization() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_dns_authorization( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_dns_authorization_flattened_error(): + client = CertificateManagerClient( + 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_dns_authorization( + certificate_manager.GetDnsAuthorizationRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_dns_authorization_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_dns_authorization), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_manager.DnsAuthorization() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.DnsAuthorization()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_dns_authorization( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_dns_authorization_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_dns_authorization( + certificate_manager.GetDnsAuthorizationRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.CreateDnsAuthorizationRequest, + dict, +]) +def test_create_dns_authorization(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_dns_authorization), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_dns_authorization(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.CreateDnsAuthorizationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_dns_authorization_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 = CertificateManagerClient( + 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_dns_authorization), + '__call__') as call: + client.create_dns_authorization() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.CreateDnsAuthorizationRequest() + +@pytest.mark.asyncio +async def test_create_dns_authorization_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.CreateDnsAuthorizationRequest): + client = CertificateManagerAsyncClient( + 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_dns_authorization), + '__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_dns_authorization(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.CreateDnsAuthorizationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_dns_authorization_async_from_dict(): + await test_create_dns_authorization_async(request_type=dict) + + +def test_create_dns_authorization_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.CreateDnsAuthorizationRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_dns_authorization), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_dns_authorization(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_dns_authorization_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.CreateDnsAuthorizationRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_dns_authorization), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_dns_authorization(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_dns_authorization_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_dns_authorization), + '__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_dns_authorization( + parent='parent_value', + dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), + dns_authorization_id='dns_authorization_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].dns_authorization + mock_val = certificate_manager.DnsAuthorization(name='name_value') + assert arg == mock_val + arg = args[0].dns_authorization_id + mock_val = 'dns_authorization_id_value' + assert arg == mock_val + + +def test_create_dns_authorization_flattened_error(): + client = CertificateManagerClient( + 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_dns_authorization( + certificate_manager.CreateDnsAuthorizationRequest(), + parent='parent_value', + dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), + dns_authorization_id='dns_authorization_id_value', + ) + +@pytest.mark.asyncio +async def test_create_dns_authorization_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_dns_authorization), + '__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_dns_authorization( + parent='parent_value', + dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), + dns_authorization_id='dns_authorization_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].dns_authorization + mock_val = certificate_manager.DnsAuthorization(name='name_value') + assert arg == mock_val + arg = args[0].dns_authorization_id + mock_val = 'dns_authorization_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_dns_authorization_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_dns_authorization( + certificate_manager.CreateDnsAuthorizationRequest(), + parent='parent_value', + dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), + dns_authorization_id='dns_authorization_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.UpdateDnsAuthorizationRequest, + dict, +]) +def test_update_dns_authorization(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_dns_authorization), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_dns_authorization(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.UpdateDnsAuthorizationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_dns_authorization_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 = CertificateManagerClient( + 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_dns_authorization), + '__call__') as call: + client.update_dns_authorization() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.UpdateDnsAuthorizationRequest() + +@pytest.mark.asyncio +async def test_update_dns_authorization_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.UpdateDnsAuthorizationRequest): + client = CertificateManagerAsyncClient( + 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_dns_authorization), + '__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_dns_authorization(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.UpdateDnsAuthorizationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_dns_authorization_async_from_dict(): + await test_update_dns_authorization_async(request_type=dict) + + +def test_update_dns_authorization_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.UpdateDnsAuthorizationRequest() + + request.dns_authorization.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_dns_authorization), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_dns_authorization(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', + 'dns_authorization.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_dns_authorization_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.UpdateDnsAuthorizationRequest() + + request.dns_authorization.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_dns_authorization), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_dns_authorization(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', + 'dns_authorization.name=name_value', + ) in kw['metadata'] + + +def test_update_dns_authorization_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_dns_authorization), + '__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_dns_authorization( + dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].dns_authorization + mock_val = certificate_manager.DnsAuthorization(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_dns_authorization_flattened_error(): + client = CertificateManagerClient( + 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_dns_authorization( + certificate_manager.UpdateDnsAuthorizationRequest(), + dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_dns_authorization_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_dns_authorization), + '__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_dns_authorization( + dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].dns_authorization + mock_val = certificate_manager.DnsAuthorization(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_dns_authorization_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_dns_authorization( + certificate_manager.UpdateDnsAuthorizationRequest(), + dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.DeleteDnsAuthorizationRequest, + dict, +]) +def test_delete_dns_authorization(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_dns_authorization), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_dns_authorization(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.DeleteDnsAuthorizationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_dns_authorization_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 = CertificateManagerClient( + 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_dns_authorization), + '__call__') as call: + client.delete_dns_authorization() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.DeleteDnsAuthorizationRequest() + +@pytest.mark.asyncio +async def test_delete_dns_authorization_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.DeleteDnsAuthorizationRequest): + client = CertificateManagerAsyncClient( + 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_dns_authorization), + '__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_dns_authorization(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_manager.DeleteDnsAuthorizationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_dns_authorization_async_from_dict(): + await test_delete_dns_authorization_async(request_type=dict) + + +def test_delete_dns_authorization_field_headers(): + client = CertificateManagerClient( + 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 = certificate_manager.DeleteDnsAuthorizationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_dns_authorization), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_dns_authorization(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_dns_authorization_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_manager.DeleteDnsAuthorizationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_dns_authorization), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_dns_authorization(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_dns_authorization_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_dns_authorization), + '__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_dns_authorization( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_dns_authorization_flattened_error(): + client = CertificateManagerClient( + 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_dns_authorization( + certificate_manager.DeleteDnsAuthorizationRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_dns_authorization_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_dns_authorization), + '__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_dns_authorization( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_dns_authorization_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_dns_authorization( + certificate_manager.DeleteDnsAuthorizationRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_issuance_config.ListCertificateIssuanceConfigsRequest, + dict, +]) +def test_list_certificate_issuance_configs(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_issuance_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_certificate_issuance_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_issuance_config.ListCertificateIssuanceConfigsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateIssuanceConfigsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificate_issuance_configs_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 = CertificateManagerClient( + 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_certificate_issuance_configs), + '__call__') as call: + client.list_certificate_issuance_configs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_issuance_config.ListCertificateIssuanceConfigsRequest() + +@pytest.mark.asyncio +async def test_list_certificate_issuance_configs_async(transport: str = 'grpc_asyncio', request_type=certificate_issuance_config.ListCertificateIssuanceConfigsRequest): + client = CertificateManagerAsyncClient( + 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_certificate_issuance_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_certificate_issuance_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_issuance_config.ListCertificateIssuanceConfigsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateIssuanceConfigsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_certificate_issuance_configs_async_from_dict(): + await test_list_certificate_issuance_configs_async(request_type=dict) + + +def test_list_certificate_issuance_configs_field_headers(): + client = CertificateManagerClient( + 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 = certificate_issuance_config.ListCertificateIssuanceConfigsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_issuance_configs), + '__call__') as call: + call.return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() + client.list_certificate_issuance_configs(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_certificate_issuance_configs_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_issuance_config.ListCertificateIssuanceConfigsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_issuance_configs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_issuance_config.ListCertificateIssuanceConfigsResponse()) + await client.list_certificate_issuance_configs(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_certificate_issuance_configs_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_issuance_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_certificate_issuance_configs( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_certificate_issuance_configs_flattened_error(): + client = CertificateManagerClient( + 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_certificate_issuance_configs( + certificate_issuance_config.ListCertificateIssuanceConfigsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_certificate_issuance_configs_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_issuance_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_issuance_config.ListCertificateIssuanceConfigsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_certificate_issuance_configs( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_certificate_issuance_configs_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_issuance_configs( + certificate_issuance_config.ListCertificateIssuanceConfigsRequest(), + parent='parent_value', + ) + + +def test_list_certificate_issuance_configs_pager(transport_name: str = "grpc"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_issuance_configs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + ], + next_page_token='abc', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[], + next_page_token='def', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + ], + next_page_token='ghi', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_certificate_issuance_configs(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_issuance_config.CertificateIssuanceConfig) + for i in results) +def test_list_certificate_issuance_configs_pages(transport_name: str = "grpc"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_issuance_configs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + ], + next_page_token='abc', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[], + next_page_token='def', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + ], + next_page_token='ghi', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + ], + ), + RuntimeError, + ) + pages = list(client.list_certificate_issuance_configs(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_certificate_issuance_configs_async_pager(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_issuance_configs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + ], + next_page_token='abc', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[], + next_page_token='def', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + ], + next_page_token='ghi', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_certificate_issuance_configs(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, certificate_issuance_config.CertificateIssuanceConfig) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_certificate_issuance_configs_async_pages(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_certificate_issuance_configs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + ], + next_page_token='abc', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[], + next_page_token='def', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + ], + next_page_token='ghi', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_certificate_issuance_configs(request={})).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + certificate_issuance_config.GetCertificateIssuanceConfigRequest, + dict, +]) +def test_get_certificate_issuance_config(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_issuance_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_issuance_config.CertificateIssuanceConfig( + name='name_value', + description='description_value', + rotation_window_percentage=2788, + key_algorithm=certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048, + ) + response = client.get_certificate_issuance_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_issuance_config.GetCertificateIssuanceConfigRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_issuance_config.CertificateIssuanceConfig) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.rotation_window_percentage == 2788 + assert response.key_algorithm == certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048 + + +def test_get_certificate_issuance_config_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 = CertificateManagerClient( + 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_certificate_issuance_config), + '__call__') as call: + client.get_certificate_issuance_config() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_issuance_config.GetCertificateIssuanceConfigRequest() + +@pytest.mark.asyncio +async def test_get_certificate_issuance_config_async(transport: str = 'grpc_asyncio', request_type=certificate_issuance_config.GetCertificateIssuanceConfigRequest): + client = CertificateManagerAsyncClient( + 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_certificate_issuance_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_issuance_config.CertificateIssuanceConfig( + name='name_value', + description='description_value', + rotation_window_percentage=2788, + key_algorithm=certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048, + )) + response = await client.get_certificate_issuance_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_issuance_config.GetCertificateIssuanceConfigRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_issuance_config.CertificateIssuanceConfig) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.rotation_window_percentage == 2788 + assert response.key_algorithm == certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048 + + +@pytest.mark.asyncio +async def test_get_certificate_issuance_config_async_from_dict(): + await test_get_certificate_issuance_config_async(request_type=dict) + + +def test_get_certificate_issuance_config_field_headers(): + client = CertificateManagerClient( + 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 = certificate_issuance_config.GetCertificateIssuanceConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate_issuance_config), + '__call__') as call: + call.return_value = certificate_issuance_config.CertificateIssuanceConfig() + client.get_certificate_issuance_config(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_certificate_issuance_config_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_issuance_config.GetCertificateIssuanceConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate_issuance_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_issuance_config.CertificateIssuanceConfig()) + await client.get_certificate_issuance_config(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_certificate_issuance_config_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate_issuance_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_issuance_config.CertificateIssuanceConfig() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_certificate_issuance_config( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_certificate_issuance_config_flattened_error(): + client = CertificateManagerClient( + 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_certificate_issuance_config( + certificate_issuance_config.GetCertificateIssuanceConfigRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_certificate_issuance_config_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_certificate_issuance_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = certificate_issuance_config.CertificateIssuanceConfig() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_issuance_config.CertificateIssuanceConfig()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_certificate_issuance_config( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_certificate_issuance_config_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_issuance_config( + certificate_issuance_config.GetCertificateIssuanceConfigRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, + dict, +]) +def test_create_certificate_issuance_config(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_issuance_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_certificate_issuance_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_certificate_issuance_config_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 = CertificateManagerClient( + 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_certificate_issuance_config), + '__call__') as call: + client.create_certificate_issuance_config() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() + +@pytest.mark.asyncio +async def test_create_certificate_issuance_config_async(transport: str = 'grpc_asyncio', request_type=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest): + client = CertificateManagerAsyncClient( + 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_certificate_issuance_config), + '__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_certificate_issuance_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_certificate_issuance_config_async_from_dict(): + await test_create_certificate_issuance_config_async(request_type=dict) + + +def test_create_certificate_issuance_config_field_headers(): + client = CertificateManagerClient( + 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 = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate_issuance_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_certificate_issuance_config(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_certificate_issuance_config_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate_issuance_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_certificate_issuance_config(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_certificate_issuance_config_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate_issuance_config), + '__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_certificate_issuance_config( + parent='parent_value', + certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value'), + certificate_issuance_config_id='certificate_issuance_config_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].certificate_issuance_config + mock_val = gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value') + assert arg == mock_val + arg = args[0].certificate_issuance_config_id + mock_val = 'certificate_issuance_config_id_value' + assert arg == mock_val + + +def test_create_certificate_issuance_config_flattened_error(): + client = CertificateManagerClient( + 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_certificate_issuance_config( + gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest(), + parent='parent_value', + certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value'), + certificate_issuance_config_id='certificate_issuance_config_id_value', + ) + +@pytest.mark.asyncio +async def test_create_certificate_issuance_config_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_certificate_issuance_config), + '__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_certificate_issuance_config( + parent='parent_value', + certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value'), + certificate_issuance_config_id='certificate_issuance_config_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].certificate_issuance_config + mock_val = gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value') + assert arg == mock_val + arg = args[0].certificate_issuance_config_id + mock_val = 'certificate_issuance_config_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_certificate_issuance_config_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_issuance_config( + gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest(), + parent='parent_value', + certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value'), + certificate_issuance_config_id='certificate_issuance_config_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, + dict, +]) +def test_delete_certificate_issuance_config(request_type, transport: str = 'grpc'): + client = CertificateManagerClient( + 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_certificate_issuance_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_certificate_issuance_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_certificate_issuance_config_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 = CertificateManagerClient( + 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_certificate_issuance_config), + '__call__') as call: + client.delete_certificate_issuance_config() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() + +@pytest.mark.asyncio +async def test_delete_certificate_issuance_config_async(transport: str = 'grpc_asyncio', request_type=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest): + client = CertificateManagerAsyncClient( + 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_certificate_issuance_config), + '__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_certificate_issuance_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_certificate_issuance_config_async_from_dict(): + await test_delete_certificate_issuance_config_async(request_type=dict) + + +def test_delete_certificate_issuance_config_field_headers(): + client = CertificateManagerClient( + 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 = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate_issuance_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_certificate_issuance_config(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_certificate_issuance_config_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate_issuance_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_certificate_issuance_config(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_certificate_issuance_config_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate_issuance_config), + '__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_certificate_issuance_config( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_certificate_issuance_config_flattened_error(): + client = CertificateManagerClient( + 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_certificate_issuance_config( + certificate_issuance_config.DeleteCertificateIssuanceConfigRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_certificate_issuance_config_flattened_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_certificate_issuance_config), + '__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_certificate_issuance_config( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_certificate_issuance_config_flattened_error_async(): + client = CertificateManagerAsyncClient( + 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_certificate_issuance_config( + certificate_issuance_config.DeleteCertificateIssuanceConfigRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.ListCertificatesRequest, + dict, +]) +def test_list_certificates_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificatesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListCertificatesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_certificates(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificatesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificates_rest_required_fields(request_type=certificate_manager.ListCertificatesRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificates._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificates._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificatesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.ListCertificatesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_certificates(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_certificates_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_certificates._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_certificates_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_list_certificates") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_list_certificates") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.ListCertificatesRequest.pb(certificate_manager.ListCertificatesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_manager.ListCertificatesResponse.to_json(certificate_manager.ListCertificatesResponse()) + + request = certificate_manager.ListCertificatesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.ListCertificatesResponse() + + client.list_certificates(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_certificates_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.ListCertificatesRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_certificates(request) + + +def test_list_certificates_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificatesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListCertificatesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_certificates(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/certificates" % client.transport._host, args[1]) + + +def test_list_certificates_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_certificates( + certificate_manager.ListCertificatesRequest(), + parent='parent_value', + ) + + +def test_list_certificates_rest_pager(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + certificate_manager.Certificate(), + certificate_manager.Certificate(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + certificate_manager.Certificate(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(certificate_manager.ListCertificatesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_certificates(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_manager.Certificate) + for i in results) + + pages = list(client.list_certificates(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.GetCertificateRequest, + dict, +]) +def test_get_certificate_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificates/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.Certificate( + name='name_value', + description='description_value', + san_dnsnames=['san_dnsnames_value'], + pem_certificate='pem_certificate_value', + scope=certificate_manager.Certificate.Scope.EDGE_CACHE, + self_managed=certificate_manager.Certificate.SelfManagedCertificate(pem_certificate='pem_certificate_value'), + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.Certificate.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_certificate(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.Certificate) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.san_dnsnames == ['san_dnsnames_value'] + assert response.pem_certificate == 'pem_certificate_value' + assert response.scope == certificate_manager.Certificate.Scope.EDGE_CACHE + + +def test_get_certificate_rest_required_fields(request_type=certificate_manager.GetCertificateRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.Certificate() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.Certificate.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_certificate(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_certificate_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_certificate._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_certificate_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_get_certificate") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_get_certificate") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.GetCertificateRequest.pb(certificate_manager.GetCertificateRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_manager.Certificate.to_json(certificate_manager.Certificate()) + + request = certificate_manager.GetCertificateRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.Certificate() + + client.get_certificate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_certificate_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.GetCertificateRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificates/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_certificate(request) + + +def test_get_certificate_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.Certificate() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/certificates/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.Certificate.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_certificate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificates/*}" % client.transport._host, args[1]) + + +def test_get_certificate_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_certificate( + certificate_manager.GetCertificateRequest(), + name='name_value', + ) + + +def test_get_certificate_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.CreateCertificateRequest, + dict, +]) +def test_create_certificate_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["certificate"] = {'name': 'name_value', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'self_managed': {'pem_certificate': 'pem_certificate_value', 'pem_private_key': 'pem_private_key_value'}, 'managed': {'domains': ['domains_value1', 'domains_value2'], 'dns_authorizations': ['dns_authorizations_value1', 'dns_authorizations_value2'], 'issuance_config': 'issuance_config_value', 'state': 1, 'provisioning_issue': {'reason': 1, 'details': 'details_value'}, 'authorization_attempt_info': [{'domain': 'domain_value', 'state': 1, 'failure_reason': 1, 'details': 'details_value'}]}, 'san_dnsnames': ['san_dnsnames_value1', 'san_dnsnames_value2'], 'pem_certificate': 'pem_certificate_value', 'expire_time': {}, 'scope': 1} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.create_certificate(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_create_certificate_rest_required_fields(request_type=certificate_manager.CreateCertificateRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["certificate_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + assert "certificateId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "certificateId" in jsonified_request + assert jsonified_request["certificateId"] == request_init["certificate_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["certificateId"] = 'certificate_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("certificate_id", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + assert "certificateId" in jsonified_request + assert jsonified_request["certificateId"] == 'certificate_id_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.create_certificate(request) + + expected_params = [ + ( + "certificateId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_certificate_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_certificate._get_unset_required_fields({}) + assert set(unset_fields) == (set(("certificateId", )) & set(("parent", "certificateId", "certificate", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_certificate_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_create_certificate") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_create_certificate") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.CreateCertificateRequest.pb(certificate_manager.CreateCertificateRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_manager.CreateCertificateRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_certificate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_certificate_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.CreateCertificateRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["certificate"] = {'name': 'name_value', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'self_managed': {'pem_certificate': 'pem_certificate_value', 'pem_private_key': 'pem_private_key_value'}, 'managed': {'domains': ['domains_value1', 'domains_value2'], 'dns_authorizations': ['dns_authorizations_value1', 'dns_authorizations_value2'], 'issuance_config': 'issuance_config_value', 'state': 1, 'provisioning_issue': {'reason': 1, 'details': 'details_value'}, 'authorization_attempt_info': [{'domain': 'domain_value', 'state': 1, 'failure_reason': 1, 'details': 'details_value'}]}, 'san_dnsnames': ['san_dnsnames_value1', 'san_dnsnames_value2'], 'pem_certificate': 'pem_certificate_value', 'expire_time': {}, 'scope': 1} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_certificate(request) + + +def test_create_certificate_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + certificate=certificate_manager.Certificate(name='name_value'), + certificate_id='certificate_id_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.create_certificate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/certificates" % client.transport._host, args[1]) + + +def test_create_certificate_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_certificate( + certificate_manager.CreateCertificateRequest(), + parent='parent_value', + certificate=certificate_manager.Certificate(name='name_value'), + certificate_id='certificate_id_value', + ) + + +def test_create_certificate_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.UpdateCertificateRequest, + dict, +]) +def test_update_certificate_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'certificate': {'name': 'projects/sample1/locations/sample2/certificates/sample3'}} + request_init["certificate"] = {'name': 'projects/sample1/locations/sample2/certificates/sample3', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'self_managed': {'pem_certificate': 'pem_certificate_value', 'pem_private_key': 'pem_private_key_value'}, 'managed': {'domains': ['domains_value1', 'domains_value2'], 'dns_authorizations': ['dns_authorizations_value1', 'dns_authorizations_value2'], 'issuance_config': 'issuance_config_value', 'state': 1, 'provisioning_issue': {'reason': 1, 'details': 'details_value'}, 'authorization_attempt_info': [{'domain': 'domain_value', 'state': 1, 'failure_reason': 1, 'details': 'details_value'}]}, 'san_dnsnames': ['san_dnsnames_value1', 'san_dnsnames_value2'], 'pem_certificate': 'pem_certificate_value', 'expire_time': {}, 'scope': 1} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.update_certificate(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_update_certificate_rest_required_fields(request_type=certificate_manager.UpdateCertificateRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_certificate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_certificate._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.update_certificate(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_certificate_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_certificate._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("certificate", "updateMask", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_certificate_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_update_certificate") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_update_certificate") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.UpdateCertificateRequest.pb(certificate_manager.UpdateCertificateRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_manager.UpdateCertificateRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.update_certificate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_certificate_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.UpdateCertificateRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'certificate': {'name': 'projects/sample1/locations/sample2/certificates/sample3'}} + request_init["certificate"] = {'name': 'projects/sample1/locations/sample2/certificates/sample3', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'self_managed': {'pem_certificate': 'pem_certificate_value', 'pem_private_key': 'pem_private_key_value'}, 'managed': {'domains': ['domains_value1', 'domains_value2'], 'dns_authorizations': ['dns_authorizations_value1', 'dns_authorizations_value2'], 'issuance_config': 'issuance_config_value', 'state': 1, 'provisioning_issue': {'reason': 1, 'details': 'details_value'}, 'authorization_attempt_info': [{'domain': 'domain_value', 'state': 1, 'failure_reason': 1, 'details': 'details_value'}]}, 'san_dnsnames': ['san_dnsnames_value1', 'san_dnsnames_value2'], 'pem_certificate': 'pem_certificate_value', 'expire_time': {}, 'scope': 1} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_certificate(request) + + +def test_update_certificate_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'certificate': {'name': 'projects/sample1/locations/sample2/certificates/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + certificate=certificate_manager.Certificate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.update_certificate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{certificate.name=projects/*/locations/*/certificates/*}" % client.transport._host, args[1]) + + +def test_update_certificate_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_certificate( + certificate_manager.UpdateCertificateRequest(), + certificate=certificate_manager.Certificate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_certificate_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.DeleteCertificateRequest, + dict, +]) +def test_delete_certificate_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificates/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_certificate(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_delete_certificate_rest_required_fields(request_type=certificate_manager.DeleteCertificateRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_certificate(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_certificate_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_certificate._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_certificate_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_delete_certificate") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_delete_certificate") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.DeleteCertificateRequest.pb(certificate_manager.DeleteCertificateRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_manager.DeleteCertificateRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.delete_certificate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_certificate_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.DeleteCertificateRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificates/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_certificate(request) + + +def test_delete_certificate_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/certificates/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_certificate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificates/*}" % client.transport._host, args[1]) + + +def test_delete_certificate_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_certificate( + certificate_manager.DeleteCertificateRequest(), + name='name_value', + ) + + +def test_delete_certificate_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.ListCertificateMapsRequest, + dict, +]) +def test_list_certificate_maps_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificateMapsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListCertificateMapsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_certificate_maps(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateMapsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificate_maps_rest_required_fields(request_type=certificate_manager.ListCertificateMapsRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificate_maps._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificate_maps._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificateMapsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.ListCertificateMapsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_certificate_maps(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_certificate_maps_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_certificate_maps._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_certificate_maps_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_list_certificate_maps") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_list_certificate_maps") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.ListCertificateMapsRequest.pb(certificate_manager.ListCertificateMapsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_manager.ListCertificateMapsResponse.to_json(certificate_manager.ListCertificateMapsResponse()) + + request = certificate_manager.ListCertificateMapsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.ListCertificateMapsResponse() + + client.list_certificate_maps(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_certificate_maps_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.ListCertificateMapsRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_certificate_maps(request) + + +def test_list_certificate_maps_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificateMapsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListCertificateMapsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_certificate_maps(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/certificateMaps" % client.transport._host, args[1]) + + +def test_list_certificate_maps_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_certificate_maps( + certificate_manager.ListCertificateMapsRequest(), + parent='parent_value', + ) + + +def test_list_certificate_maps_rest_pager(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[], + next_page_token='def', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(certificate_manager.ListCertificateMapsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_certificate_maps(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_manager.CertificateMap) + for i in results) + + pages = list(client.list_certificate_maps(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.GetCertificateMapRequest, + dict, +]) +def test_get_certificate_map_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.CertificateMap( + name='name_value', + description='description_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.CertificateMap.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_certificate_map(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.CertificateMap) + assert response.name == 'name_value' + assert response.description == 'description_value' + + +def test_get_certificate_map_rest_required_fields(request_type=certificate_manager.GetCertificateMapRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate_map._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate_map._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.CertificateMap() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.CertificateMap.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_certificate_map(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_certificate_map_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_certificate_map._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_certificate_map_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_get_certificate_map") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_get_certificate_map") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.GetCertificateMapRequest.pb(certificate_manager.GetCertificateMapRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_manager.CertificateMap.to_json(certificate_manager.CertificateMap()) + + request = certificate_manager.GetCertificateMapRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.CertificateMap() + + client.get_certificate_map(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_certificate_map_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.GetCertificateMapRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_certificate_map(request) + + +def test_get_certificate_map_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.CertificateMap() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.CertificateMap.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_certificate_map(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificateMaps/*}" % client.transport._host, args[1]) + + +def test_get_certificate_map_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_certificate_map( + certificate_manager.GetCertificateMapRequest(), + name='name_value', + ) + + +def test_get_certificate_map_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.CreateCertificateMapRequest, + dict, +]) +def test_create_certificate_map_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["certificate_map"] = {'name': 'name_value', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'gclb_targets': [{'target_https_proxy': 'target_https_proxy_value', 'target_ssl_proxy': 'target_ssl_proxy_value', 'ip_configs': [{'ip_address': 'ip_address_value', 'ports': [569, 570]}]}]} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.create_certificate_map(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_create_certificate_map_rest_required_fields(request_type=certificate_manager.CreateCertificateMapRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["certificate_map_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + assert "certificateMapId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate_map._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "certificateMapId" in jsonified_request + assert jsonified_request["certificateMapId"] == request_init["certificate_map_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["certificateMapId"] = 'certificate_map_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate_map._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("certificate_map_id", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + assert "certificateMapId" in jsonified_request + assert jsonified_request["certificateMapId"] == 'certificate_map_id_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.create_certificate_map(request) + + expected_params = [ + ( + "certificateMapId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_certificate_map_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_certificate_map._get_unset_required_fields({}) + assert set(unset_fields) == (set(("certificateMapId", )) & set(("parent", "certificateMapId", "certificateMap", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_certificate_map_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_create_certificate_map") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_create_certificate_map") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.CreateCertificateMapRequest.pb(certificate_manager.CreateCertificateMapRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_manager.CreateCertificateMapRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_certificate_map(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_certificate_map_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.CreateCertificateMapRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["certificate_map"] = {'name': 'name_value', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'gclb_targets': [{'target_https_proxy': 'target_https_proxy_value', 'target_ssl_proxy': 'target_ssl_proxy_value', 'ip_configs': [{'ip_address': 'ip_address_value', 'ports': [569, 570]}]}]} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_certificate_map(request) + + +def test_create_certificate_map_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + certificate_map=certificate_manager.CertificateMap(name='name_value'), + certificate_map_id='certificate_map_id_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.create_certificate_map(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/certificateMaps" % client.transport._host, args[1]) + + +def test_create_certificate_map_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_certificate_map( + certificate_manager.CreateCertificateMapRequest(), + parent='parent_value', + certificate_map=certificate_manager.CertificateMap(name='name_value'), + certificate_map_id='certificate_map_id_value', + ) + + +def test_create_certificate_map_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.UpdateCertificateMapRequest, + dict, +]) +def test_update_certificate_map_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'certificate_map': {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'}} + request_init["certificate_map"] = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'gclb_targets': [{'target_https_proxy': 'target_https_proxy_value', 'target_ssl_proxy': 'target_ssl_proxy_value', 'ip_configs': [{'ip_address': 'ip_address_value', 'ports': [569, 570]}]}]} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.update_certificate_map(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_update_certificate_map_rest_required_fields(request_type=certificate_manager.UpdateCertificateMapRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_certificate_map._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_certificate_map._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.update_certificate_map(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_certificate_map_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_certificate_map._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("certificateMap", "updateMask", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_certificate_map_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_update_certificate_map") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_update_certificate_map") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.UpdateCertificateMapRequest.pb(certificate_manager.UpdateCertificateMapRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_manager.UpdateCertificateMapRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.update_certificate_map(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_certificate_map_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.UpdateCertificateMapRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'certificate_map': {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'}} + request_init["certificate_map"] = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'gclb_targets': [{'target_https_proxy': 'target_https_proxy_value', 'target_ssl_proxy': 'target_ssl_proxy_value', 'ip_configs': [{'ip_address': 'ip_address_value', 'ports': [569, 570]}]}]} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_certificate_map(request) + + +def test_update_certificate_map_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'certificate_map': {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + certificate_map=certificate_manager.CertificateMap(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.update_certificate_map(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{certificate_map.name=projects/*/locations/*/certificateMaps/*}" % client.transport._host, args[1]) + + +def test_update_certificate_map_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_certificate_map( + certificate_manager.UpdateCertificateMapRequest(), + certificate_map=certificate_manager.CertificateMap(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_certificate_map_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.DeleteCertificateMapRequest, + dict, +]) +def test_delete_certificate_map_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_certificate_map(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_delete_certificate_map_rest_required_fields(request_type=certificate_manager.DeleteCertificateMapRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate_map._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate_map._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_certificate_map(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_certificate_map_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_certificate_map._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_certificate_map_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_delete_certificate_map") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_delete_certificate_map") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.DeleteCertificateMapRequest.pb(certificate_manager.DeleteCertificateMapRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_manager.DeleteCertificateMapRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.delete_certificate_map(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_certificate_map_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.DeleteCertificateMapRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_certificate_map(request) + + +def test_delete_certificate_map_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_certificate_map(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificateMaps/*}" % client.transport._host, args[1]) + + +def test_delete_certificate_map_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_certificate_map( + certificate_manager.DeleteCertificateMapRequest(), + name='name_value', + ) + + +def test_delete_certificate_map_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.ListCertificateMapEntriesRequest, + dict, +]) +def test_list_certificate_map_entries_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificateMapEntriesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListCertificateMapEntriesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_certificate_map_entries(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateMapEntriesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificate_map_entries_rest_required_fields(request_type=certificate_manager.ListCertificateMapEntriesRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificate_map_entries._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificate_map_entries._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificateMapEntriesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.ListCertificateMapEntriesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_certificate_map_entries(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_certificate_map_entries_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_certificate_map_entries._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_certificate_map_entries_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_list_certificate_map_entries") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_list_certificate_map_entries") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.ListCertificateMapEntriesRequest.pb(certificate_manager.ListCertificateMapEntriesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_manager.ListCertificateMapEntriesResponse.to_json(certificate_manager.ListCertificateMapEntriesResponse()) + + request = certificate_manager.ListCertificateMapEntriesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.ListCertificateMapEntriesResponse() + + client.list_certificate_map_entries(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_certificate_map_entries_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.ListCertificateMapEntriesRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_certificate_map_entries(request) + + +def test_list_certificate_map_entries_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificateMapEntriesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListCertificateMapEntriesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_certificate_map_entries(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*/certificateMaps/*}/certificateMapEntries" % client.transport._host, args[1]) + + +def test_list_certificate_map_entries_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_certificate_map_entries( + certificate_manager.ListCertificateMapEntriesRequest(), + parent='parent_value', + ) + + +def test_list_certificate_map_entries_rest_pager(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + ], + next_page_token='abc', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[], + next_page_token='def', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + ], + next_page_token='ghi', + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(certificate_manager.ListCertificateMapEntriesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + + pager = client.list_certificate_map_entries(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_manager.CertificateMapEntry) + for i in results) + + pages = list(client.list_certificate_map_entries(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.GetCertificateMapEntryRequest, + dict, +]) +def test_get_certificate_map_entry_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.CertificateMapEntry( + name='name_value', + description='description_value', + certificates=['certificates_value'], + state=certificate_manager.ServingState.ACTIVE, + hostname='hostname_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.CertificateMapEntry.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_certificate_map_entry(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.CertificateMapEntry) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.certificates == ['certificates_value'] + assert response.state == certificate_manager.ServingState.ACTIVE + + +def test_get_certificate_map_entry_rest_required_fields(request_type=certificate_manager.GetCertificateMapEntryRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate_map_entry._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate_map_entry._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.CertificateMapEntry() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.CertificateMapEntry.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_certificate_map_entry(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_certificate_map_entry_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_certificate_map_entry._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_certificate_map_entry_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_get_certificate_map_entry") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_get_certificate_map_entry") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.GetCertificateMapEntryRequest.pb(certificate_manager.GetCertificateMapEntryRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_manager.CertificateMapEntry.to_json(certificate_manager.CertificateMapEntry()) + + request = certificate_manager.GetCertificateMapEntryRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.CertificateMapEntry() + + client.get_certificate_map_entry(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_certificate_map_entry_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.GetCertificateMapEntryRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_certificate_map_entry(request) + + +def test_get_certificate_map_entry_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.CertificateMapEntry() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.CertificateMapEntry.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_certificate_map_entry(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}" % client.transport._host, args[1]) + + +def test_get_certificate_map_entry_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_certificate_map_entry( + certificate_manager.GetCertificateMapEntryRequest(), + name='name_value', + ) + + +def test_get_certificate_map_entry_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.CreateCertificateMapEntryRequest, + dict, +]) +def test_create_certificate_map_entry_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + request_init["certificate_map_entry"] = {'name': 'name_value', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'hostname': 'hostname_value', 'matcher': 1, 'certificates': ['certificates_value1', 'certificates_value2'], 'state': 1} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.create_certificate_map_entry(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_create_certificate_map_entry_rest_required_fields(request_type=certificate_manager.CreateCertificateMapEntryRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["certificate_map_entry_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + assert "certificateMapEntryId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate_map_entry._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "certificateMapEntryId" in jsonified_request + assert jsonified_request["certificateMapEntryId"] == request_init["certificate_map_entry_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["certificateMapEntryId"] = 'certificate_map_entry_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate_map_entry._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("certificate_map_entry_id", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + assert "certificateMapEntryId" in jsonified_request + assert jsonified_request["certificateMapEntryId"] == 'certificate_map_entry_id_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.create_certificate_map_entry(request) + + expected_params = [ + ( + "certificateMapEntryId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_certificate_map_entry_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_certificate_map_entry._get_unset_required_fields({}) + assert set(unset_fields) == (set(("certificateMapEntryId", )) & set(("parent", "certificateMapEntryId", "certificateMapEntry", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_certificate_map_entry_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_create_certificate_map_entry") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_create_certificate_map_entry") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.CreateCertificateMapEntryRequest.pb(certificate_manager.CreateCertificateMapEntryRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_manager.CreateCertificateMapEntryRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_certificate_map_entry(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_certificate_map_entry_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.CreateCertificateMapEntryRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + request_init["certificate_map_entry"] = {'name': 'name_value', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'hostname': 'hostname_value', 'matcher': 1, 'certificates': ['certificates_value1', 'certificates_value2'], 'state': 1} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_certificate_map_entry(request) + + +def test_create_certificate_map_entry_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), + certificate_map_entry_id='certificate_map_entry_id_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.create_certificate_map_entry(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*/certificateMaps/*}/certificateMapEntries" % client.transport._host, args[1]) + + +def test_create_certificate_map_entry_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_certificate_map_entry( + certificate_manager.CreateCertificateMapEntryRequest(), + parent='parent_value', + certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), + certificate_map_entry_id='certificate_map_entry_id_value', + ) + + +def test_create_certificate_map_entry_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.UpdateCertificateMapEntryRequest, + dict, +]) +def test_update_certificate_map_entry_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'certificate_map_entry': {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'}} + request_init["certificate_map_entry"] = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'hostname': 'hostname_value', 'matcher': 1, 'certificates': ['certificates_value1', 'certificates_value2'], 'state': 1} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.update_certificate_map_entry(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_update_certificate_map_entry_rest_required_fields(request_type=certificate_manager.UpdateCertificateMapEntryRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_certificate_map_entry._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_certificate_map_entry._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.update_certificate_map_entry(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_certificate_map_entry_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_certificate_map_entry._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("certificateMapEntry", "updateMask", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_certificate_map_entry_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_update_certificate_map_entry") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_update_certificate_map_entry") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.UpdateCertificateMapEntryRequest.pb(certificate_manager.UpdateCertificateMapEntryRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_manager.UpdateCertificateMapEntryRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.update_certificate_map_entry(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_certificate_map_entry_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.UpdateCertificateMapEntryRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'certificate_map_entry': {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'}} + request_init["certificate_map_entry"] = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'hostname': 'hostname_value', 'matcher': 1, 'certificates': ['certificates_value1', 'certificates_value2'], 'state': 1} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_certificate_map_entry(request) + + +def test_update_certificate_map_entry_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'certificate_map_entry': {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'}} + + # get truthy value for each flattened field + mock_args = dict( + certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.update_certificate_map_entry(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{certificate_map_entry.name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}" % client.transport._host, args[1]) + + +def test_update_certificate_map_entry_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_certificate_map_entry( + certificate_manager.UpdateCertificateMapEntryRequest(), + certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_certificate_map_entry_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.DeleteCertificateMapEntryRequest, + dict, +]) +def test_delete_certificate_map_entry_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_certificate_map_entry(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_delete_certificate_map_entry_rest_required_fields(request_type=certificate_manager.DeleteCertificateMapEntryRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate_map_entry._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate_map_entry._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_certificate_map_entry(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_certificate_map_entry_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_certificate_map_entry._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_certificate_map_entry_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_delete_certificate_map_entry") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_delete_certificate_map_entry") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.DeleteCertificateMapEntryRequest.pb(certificate_manager.DeleteCertificateMapEntryRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_manager.DeleteCertificateMapEntryRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.delete_certificate_map_entry(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_certificate_map_entry_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.DeleteCertificateMapEntryRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_certificate_map_entry(request) + + +def test_delete_certificate_map_entry_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_certificate_map_entry(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}" % client.transport._host, args[1]) + + +def test_delete_certificate_map_entry_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_certificate_map_entry( + certificate_manager.DeleteCertificateMapEntryRequest(), + name='name_value', + ) + + +def test_delete_certificate_map_entry_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.ListDnsAuthorizationsRequest, + dict, +]) +def test_list_dns_authorizations_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListDnsAuthorizationsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListDnsAuthorizationsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_dns_authorizations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDnsAuthorizationsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_dns_authorizations_rest_required_fields(request_type=certificate_manager.ListDnsAuthorizationsRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_dns_authorizations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_dns_authorizations._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListDnsAuthorizationsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.ListDnsAuthorizationsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_dns_authorizations(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_dns_authorizations_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_dns_authorizations._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_dns_authorizations_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_list_dns_authorizations") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_list_dns_authorizations") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.ListDnsAuthorizationsRequest.pb(certificate_manager.ListDnsAuthorizationsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_manager.ListDnsAuthorizationsResponse.to_json(certificate_manager.ListDnsAuthorizationsResponse()) + + request = certificate_manager.ListDnsAuthorizationsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.ListDnsAuthorizationsResponse() + + client.list_dns_authorizations(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_dns_authorizations_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.ListDnsAuthorizationsRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_dns_authorizations(request) + + +def test_list_dns_authorizations_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListDnsAuthorizationsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListDnsAuthorizationsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_dns_authorizations(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/dnsAuthorizations" % client.transport._host, args[1]) + + +def test_list_dns_authorizations_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_dns_authorizations( + certificate_manager.ListDnsAuthorizationsRequest(), + parent='parent_value', + ) + + +def test_list_dns_authorizations_rest_pager(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + ], + next_page_token='abc', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[], + next_page_token='def', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + ], + next_page_token='ghi', + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(certificate_manager.ListDnsAuthorizationsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_dns_authorizations(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_manager.DnsAuthorization) + for i in results) + + pages = list(client.list_dns_authorizations(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.GetDnsAuthorizationRequest, + dict, +]) +def test_get_dns_authorization_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.DnsAuthorization( + name='name_value', + description='description_value', + domain='domain_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.DnsAuthorization.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_dns_authorization(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.DnsAuthorization) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.domain == 'domain_value' + + +def test_get_dns_authorization_rest_required_fields(request_type=certificate_manager.GetDnsAuthorizationRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_dns_authorization._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_dns_authorization._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.DnsAuthorization() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.DnsAuthorization.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_dns_authorization(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_dns_authorization_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_dns_authorization._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_dns_authorization_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_get_dns_authorization") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_get_dns_authorization") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.GetDnsAuthorizationRequest.pb(certificate_manager.GetDnsAuthorizationRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_manager.DnsAuthorization.to_json(certificate_manager.DnsAuthorization()) + + request = certificate_manager.GetDnsAuthorizationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.DnsAuthorization() + + client.get_dns_authorization(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_dns_authorization_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.GetDnsAuthorizationRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_dns_authorization(request) + + +def test_get_dns_authorization_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.DnsAuthorization() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.DnsAuthorization.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_dns_authorization(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/dnsAuthorizations/*}" % client.transport._host, args[1]) + + +def test_get_dns_authorization_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_dns_authorization( + certificate_manager.GetDnsAuthorizationRequest(), + name='name_value', + ) + + +def test_get_dns_authorization_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.CreateDnsAuthorizationRequest, + dict, +]) +def test_create_dns_authorization_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["dns_authorization"] = {'name': 'name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'description': 'description_value', 'domain': 'domain_value', 'dns_resource_record': {'name': 'name_value', 'type_': 'type__value', 'data': 'data_value'}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.create_dns_authorization(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_create_dns_authorization_rest_required_fields(request_type=certificate_manager.CreateDnsAuthorizationRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["dns_authorization_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + assert "dnsAuthorizationId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_dns_authorization._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "dnsAuthorizationId" in jsonified_request + assert jsonified_request["dnsAuthorizationId"] == request_init["dns_authorization_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["dnsAuthorizationId"] = 'dns_authorization_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_dns_authorization._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("dns_authorization_id", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + assert "dnsAuthorizationId" in jsonified_request + assert jsonified_request["dnsAuthorizationId"] == 'dns_authorization_id_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.create_dns_authorization(request) + + expected_params = [ + ( + "dnsAuthorizationId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_dns_authorization_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_dns_authorization._get_unset_required_fields({}) + assert set(unset_fields) == (set(("dnsAuthorizationId", )) & set(("parent", "dnsAuthorizationId", "dnsAuthorization", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_dns_authorization_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_create_dns_authorization") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_create_dns_authorization") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.CreateDnsAuthorizationRequest.pb(certificate_manager.CreateDnsAuthorizationRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_manager.CreateDnsAuthorizationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_dns_authorization(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_dns_authorization_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.CreateDnsAuthorizationRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["dns_authorization"] = {'name': 'name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'description': 'description_value', 'domain': 'domain_value', 'dns_resource_record': {'name': 'name_value', 'type_': 'type__value', 'data': 'data_value'}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_dns_authorization(request) + + +def test_create_dns_authorization_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), + dns_authorization_id='dns_authorization_id_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.create_dns_authorization(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/dnsAuthorizations" % client.transport._host, args[1]) + + +def test_create_dns_authorization_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_dns_authorization( + certificate_manager.CreateDnsAuthorizationRequest(), + parent='parent_value', + dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), + dns_authorization_id='dns_authorization_id_value', + ) + + +def test_create_dns_authorization_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.UpdateDnsAuthorizationRequest, + dict, +]) +def test_update_dns_authorization_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'dns_authorization': {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'}} + request_init["dns_authorization"] = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'description': 'description_value', 'domain': 'domain_value', 'dns_resource_record': {'name': 'name_value', 'type_': 'type__value', 'data': 'data_value'}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.update_dns_authorization(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_update_dns_authorization_rest_required_fields(request_type=certificate_manager.UpdateDnsAuthorizationRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_dns_authorization._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_dns_authorization._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.update_dns_authorization(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_dns_authorization_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_dns_authorization._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("dnsAuthorization", "updateMask", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_dns_authorization_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_update_dns_authorization") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_update_dns_authorization") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.UpdateDnsAuthorizationRequest.pb(certificate_manager.UpdateDnsAuthorizationRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_manager.UpdateDnsAuthorizationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.update_dns_authorization(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_dns_authorization_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.UpdateDnsAuthorizationRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'dns_authorization': {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'}} + request_init["dns_authorization"] = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'description': 'description_value', 'domain': 'domain_value', 'dns_resource_record': {'name': 'name_value', 'type_': 'type__value', 'data': 'data_value'}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_dns_authorization(request) + + +def test_update_dns_authorization_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'dns_authorization': {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.update_dns_authorization(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{dns_authorization.name=projects/*/locations/*/dnsAuthorizations/*}" % client.transport._host, args[1]) + + +def test_update_dns_authorization_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_dns_authorization( + certificate_manager.UpdateDnsAuthorizationRequest(), + dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_dns_authorization_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_manager.DeleteDnsAuthorizationRequest, + dict, +]) +def test_delete_dns_authorization_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_dns_authorization(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_delete_dns_authorization_rest_required_fields(request_type=certificate_manager.DeleteDnsAuthorizationRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_dns_authorization._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_dns_authorization._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_dns_authorization(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_dns_authorization_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_dns_authorization._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_dns_authorization_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_delete_dns_authorization") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_delete_dns_authorization") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.DeleteDnsAuthorizationRequest.pb(certificate_manager.DeleteDnsAuthorizationRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_manager.DeleteDnsAuthorizationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.delete_dns_authorization(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_dns_authorization_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.DeleteDnsAuthorizationRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_dns_authorization(request) + + +def test_delete_dns_authorization_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_dns_authorization(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/dnsAuthorizations/*}" % client.transport._host, args[1]) + + +def test_delete_dns_authorization_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_dns_authorization( + certificate_manager.DeleteDnsAuthorizationRequest(), + name='name_value', + ) + + +def test_delete_dns_authorization_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_issuance_config.ListCertificateIssuanceConfigsRequest, + dict, +]) +def test_list_certificate_issuance_configs_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_certificate_issuance_configs(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateIssuanceConfigsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificate_issuance_configs_rest_required_fields(request_type=certificate_issuance_config.ListCertificateIssuanceConfigsRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificate_issuance_configs._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificate_issuance_configs._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_certificate_issuance_configs(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_certificate_issuance_configs_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_certificate_issuance_configs._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_certificate_issuance_configs_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_list_certificate_issuance_configs") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_list_certificate_issuance_configs") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_issuance_config.ListCertificateIssuanceConfigsRequest.pb(certificate_issuance_config.ListCertificateIssuanceConfigsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_issuance_config.ListCertificateIssuanceConfigsResponse.to_json(certificate_issuance_config.ListCertificateIssuanceConfigsResponse()) + + request = certificate_issuance_config.ListCertificateIssuanceConfigsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() + + client.list_certificate_issuance_configs(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_certificate_issuance_configs_rest_bad_request(transport: str = 'rest', request_type=certificate_issuance_config.ListCertificateIssuanceConfigsRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_certificate_issuance_configs(request) + + +def test_list_certificate_issuance_configs_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_certificate_issuance_configs(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/certificateIssuanceConfigs" % client.transport._host, args[1]) + + +def test_list_certificate_issuance_configs_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_certificate_issuance_configs( + certificate_issuance_config.ListCertificateIssuanceConfigsRequest(), + parent='parent_value', + ) + + +def test_list_certificate_issuance_configs_rest_pager(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + ], + next_page_token='abc', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[], + next_page_token='def', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + ], + next_page_token='ghi', + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(certificate_issuance_config.ListCertificateIssuanceConfigsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_certificate_issuance_configs(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_issuance_config.CertificateIssuanceConfig) + for i in results) + + pages = list(client.list_certificate_issuance_configs(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + certificate_issuance_config.GetCertificateIssuanceConfigRequest, + dict, +]) +def test_get_certificate_issuance_config_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_issuance_config.CertificateIssuanceConfig( + name='name_value', + description='description_value', + rotation_window_percentage=2788, + key_algorithm=certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048, + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_issuance_config.CertificateIssuanceConfig.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_certificate_issuance_config(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_issuance_config.CertificateIssuanceConfig) + assert response.name == 'name_value' + assert response.description == 'description_value' + assert response.rotation_window_percentage == 2788 + assert response.key_algorithm == certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048 + + +def test_get_certificate_issuance_config_rest_required_fields(request_type=certificate_issuance_config.GetCertificateIssuanceConfigRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate_issuance_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate_issuance_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_issuance_config.CertificateIssuanceConfig() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_issuance_config.CertificateIssuanceConfig.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_certificate_issuance_config(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_certificate_issuance_config_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_certificate_issuance_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_certificate_issuance_config_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_get_certificate_issuance_config") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_get_certificate_issuance_config") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_issuance_config.GetCertificateIssuanceConfigRequest.pb(certificate_issuance_config.GetCertificateIssuanceConfigRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_issuance_config.CertificateIssuanceConfig.to_json(certificate_issuance_config.CertificateIssuanceConfig()) + + request = certificate_issuance_config.GetCertificateIssuanceConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_issuance_config.CertificateIssuanceConfig() + + client.get_certificate_issuance_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_certificate_issuance_config_rest_bad_request(transport: str = 'rest', request_type=certificate_issuance_config.GetCertificateIssuanceConfigRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_certificate_issuance_config(request) + + +def test_get_certificate_issuance_config_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = certificate_issuance_config.CertificateIssuanceConfig() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_issuance_config.CertificateIssuanceConfig.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_certificate_issuance_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificateIssuanceConfigs/*}" % client.transport._host, args[1]) + + +def test_get_certificate_issuance_config_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_certificate_issuance_config( + certificate_issuance_config.GetCertificateIssuanceConfigRequest(), + name='name_value', + ) + + +def test_get_certificate_issuance_config_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, + dict, +]) +def test_create_certificate_issuance_config_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["certificate_issuance_config"] = {'name': 'name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'description': 'description_value', 'certificate_authority_config': {'certificate_authority_service_config': {'ca_pool': 'ca_pool_value'}}, 'lifetime': {'seconds': 751, 'nanos': 543}, 'rotation_window_percentage': 2788, 'key_algorithm': 1} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.create_certificate_issuance_config(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_create_certificate_issuance_config_rest_required_fields(request_type=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["certificate_issuance_config_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + assert "certificateIssuanceConfigId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate_issuance_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "certificateIssuanceConfigId" in jsonified_request + assert jsonified_request["certificateIssuanceConfigId"] == request_init["certificate_issuance_config_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["certificateIssuanceConfigId"] = 'certificate_issuance_config_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate_issuance_config._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("certificate_issuance_config_id", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + assert "certificateIssuanceConfigId" in jsonified_request + assert jsonified_request["certificateIssuanceConfigId"] == 'certificate_issuance_config_id_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.create_certificate_issuance_config(request) + + expected_params = [ + ( + "certificateIssuanceConfigId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_certificate_issuance_config_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_certificate_issuance_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(("certificateIssuanceConfigId", )) & set(("parent", "certificateIssuanceConfigId", "certificateIssuanceConfig", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_certificate_issuance_config_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_create_certificate_issuance_config") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_create_certificate_issuance_config") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest.pb(gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_certificate_issuance_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_certificate_issuance_config_rest_bad_request(transport: str = 'rest', request_type=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["certificate_issuance_config"] = {'name': 'name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'description': 'description_value', 'certificate_authority_config': {'certificate_authority_service_config': {'ca_pool': 'ca_pool_value'}}, 'lifetime': {'seconds': 751, 'nanos': 543}, 'rotation_window_percentage': 2788, 'key_algorithm': 1} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_certificate_issuance_config(request) + + +def test_create_certificate_issuance_config_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value'), + certificate_issuance_config_id='certificate_issuance_config_id_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.create_certificate_issuance_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/certificateIssuanceConfigs" % client.transport._host, args[1]) + + +def test_create_certificate_issuance_config_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_certificate_issuance_config( + gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest(), + parent='parent_value', + certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value'), + certificate_issuance_config_id='certificate_issuance_config_id_value', + ) + + +def test_create_certificate_issuance_config_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, + dict, +]) +def test_delete_certificate_issuance_config_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_certificate_issuance_config(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_delete_certificate_issuance_config_rest_required_fields(request_type=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate_issuance_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate_issuance_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_certificate_issuance_config(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_certificate_issuance_config_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_certificate_issuance_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_certificate_issuance_config_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "post_delete_certificate_issuance_config") as post, \ + mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_delete_certificate_issuance_config") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest.pb(certificate_issuance_config.DeleteCertificateIssuanceConfigRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.delete_certificate_issuance_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_certificate_issuance_config_rest_bad_request(transport: str = 'rest', request_type=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_certificate_issuance_config(request) + + +def test_delete_certificate_issuance_config_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_certificate_issuance_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificateIssuanceConfigs/*}" % client.transport._host, args[1]) + + +def test_delete_certificate_issuance_config_rest_flattened_error(transport: str = 'rest'): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_certificate_issuance_config( + certificate_issuance_config.DeleteCertificateIssuanceConfigRequest(), + name='name_value', + ) + + +def test_delete_certificate_issuance_config_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.CertificateManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.CertificateManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CertificateManagerClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.CertificateManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CertificateManagerClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CertificateManagerClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.CertificateManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CertificateManagerClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.CertificateManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = CertificateManagerClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.CertificateManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.CertificateManagerGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.CertificateManagerGrpcTransport, + transports.CertificateManagerGrpcAsyncIOTransport, + transports.CertificateManagerRestTransport, +]) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + +@pytest.mark.parametrize("transport_name", [ + "grpc", + "rest", +]) +def test_transport_kind(transport_name): + transport = CertificateManagerClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CertificateManagerGrpcTransport, + ) + +def test_certificate_manager_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.CertificateManagerTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_certificate_manager_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.certificate_manager_v1.services.certificate_manager.transports.CertificateManagerTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.CertificateManagerTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'list_certificates', + 'get_certificate', + 'create_certificate', + 'update_certificate', + 'delete_certificate', + 'list_certificate_maps', + 'get_certificate_map', + 'create_certificate_map', + 'update_certificate_map', + 'delete_certificate_map', + 'list_certificate_map_entries', + 'get_certificate_map_entry', + 'create_certificate_map_entry', + 'update_certificate_map_entry', + 'delete_certificate_map_entry', + 'list_dns_authorizations', + 'get_dns_authorization', + 'create_dns_authorization', + 'update_dns_authorization', + 'delete_dns_authorization', + 'list_certificate_issuance_configs', + 'get_certificate_issuance_config', + 'create_certificate_issuance_config', + 'delete_certificate_issuance_config', + 'get_location', + 'list_locations', + 'get_operation', + 'cancel_operation', + 'delete_operation', + 'list_operations', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + with pytest.raises(NotImplementedError): + transport.close() + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + # Catch all for all remaining methods and properties + remainder = [ + 'kind', + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + + +def test_certificate_manager_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.certificate_manager_v1.services.certificate_manager.transports.CertificateManagerTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CertificateManagerTransport( + 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", + ) + + +def test_certificate_manager_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.certificate_manager_v1.services.certificate_manager.transports.CertificateManagerTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CertificateManagerTransport() + adc.assert_called_once() + + +def test_certificate_manager_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) + CertificateManagerClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.CertificateManagerGrpcTransport, + transports.CertificateManagerGrpcAsyncIOTransport, + ], +) +def test_certificate_manager_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.CertificateManagerGrpcTransport, + transports.CertificateManagerGrpcAsyncIOTransport, + transports.CertificateManagerRestTransport, + ], +) +def test_certificate_manager_transport_auth_gdch_credentials(transport_class): + host = 'https://language.com' + api_audience_tests = [None, 'https://language2.com'] + api_audience_expect = [host, 'https://language2.com'] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock(return_value=gdch_mock) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with( + e + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateManagerGrpcTransport, grpc_helpers), + (transports.CertificateManagerGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_certificate_manager_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( + "certificatemanager.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="certificatemanager.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.CertificateManagerGrpcTransport, transports.CertificateManagerGrpcAsyncIOTransport]) +def test_certificate_manager_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_certificate_manager_http_transport_client_cert_source_for_mtls(): + cred = ga_credentials.AnonymousCredentials() + with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel") as mock_configure_mtls_channel: + transports.CertificateManagerRestTransport ( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) + + +def test_certificate_manager_rest_lro_client(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.AbstractOperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +@pytest.mark.parametrize("transport_name", [ + "grpc", + "grpc_asyncio", + "rest", +]) +def test_certificate_manager_host_no_port(transport_name): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='certificatemanager.googleapis.com'), + transport=transport_name, + ) + assert client.transport._host == ( + 'certificatemanager.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else 'https://certificatemanager.googleapis.com' + ) + +@pytest.mark.parametrize("transport_name", [ + "grpc", + "grpc_asyncio", + "rest", +]) +def test_certificate_manager_host_with_port(transport_name): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='certificatemanager.googleapis.com:8000'), + transport=transport_name, + ) + assert client.transport._host == ( + 'certificatemanager.googleapis.com:8000' + if transport_name in ['grpc', 'grpc_asyncio'] + else 'https://certificatemanager.googleapis.com:8000' + ) + +@pytest.mark.parametrize("transport_name", [ + "rest", +]) +def test_certificate_manager_client_transport_session_collision(transport_name): + creds1 = ga_credentials.AnonymousCredentials() + creds2 = ga_credentials.AnonymousCredentials() + client1 = CertificateManagerClient( + credentials=creds1, + transport=transport_name, + ) + client2 = CertificateManagerClient( + credentials=creds2, + transport=transport_name, + ) + session1 = client1.transport.list_certificates._session + session2 = client2.transport.list_certificates._session + assert session1 != session2 + session1 = client1.transport.get_certificate._session + session2 = client2.transport.get_certificate._session + assert session1 != session2 + session1 = client1.transport.create_certificate._session + session2 = client2.transport.create_certificate._session + assert session1 != session2 + session1 = client1.transport.update_certificate._session + session2 = client2.transport.update_certificate._session + assert session1 != session2 + session1 = client1.transport.delete_certificate._session + session2 = client2.transport.delete_certificate._session + assert session1 != session2 + session1 = client1.transport.list_certificate_maps._session + session2 = client2.transport.list_certificate_maps._session + assert session1 != session2 + session1 = client1.transport.get_certificate_map._session + session2 = client2.transport.get_certificate_map._session + assert session1 != session2 + session1 = client1.transport.create_certificate_map._session + session2 = client2.transport.create_certificate_map._session + assert session1 != session2 + session1 = client1.transport.update_certificate_map._session + session2 = client2.transport.update_certificate_map._session + assert session1 != session2 + session1 = client1.transport.delete_certificate_map._session + session2 = client2.transport.delete_certificate_map._session + assert session1 != session2 + session1 = client1.transport.list_certificate_map_entries._session + session2 = client2.transport.list_certificate_map_entries._session + assert session1 != session2 + session1 = client1.transport.get_certificate_map_entry._session + session2 = client2.transport.get_certificate_map_entry._session + assert session1 != session2 + session1 = client1.transport.create_certificate_map_entry._session + session2 = client2.transport.create_certificate_map_entry._session + assert session1 != session2 + session1 = client1.transport.update_certificate_map_entry._session + session2 = client2.transport.update_certificate_map_entry._session + assert session1 != session2 + session1 = client1.transport.delete_certificate_map_entry._session + session2 = client2.transport.delete_certificate_map_entry._session + assert session1 != session2 + session1 = client1.transport.list_dns_authorizations._session + session2 = client2.transport.list_dns_authorizations._session + assert session1 != session2 + session1 = client1.transport.get_dns_authorization._session + session2 = client2.transport.get_dns_authorization._session + assert session1 != session2 + session1 = client1.transport.create_dns_authorization._session + session2 = client2.transport.create_dns_authorization._session + assert session1 != session2 + session1 = client1.transport.update_dns_authorization._session + session2 = client2.transport.update_dns_authorization._session + assert session1 != session2 + session1 = client1.transport.delete_dns_authorization._session + session2 = client2.transport.delete_dns_authorization._session + assert session1 != session2 + session1 = client1.transport.list_certificate_issuance_configs._session + session2 = client2.transport.list_certificate_issuance_configs._session + assert session1 != session2 + session1 = client1.transport.get_certificate_issuance_config._session + session2 = client2.transport.get_certificate_issuance_config._session + assert session1 != session2 + session1 = client1.transport.create_certificate_issuance_config._session + session2 = client2.transport.create_certificate_issuance_config._session + assert session1 != session2 + session1 = client1.transport.delete_certificate_issuance_config._session + session2 = client2.transport.delete_certificate_issuance_config._session + assert session1 != session2 +def test_certificate_manager_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CertificateManagerGrpcTransport( + 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_certificate_manager_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CertificateManagerGrpcAsyncIOTransport( + 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.CertificateManagerGrpcTransport, transports.CertificateManagerGrpcAsyncIOTransport]) +def test_certificate_manager_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.CertificateManagerGrpcTransport, transports.CertificateManagerGrpcAsyncIOTransport]) +def test_certificate_manager_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_certificate_manager_grpc_lro_client(): + client = CertificateManagerClient( + 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_certificate_manager_grpc_lro_async_client(): + client = CertificateManagerAsyncClient( + 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_ca_pool_path(): + project = "squid" + location = "clam" + ca_pool = "whelk" + expected = "projects/{project}/locations/{location}/caPools/{ca_pool}".format(project=project, location=location, ca_pool=ca_pool, ) + actual = CertificateManagerClient.ca_pool_path(project, location, ca_pool) + assert expected == actual + + +def test_parse_ca_pool_path(): + expected = { + "project": "octopus", + "location": "oyster", + "ca_pool": "nudibranch", + } + path = CertificateManagerClient.ca_pool_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateManagerClient.parse_ca_pool_path(path) + assert expected == actual + +def test_certificate_path(): + project = "cuttlefish" + location = "mussel" + certificate = "winkle" + expected = "projects/{project}/locations/{location}/certificates/{certificate}".format(project=project, location=location, certificate=certificate, ) + actual = CertificateManagerClient.certificate_path(project, location, certificate) + assert expected == actual + + +def test_parse_certificate_path(): + expected = { + "project": "nautilus", + "location": "scallop", + "certificate": "abalone", + } + path = CertificateManagerClient.certificate_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateManagerClient.parse_certificate_path(path) + assert expected == actual + +def test_certificate_issuance_config_path(): + project = "squid" + location = "clam" + certificate_issuance_config = "whelk" + expected = "projects/{project}/locations/{location}/certificateIssuanceConfigs/{certificate_issuance_config}".format(project=project, location=location, certificate_issuance_config=certificate_issuance_config, ) + actual = CertificateManagerClient.certificate_issuance_config_path(project, location, certificate_issuance_config) + assert expected == actual + + +def test_parse_certificate_issuance_config_path(): + expected = { + "project": "octopus", + "location": "oyster", + "certificate_issuance_config": "nudibranch", + } + path = CertificateManagerClient.certificate_issuance_config_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateManagerClient.parse_certificate_issuance_config_path(path) + assert expected == actual + +def test_certificate_map_path(): + project = "cuttlefish" + location = "mussel" + certificate_map = "winkle" + expected = "projects/{project}/locations/{location}/certificateMaps/{certificate_map}".format(project=project, location=location, certificate_map=certificate_map, ) + actual = CertificateManagerClient.certificate_map_path(project, location, certificate_map) + assert expected == actual + + +def test_parse_certificate_map_path(): + expected = { + "project": "nautilus", + "location": "scallop", + "certificate_map": "abalone", + } + path = CertificateManagerClient.certificate_map_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateManagerClient.parse_certificate_map_path(path) + assert expected == actual + +def test_certificate_map_entry_path(): + project = "squid" + location = "clam" + certificate_map = "whelk" + certificate_map_entry = "octopus" + expected = "projects/{project}/locations/{location}/certificateMaps/{certificate_map}/certificateMapEntries/{certificate_map_entry}".format(project=project, location=location, certificate_map=certificate_map, certificate_map_entry=certificate_map_entry, ) + actual = CertificateManagerClient.certificate_map_entry_path(project, location, certificate_map, certificate_map_entry) + assert expected == actual + + +def test_parse_certificate_map_entry_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "certificate_map": "cuttlefish", + "certificate_map_entry": "mussel", + } + path = CertificateManagerClient.certificate_map_entry_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateManagerClient.parse_certificate_map_entry_path(path) + assert expected == actual + +def test_dns_authorization_path(): + project = "winkle" + location = "nautilus" + dns_authorization = "scallop" + expected = "projects/{project}/locations/{location}/dnsAuthorizations/{dns_authorization}".format(project=project, location=location, dns_authorization=dns_authorization, ) + actual = CertificateManagerClient.dns_authorization_path(project, location, dns_authorization) + assert expected == actual + + +def test_parse_dns_authorization_path(): + expected = { + "project": "abalone", + "location": "squid", + "dns_authorization": "clam", + } + path = CertificateManagerClient.dns_authorization_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateManagerClient.parse_dns_authorization_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "whelk" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = CertificateManagerClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "octopus", + } + path = CertificateManagerClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateManagerClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "oyster" + expected = "folders/{folder}".format(folder=folder, ) + actual = CertificateManagerClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nudibranch", + } + path = CertificateManagerClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateManagerClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "cuttlefish" + expected = "organizations/{organization}".format(organization=organization, ) + actual = CertificateManagerClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "mussel", + } + path = CertificateManagerClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateManagerClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "winkle" + expected = "projects/{project}".format(project=project, ) + actual = CertificateManagerClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nautilus", + } + path = CertificateManagerClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateManagerClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "scallop" + location = "abalone" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = CertificateManagerClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "squid", + "location": "clam", + } + path = CertificateManagerClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateManagerClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_with_default_client_info(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.CertificateManagerTransport, '_prep_wrapped_messages') as prep: + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.CertificateManagerTransport, '_prep_wrapped_messages') as prep: + transport_class = CertificateManagerClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", + ) + with mock.patch.object(type(getattr(client.transport, "grpc_channel")), "close") as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_get_location_rest_bad_request(transport: str = 'rest', request_type=locations_pb2.GetLocationRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_location(request) + +@pytest.mark.parametrize("request_type", [ + locations_pb2.GetLocationRequest, + dict, +]) +def test_get_location_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {'name': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = locations_pb2.Location() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_location(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, locations_pb2.Location) + +def test_list_locations_rest_bad_request(transport: str = 'rest', request_type=locations_pb2.ListLocationsRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_locations(request) + +@pytest.mark.parametrize("request_type", [ + locations_pb2.ListLocationsRequest, + dict, +]) +def test_list_locations_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {'name': 'projects/sample1'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = locations_pb2.ListLocationsResponse() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_locations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, locations_pb2.ListLocationsResponse) + +def test_cancel_operation_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.CancelOperationRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.cancel_operation(request) + +@pytest.mark.parametrize("request_type", [ + operations_pb2.CancelOperationRequest, + dict, +]) +def test_cancel_operation_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '{}' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.cancel_operation(request) + + # Establish that the response is the type that we expect. + assert response is None + +def test_delete_operation_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.DeleteOperationRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_operation(request) + +@pytest.mark.parametrize("request_type", [ + operations_pb2.DeleteOperationRequest, + dict, +]) +def test_delete_operation_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '{}' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_operation(request) + + # Establish that the response is the type that we expect. + assert response is None + +def test_get_operation_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.GetOperationRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_operation(request) + +@pytest.mark.parametrize("request_type", [ + operations_pb2.GetOperationRequest, + dict, +]) +def test_get_operation_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_operation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + +def test_list_operations_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.ListOperationsRequest): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_operations(request) + +@pytest.mark.parametrize("request_type", [ + operations_pb2.ListOperationsRequest, + dict, +]) +def test_list_operations_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {'name': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.ListOperationsResponse() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_operations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) + + +def test_delete_operation(transport: str = "grpc"): + client = CertificateManagerClient( + 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 = operations_pb2.DeleteOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_operation(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 response is the type that we expect. + assert response is None +@pytest.mark.asyncio +async def test_delete_operation_async(transport: str = "grpc"): + client = CertificateManagerAsyncClient( + 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 = operations_pb2.DeleteOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.delete_operation(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 response is the type that we expect. + assert response is None + +def test_delete_operation_field_headers(): + client = CertificateManagerClient( + 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 = operations_pb2.DeleteOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + call.return_value = None + + client.delete_operation(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=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_delete_operation_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = operations_pb2.DeleteOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + await client.delete_operation(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=locations",) in kw["metadata"] + +def test_delete_operation_from_dict(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_operation( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_delete_operation_from_dict_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.delete_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_cancel_operation(transport: str = "grpc"): + client = CertificateManagerClient( + 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 = operations_pb2.CancelOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.cancel_operation(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 response is the type that we expect. + assert response is None +@pytest.mark.asyncio +async def test_cancel_operation_async(transport: str = "grpc"): + client = CertificateManagerAsyncClient( + 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 = operations_pb2.CancelOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.cancel_operation(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 response is the type that we expect. + assert response is None + +def test_cancel_operation_field_headers(): + client = CertificateManagerClient( + 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 = operations_pb2.CancelOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + call.return_value = None + + client.cancel_operation(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=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_cancel_operation_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = operations_pb2.CancelOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + await client.cancel_operation(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=locations",) in kw["metadata"] + +def test_cancel_operation_from_dict(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.cancel_operation( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_cancel_operation_from_dict_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.cancel_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_get_operation(transport: str = "grpc"): + client = CertificateManagerClient( + 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 = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + response = client.get_operation(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 response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) +@pytest.mark.asyncio +async def test_get_operation_async(transport: str = "grpc"): + client = CertificateManagerAsyncClient( + 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 = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation(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 response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + +def test_get_operation_field_headers(): + client = CertificateManagerClient( + 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 = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = operations_pb2.Operation() + + client.get_operation(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=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_get_operation_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + await client.get_operation(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=locations",) in kw["metadata"] + +def test_get_operation_from_dict(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + + response = client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_get_operation_from_dict_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_list_operations(transport: str = "grpc"): + client = CertificateManagerClient( + 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 = operations_pb2.ListOperationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.ListOperationsResponse() + response = client.list_operations(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 response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) +@pytest.mark.asyncio +async def test_list_operations_async(transport: str = "grpc"): + client = CertificateManagerAsyncClient( + 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 = operations_pb2.ListOperationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.ListOperationsResponse() + ) + response = await client.list_operations(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 response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) + +def test_list_operations_field_headers(): + client = CertificateManagerClient( + 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 = operations_pb2.ListOperationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + call.return_value = operations_pb2.ListOperationsResponse() + + client.list_operations(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=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_list_operations_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = operations_pb2.ListOperationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.ListOperationsResponse() + ) + await client.list_operations(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=locations",) in kw["metadata"] + +def test_list_operations_from_dict(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.ListOperationsResponse() + + response = client.list_operations( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_list_operations_from_dict_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.ListOperationsResponse() + ) + response = await client.list_operations( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_list_locations(transport: str = "grpc"): + client = CertificateManagerClient( + 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 = locations_pb2.ListLocationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = locations_pb2.ListLocationsResponse() + response = client.list_locations(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 response is the type that we expect. + assert isinstance(response, locations_pb2.ListLocationsResponse) +@pytest.mark.asyncio +async def test_list_locations_async(transport: str = "grpc"): + client = CertificateManagerAsyncClient( + 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 = locations_pb2.ListLocationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.ListLocationsResponse() + ) + response = await client.list_locations(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 response is the type that we expect. + assert isinstance(response, locations_pb2.ListLocationsResponse) + +def test_list_locations_field_headers(): + client = CertificateManagerClient( + 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 = locations_pb2.ListLocationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + call.return_value = locations_pb2.ListLocationsResponse() + + client.list_locations(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=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_list_locations_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = locations_pb2.ListLocationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.ListLocationsResponse() + ) + await client.list_locations(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=locations",) in kw["metadata"] + +def test_list_locations_from_dict(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = locations_pb2.ListLocationsResponse() + + response = client.list_locations( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_list_locations_from_dict_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.ListLocationsResponse() + ) + response = await client.list_locations( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_get_location(transport: str = "grpc"): + client = CertificateManagerClient( + 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 = locations_pb2.GetLocationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_location), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = locations_pb2.Location() + response = client.get_location(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 response is the type that we expect. + assert isinstance(response, locations_pb2.Location) +@pytest.mark.asyncio +async def test_get_location_async(transport: str = "grpc_asyncio"): + client = CertificateManagerAsyncClient( + 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 = locations_pb2.GetLocationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_location), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.Location() + ) + response = await client.get_location(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 response is the type that we expect. + assert isinstance(response, locations_pb2.Location) + +def test_get_location_field_headers(): + client = CertificateManagerClient( + 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 = locations_pb2.GetLocationRequest() + request.name = "locations/abc" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_location), "__call__") as call: + call.return_value = locations_pb2.Location() + + client.get_location(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=locations/abc",) in kw["metadata"] +@pytest.mark.asyncio +async def test_get_location_field_headers_async(): + client = CertificateManagerAsyncClient( + 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 = locations_pb2.GetLocationRequest() + request.name = "locations/abc" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_location), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.Location() + ) + await client.get_location(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=locations/abc",) in kw["metadata"] + +def test_get_location_from_dict(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = locations_pb2.Location() + + response = client.get_location( + request={ + "name": "locations/abc", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_get_location_from_dict_async(): + client = CertificateManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.Location() + ) + response = await client.get_location( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_transport_close(): + transports = { + "rest": "_session", + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport + ) + with mock.patch.object(type(getattr(client.transport, close_name)), "close") as close: + with client: + close.assert_not_called() + close.assert_called_once() + +def test_client_ctx(): + transports = [ + 'rest', + 'grpc', + ] + for transport in transports: + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() + +@pytest.mark.parametrize("client_class,transport_class", [ + (CertificateManagerClient, transports.CertificateManagerGrpcTransport), + (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport), +]) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + 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=mock_cred, + 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, + always_use_jwt_access=True, + api_audience=None, + ) From 3d493917dca6249177b71411605ae3614d8bec00 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 8 Feb 2023 22:55:11 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../gapic_metadata.json | 125 + .../services/certificate_manager/client.py | 2 + .../transports/__init__.py | 4 + .../certificate_manager/transports/rest.py | 2731 +-- owl-bot-staging/v1/.coveragerc | 13 - owl-bot-staging/v1/.flake8 | 33 - owl-bot-staging/v1/MANIFEST.in | 2 - owl-bot-staging/v1/README.rst | 49 - .../certificate_manager.rst | 10 - .../docs/certificate_manager_v1/services.rst | 6 - .../v1/docs/certificate_manager_v1/types.rst | 6 - owl-bot-staging/v1/docs/conf.py | 376 - owl-bot-staging/v1/docs/index.rst | 7 - .../cloud/certificate_manager/__init__.py | 99 - .../certificate_manager/gapic_version.py | 16 - .../google/cloud/certificate_manager/py.typed | 2 - .../cloud/certificate_manager_v1/__init__.py | 100 - .../gapic_metadata.json | 388 - .../certificate_manager_v1/gapic_version.py | 16 - .../cloud/certificate_manager_v1/py.typed | 2 - .../services/__init__.py | 15 - .../services/certificate_manager/__init__.py | 22 - .../certificate_manager/async_client.py | 3616 ---- .../services/certificate_manager/client.py | 3716 ---- .../services/certificate_manager/pagers.py | 624 - .../transports/__init__.py | 38 - .../certificate_manager/transports/base.py | 677 - .../certificate_manager/transports/grpc.py | 1036 -- .../transports/grpc_asyncio.py | 1035 -- .../certificate_manager_v1/types/__init__.py | 94 - .../types/certificate_issuance_config.py | 318 - .../types/certificate_manager.py | 1514 -- owl-bot-staging/v1/mypy.ini | 3 - owl-bot-staging/v1/noxfile.py | 184 - ...ficate_manager_create_certificate_async.py | 57 - ...reate_certificate_issuance_config_async.py | 63 - ...create_certificate_issuance_config_sync.py | 63 - ...te_manager_create_certificate_map_async.py | 57 - ...ager_create_certificate_map_entry_async.py | 61 - ...nager_create_certificate_map_entry_sync.py | 61 - ...ate_manager_create_certificate_map_sync.py | 57 - ...ificate_manager_create_certificate_sync.py | 57 - ..._manager_create_dns_authorization_async.py | 61 - ...e_manager_create_dns_authorization_sync.py | 61 - ...ficate_manager_delete_certificate_async.py | 56 - ...elete_certificate_issuance_config_async.py | 56 - ...delete_certificate_issuance_config_sync.py | 56 - ...te_manager_delete_certificate_map_async.py | 56 - ...ager_delete_certificate_map_entry_async.py | 56 - ...nager_delete_certificate_map_entry_sync.py | 56 - ...ate_manager_delete_certificate_map_sync.py | 56 - ...ificate_manager_delete_certificate_sync.py | 56 - ..._manager_delete_dns_authorization_async.py | 56 - ...e_manager_delete_dns_authorization_sync.py | 56 - ...rtificate_manager_get_certificate_async.py | 52 - ...r_get_certificate_issuance_config_async.py | 52 - ...er_get_certificate_issuance_config_sync.py | 52 - ...icate_manager_get_certificate_map_async.py | 52 - ...manager_get_certificate_map_entry_async.py | 52 - ..._manager_get_certificate_map_entry_sync.py | 52 - ...ficate_manager_get_certificate_map_sync.py | 52 - ...ertificate_manager_get_certificate_sync.py | 52 - ...ate_manager_get_dns_authorization_async.py | 52 - ...cate_manager_get_dns_authorization_sync.py | 52 - ...list_certificate_issuance_configs_async.py | 53 - ..._list_certificate_issuance_configs_sync.py | 53 - ...ager_list_certificate_map_entries_async.py | 53 - ...nager_list_certificate_map_entries_sync.py | 53 - ...ate_manager_list_certificate_maps_async.py | 53 - ...cate_manager_list_certificate_maps_sync.py | 53 - ...ificate_manager_list_certificates_async.py | 53 - ...tificate_manager_list_certificates_sync.py | 53 - ...e_manager_list_dns_authorizations_async.py | 53 - ...te_manager_list_dns_authorizations_sync.py | 53 - ...ficate_manager_update_certificate_async.py | 55 - ...te_manager_update_certificate_map_async.py | 55 - ...ager_update_certificate_map_entry_async.py | 59 - ...nager_update_certificate_map_entry_sync.py | 59 - ...ate_manager_update_certificate_map_sync.py | 55 - ...ificate_manager_update_certificate_sync.py | 55 - ..._manager_update_dns_authorization_async.py | 59 - ...e_manager_update_dns_authorization_sync.py | 59 - ...ta_google.cloud.certificatemanager.v1.json | 3991 ---- .../fixup_certificate_manager_v1_keywords.py | 199 - owl-bot-staging/v1/setup.py | 90 - .../v1/testing/constraints-3.10.txt | 6 - .../v1/testing/constraints-3.11.txt | 6 - .../v1/testing/constraints-3.12.txt | 6 - .../v1/testing/constraints-3.7.txt | 9 - .../v1/testing/constraints-3.8.txt | 6 - .../v1/testing/constraints-3.9.txt | 6 - 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/certificate_manager_v1/__init__.py | 16 - .../test_certificate_manager.py | 15180 ---------------- .../test_certificate_manager.py | 8236 ++++++++- 97 files changed, 9950 insertions(+), 37392 deletions(-) rename {owl-bot-staging/v1/google => google}/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py (60%) delete mode 100644 owl-bot-staging/v1/.coveragerc delete mode 100644 owl-bot-staging/v1/.flake8 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/certificate_manager_v1/certificate_manager.rst delete mode 100644 owl-bot-staging/v1/docs/certificate_manager_v1/services.rst delete mode 100644 owl-bot-staging/v1/docs/certificate_manager_v1/types.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/certificate_manager/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager/gapic_version.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager/py.typed delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_version.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/py.typed delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/async_client.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/client.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/pagers.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/base.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_issuance_config.py delete mode 100644 owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_manager.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/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_async.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_sync.py delete mode 100644 owl-bot-staging/v1/samples/generated_samples/snippet_metadata_google.cloud.certificatemanager.v1.json delete mode 100644 owl-bot-staging/v1/scripts/fixup_certificate_manager_v1_keywords.py delete mode 100644 owl-bot-staging/v1/setup.py delete mode 100644 owl-bot-staging/v1/testing/constraints-3.10.txt delete mode 100644 owl-bot-staging/v1/testing/constraints-3.11.txt delete mode 100644 owl-bot-staging/v1/testing/constraints-3.12.txt delete mode 100644 owl-bot-staging/v1/testing/constraints-3.7.txt delete mode 100644 owl-bot-staging/v1/testing/constraints-3.8.txt delete mode 100644 owl-bot-staging/v1/testing/constraints-3.9.txt delete mode 100644 owl-bot-staging/v1/tests/__init__.py delete mode 100644 owl-bot-staging/v1/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v1/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/__init__.py delete mode 100644 owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py diff --git a/google/cloud/certificate_manager_v1/gapic_metadata.json b/google/cloud/certificate_manager_v1/gapic_metadata.json index b0b60ad..0c07957 100644 --- a/google/cloud/certificate_manager_v1/gapic_metadata.json +++ b/google/cloud/certificate_manager_v1/gapic_metadata.json @@ -256,6 +256,131 @@ ] } } + }, + "rest": { + "libraryClient": "CertificateManagerClient", + "rpcs": { + "CreateCertificate": { + "methods": [ + "create_certificate" + ] + }, + "CreateCertificateIssuanceConfig": { + "methods": [ + "create_certificate_issuance_config" + ] + }, + "CreateCertificateMap": { + "methods": [ + "create_certificate_map" + ] + }, + "CreateCertificateMapEntry": { + "methods": [ + "create_certificate_map_entry" + ] + }, + "CreateDnsAuthorization": { + "methods": [ + "create_dns_authorization" + ] + }, + "DeleteCertificate": { + "methods": [ + "delete_certificate" + ] + }, + "DeleteCertificateIssuanceConfig": { + "methods": [ + "delete_certificate_issuance_config" + ] + }, + "DeleteCertificateMap": { + "methods": [ + "delete_certificate_map" + ] + }, + "DeleteCertificateMapEntry": { + "methods": [ + "delete_certificate_map_entry" + ] + }, + "DeleteDnsAuthorization": { + "methods": [ + "delete_dns_authorization" + ] + }, + "GetCertificate": { + "methods": [ + "get_certificate" + ] + }, + "GetCertificateIssuanceConfig": { + "methods": [ + "get_certificate_issuance_config" + ] + }, + "GetCertificateMap": { + "methods": [ + "get_certificate_map" + ] + }, + "GetCertificateMapEntry": { + "methods": [ + "get_certificate_map_entry" + ] + }, + "GetDnsAuthorization": { + "methods": [ + "get_dns_authorization" + ] + }, + "ListCertificateIssuanceConfigs": { + "methods": [ + "list_certificate_issuance_configs" + ] + }, + "ListCertificateMapEntries": { + "methods": [ + "list_certificate_map_entries" + ] + }, + "ListCertificateMaps": { + "methods": [ + "list_certificate_maps" + ] + }, + "ListCertificates": { + "methods": [ + "list_certificates" + ] + }, + "ListDnsAuthorizations": { + "methods": [ + "list_dns_authorizations" + ] + }, + "UpdateCertificate": { + "methods": [ + "update_certificate" + ] + }, + "UpdateCertificateMap": { + "methods": [ + "update_certificate_map" + ] + }, + "UpdateCertificateMapEntry": { + "methods": [ + "update_certificate_map_entry" + ] + }, + "UpdateDnsAuthorization": { + "methods": [ + "update_dns_authorization" + ] + } + } } } } diff --git a/google/cloud/certificate_manager_v1/services/certificate_manager/client.py b/google/cloud/certificate_manager_v1/services/certificate_manager/client.py index cebac6a..1f905bb 100644 --- a/google/cloud/certificate_manager_v1/services/certificate_manager/client.py +++ b/google/cloud/certificate_manager_v1/services/certificate_manager/client.py @@ -65,6 +65,7 @@ from .transports.base import DEFAULT_CLIENT_INFO, CertificateManagerTransport from .transports.grpc import CertificateManagerGrpcTransport from .transports.grpc_asyncio import CertificateManagerGrpcAsyncIOTransport +from .transports.rest import CertificateManagerRestTransport class CertificateManagerClientMeta(type): @@ -80,6 +81,7 @@ class CertificateManagerClientMeta(type): ) # type: Dict[str, Type[CertificateManagerTransport]] _transport_registry["grpc"] = CertificateManagerGrpcTransport _transport_registry["grpc_asyncio"] = CertificateManagerGrpcAsyncIOTransport + _transport_registry["rest"] = CertificateManagerRestTransport def get_transport_class( cls, diff --git a/google/cloud/certificate_manager_v1/services/certificate_manager/transports/__init__.py b/google/cloud/certificate_manager_v1/services/certificate_manager/transports/__init__.py index 046ef3d..472b196 100644 --- a/google/cloud/certificate_manager_v1/services/certificate_manager/transports/__init__.py +++ b/google/cloud/certificate_manager_v1/services/certificate_manager/transports/__init__.py @@ -19,6 +19,7 @@ from .base import CertificateManagerTransport from .grpc import CertificateManagerGrpcTransport from .grpc_asyncio import CertificateManagerGrpcAsyncIOTransport +from .rest import CertificateManagerRestInterceptor, CertificateManagerRestTransport # Compile a registry of transports. _transport_registry = ( @@ -26,9 +27,12 @@ ) # type: Dict[str, Type[CertificateManagerTransport]] _transport_registry["grpc"] = CertificateManagerGrpcTransport _transport_registry["grpc_asyncio"] = CertificateManagerGrpcAsyncIOTransport +_transport_registry["rest"] = CertificateManagerRestTransport __all__ = ( "CertificateManagerTransport", "CertificateManagerGrpcTransport", "CertificateManagerGrpcAsyncIOTransport", + "CertificateManagerRestTransport", + "CertificateManagerRestInterceptor", ) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py b/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py similarity index 60% rename from owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py rename to google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py index 5ce38ee..ebbe964 100644 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py +++ b/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py @@ -14,27 +14,29 @@ # limitations under the License. # -from google.auth.transport.requests import AuthorizedSession # type: ignore +import dataclasses import json # type: ignore -import grpc # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth import credentials as ga_credentials # type: ignore +import re +from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union +import warnings + +from google.api_core import ( + gapic_v1, + operations_v1, + path_template, + rest_helpers, + rest_streaming, +) from google.api_core import exceptions as core_exceptions from google.api_core import retry as retries -from google.api_core import rest_helpers -from google.api_core import rest_streaming -from google.api_core import path_template -from google.api_core import gapic_v1 - -from google.protobuf import json_format -from google.api_core import operations_v1 -from google.cloud.location import locations_pb2 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.transport.requests import AuthorizedSession # type: ignore +from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 +from google.protobuf import json_format +import grpc # type: ignore from requests import __version__ as requests_version -import dataclasses -import re -from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union -import warnings try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -42,13 +44,16 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore -from google.cloud.certificate_manager_v1.types import certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_manager from google.longrunning import operations_pb2 # type: ignore -from .base import CertificateManagerTransport, DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO +from google.cloud.certificate_manager_v1.types import certificate_issuance_config +from google.cloud.certificate_manager_v1.types import ( + certificate_issuance_config as gcc_certificate_issuance_config, +) +from google.cloud.certificate_manager_v1.types import certificate_manager +from .base import CertificateManagerTransport +from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -269,7 +274,12 @@ def post_update_dns_authorization(self, response): """ - def pre_create_certificate(self, request: certificate_manager.CreateCertificateRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.CreateCertificateRequest, Sequence[Tuple[str, str]]]: + + def pre_create_certificate( + self, + request: certificate_manager.CreateCertificateRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[certificate_manager.CreateCertificateRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for create_certificate Override in a subclass to manipulate the request or metadata @@ -277,7 +287,9 @@ def pre_create_certificate(self, request: certificate_manager.CreateCertificateR """ return request, metadata - def post_create_certificate(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_create_certificate( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for create_certificate Override in a subclass to manipulate the response @@ -285,7 +297,15 @@ def post_create_certificate(self, response: operations_pb2.Operation) -> operati it is returned to user code. """ return response - def pre_create_certificate_issuance_config(self, request: gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, Sequence[Tuple[str, str]]]: + + def pre_create_certificate_issuance_config( + self, + request: gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, + Sequence[Tuple[str, str]], + ]: """Pre-rpc interceptor for create_certificate_issuance_config Override in a subclass to manipulate the request or metadata @@ -293,7 +313,9 @@ def pre_create_certificate_issuance_config(self, request: gcc_certificate_issuan """ return request, metadata - def post_create_certificate_issuance_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_create_certificate_issuance_config( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for create_certificate_issuance_config Override in a subclass to manipulate the response @@ -301,7 +323,14 @@ def post_create_certificate_issuance_config(self, response: operations_pb2.Opera it is returned to user code. """ return response - def pre_create_certificate_map(self, request: certificate_manager.CreateCertificateMapRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.CreateCertificateMapRequest, Sequence[Tuple[str, str]]]: + + def pre_create_certificate_map( + self, + request: certificate_manager.CreateCertificateMapRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.CreateCertificateMapRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for create_certificate_map Override in a subclass to manipulate the request or metadata @@ -309,7 +338,9 @@ def pre_create_certificate_map(self, request: certificate_manager.CreateCertific """ return request, metadata - def post_create_certificate_map(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_create_certificate_map( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for create_certificate_map Override in a subclass to manipulate the response @@ -317,7 +348,14 @@ def post_create_certificate_map(self, response: operations_pb2.Operation) -> ope it is returned to user code. """ return response - def pre_create_certificate_map_entry(self, request: certificate_manager.CreateCertificateMapEntryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.CreateCertificateMapEntryRequest, Sequence[Tuple[str, str]]]: + + def pre_create_certificate_map_entry( + self, + request: certificate_manager.CreateCertificateMapEntryRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.CreateCertificateMapEntryRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for create_certificate_map_entry Override in a subclass to manipulate the request or metadata @@ -325,7 +363,9 @@ def pre_create_certificate_map_entry(self, request: certificate_manager.CreateCe """ return request, metadata - def post_create_certificate_map_entry(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_create_certificate_map_entry( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for create_certificate_map_entry Override in a subclass to manipulate the response @@ -333,7 +373,14 @@ def post_create_certificate_map_entry(self, response: operations_pb2.Operation) it is returned to user code. """ return response - def pre_create_dns_authorization(self, request: certificate_manager.CreateDnsAuthorizationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.CreateDnsAuthorizationRequest, Sequence[Tuple[str, str]]]: + + def pre_create_dns_authorization( + self, + request: certificate_manager.CreateDnsAuthorizationRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.CreateDnsAuthorizationRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for create_dns_authorization Override in a subclass to manipulate the request or metadata @@ -341,7 +388,9 @@ def pre_create_dns_authorization(self, request: certificate_manager.CreateDnsAut """ return request, metadata - def post_create_dns_authorization(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_create_dns_authorization( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for create_dns_authorization Override in a subclass to manipulate the response @@ -349,7 +398,12 @@ def post_create_dns_authorization(self, response: operations_pb2.Operation) -> o it is returned to user code. """ return response - def pre_delete_certificate(self, request: certificate_manager.DeleteCertificateRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.DeleteCertificateRequest, Sequence[Tuple[str, str]]]: + + def pre_delete_certificate( + self, + request: certificate_manager.DeleteCertificateRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[certificate_manager.DeleteCertificateRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for delete_certificate Override in a subclass to manipulate the request or metadata @@ -357,7 +411,9 @@ def pre_delete_certificate(self, request: certificate_manager.DeleteCertificateR """ return request, metadata - def post_delete_certificate(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_delete_certificate( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for delete_certificate Override in a subclass to manipulate the response @@ -365,7 +421,15 @@ def post_delete_certificate(self, response: operations_pb2.Operation) -> operati it is returned to user code. """ return response - def pre_delete_certificate_issuance_config(self, request: certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, Sequence[Tuple[str, str]]]: + + def pre_delete_certificate_issuance_config( + self, + request: certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, + Sequence[Tuple[str, str]], + ]: """Pre-rpc interceptor for delete_certificate_issuance_config Override in a subclass to manipulate the request or metadata @@ -373,7 +437,9 @@ def pre_delete_certificate_issuance_config(self, request: certificate_issuance_c """ return request, metadata - def post_delete_certificate_issuance_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_delete_certificate_issuance_config( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for delete_certificate_issuance_config Override in a subclass to manipulate the response @@ -381,7 +447,14 @@ def post_delete_certificate_issuance_config(self, response: operations_pb2.Opera it is returned to user code. """ return response - def pre_delete_certificate_map(self, request: certificate_manager.DeleteCertificateMapRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.DeleteCertificateMapRequest, Sequence[Tuple[str, str]]]: + + def pre_delete_certificate_map( + self, + request: certificate_manager.DeleteCertificateMapRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.DeleteCertificateMapRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for delete_certificate_map Override in a subclass to manipulate the request or metadata @@ -389,7 +462,9 @@ def pre_delete_certificate_map(self, request: certificate_manager.DeleteCertific """ return request, metadata - def post_delete_certificate_map(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_delete_certificate_map( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for delete_certificate_map Override in a subclass to manipulate the response @@ -397,7 +472,14 @@ def post_delete_certificate_map(self, response: operations_pb2.Operation) -> ope it is returned to user code. """ return response - def pre_delete_certificate_map_entry(self, request: certificate_manager.DeleteCertificateMapEntryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.DeleteCertificateMapEntryRequest, Sequence[Tuple[str, str]]]: + + def pre_delete_certificate_map_entry( + self, + request: certificate_manager.DeleteCertificateMapEntryRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.DeleteCertificateMapEntryRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for delete_certificate_map_entry Override in a subclass to manipulate the request or metadata @@ -405,7 +487,9 @@ def pre_delete_certificate_map_entry(self, request: certificate_manager.DeleteCe """ return request, metadata - def post_delete_certificate_map_entry(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_delete_certificate_map_entry( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for delete_certificate_map_entry Override in a subclass to manipulate the response @@ -413,7 +497,14 @@ def post_delete_certificate_map_entry(self, response: operations_pb2.Operation) it is returned to user code. """ return response - def pre_delete_dns_authorization(self, request: certificate_manager.DeleteDnsAuthorizationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.DeleteDnsAuthorizationRequest, Sequence[Tuple[str, str]]]: + + def pre_delete_dns_authorization( + self, + request: certificate_manager.DeleteDnsAuthorizationRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.DeleteDnsAuthorizationRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for delete_dns_authorization Override in a subclass to manipulate the request or metadata @@ -421,7 +512,9 @@ def pre_delete_dns_authorization(self, request: certificate_manager.DeleteDnsAut """ return request, metadata - def post_delete_dns_authorization(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_delete_dns_authorization( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for delete_dns_authorization Override in a subclass to manipulate the response @@ -429,7 +522,12 @@ def post_delete_dns_authorization(self, response: operations_pb2.Operation) -> o it is returned to user code. """ return response - def pre_get_certificate(self, request: certificate_manager.GetCertificateRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.GetCertificateRequest, Sequence[Tuple[str, str]]]: + + def pre_get_certificate( + self, + request: certificate_manager.GetCertificateRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[certificate_manager.GetCertificateRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for get_certificate Override in a subclass to manipulate the request or metadata @@ -437,7 +535,9 @@ def pre_get_certificate(self, request: certificate_manager.GetCertificateRequest """ return request, metadata - def post_get_certificate(self, response: certificate_manager.Certificate) -> certificate_manager.Certificate: + def post_get_certificate( + self, response: certificate_manager.Certificate + ) -> certificate_manager.Certificate: """Post-rpc interceptor for get_certificate Override in a subclass to manipulate the response @@ -445,7 +545,15 @@ def post_get_certificate(self, response: certificate_manager.Certificate) -> cer it is returned to user code. """ return response - def pre_get_certificate_issuance_config(self, request: certificate_issuance_config.GetCertificateIssuanceConfigRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_issuance_config.GetCertificateIssuanceConfigRequest, Sequence[Tuple[str, str]]]: + + def pre_get_certificate_issuance_config( + self, + request: certificate_issuance_config.GetCertificateIssuanceConfigRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_issuance_config.GetCertificateIssuanceConfigRequest, + Sequence[Tuple[str, str]], + ]: """Pre-rpc interceptor for get_certificate_issuance_config Override in a subclass to manipulate the request or metadata @@ -453,7 +561,9 @@ def pre_get_certificate_issuance_config(self, request: certificate_issuance_conf """ return request, metadata - def post_get_certificate_issuance_config(self, response: certificate_issuance_config.CertificateIssuanceConfig) -> certificate_issuance_config.CertificateIssuanceConfig: + def post_get_certificate_issuance_config( + self, response: certificate_issuance_config.CertificateIssuanceConfig + ) -> certificate_issuance_config.CertificateIssuanceConfig: """Post-rpc interceptor for get_certificate_issuance_config Override in a subclass to manipulate the response @@ -461,7 +571,12 @@ def post_get_certificate_issuance_config(self, response: certificate_issuance_co it is returned to user code. """ return response - def pre_get_certificate_map(self, request: certificate_manager.GetCertificateMapRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.GetCertificateMapRequest, Sequence[Tuple[str, str]]]: + + def pre_get_certificate_map( + self, + request: certificate_manager.GetCertificateMapRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[certificate_manager.GetCertificateMapRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for get_certificate_map Override in a subclass to manipulate the request or metadata @@ -469,7 +584,9 @@ def pre_get_certificate_map(self, request: certificate_manager.GetCertificateMap """ return request, metadata - def post_get_certificate_map(self, response: certificate_manager.CertificateMap) -> certificate_manager.CertificateMap: + def post_get_certificate_map( + self, response: certificate_manager.CertificateMap + ) -> certificate_manager.CertificateMap: """Post-rpc interceptor for get_certificate_map Override in a subclass to manipulate the response @@ -477,7 +594,14 @@ def post_get_certificate_map(self, response: certificate_manager.CertificateMap) it is returned to user code. """ return response - def pre_get_certificate_map_entry(self, request: certificate_manager.GetCertificateMapEntryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.GetCertificateMapEntryRequest, Sequence[Tuple[str, str]]]: + + def pre_get_certificate_map_entry( + self, + request: certificate_manager.GetCertificateMapEntryRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.GetCertificateMapEntryRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for get_certificate_map_entry Override in a subclass to manipulate the request or metadata @@ -485,7 +609,9 @@ def pre_get_certificate_map_entry(self, request: certificate_manager.GetCertific """ return request, metadata - def post_get_certificate_map_entry(self, response: certificate_manager.CertificateMapEntry) -> certificate_manager.CertificateMapEntry: + def post_get_certificate_map_entry( + self, response: certificate_manager.CertificateMapEntry + ) -> certificate_manager.CertificateMapEntry: """Post-rpc interceptor for get_certificate_map_entry Override in a subclass to manipulate the response @@ -493,7 +619,14 @@ def post_get_certificate_map_entry(self, response: certificate_manager.Certifica it is returned to user code. """ return response - def pre_get_dns_authorization(self, request: certificate_manager.GetDnsAuthorizationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.GetDnsAuthorizationRequest, Sequence[Tuple[str, str]]]: + + def pre_get_dns_authorization( + self, + request: certificate_manager.GetDnsAuthorizationRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.GetDnsAuthorizationRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for get_dns_authorization Override in a subclass to manipulate the request or metadata @@ -501,7 +634,9 @@ def pre_get_dns_authorization(self, request: certificate_manager.GetDnsAuthoriza """ return request, metadata - def post_get_dns_authorization(self, response: certificate_manager.DnsAuthorization) -> certificate_manager.DnsAuthorization: + def post_get_dns_authorization( + self, response: certificate_manager.DnsAuthorization + ) -> certificate_manager.DnsAuthorization: """Post-rpc interceptor for get_dns_authorization Override in a subclass to manipulate the response @@ -509,7 +644,15 @@ def post_get_dns_authorization(self, response: certificate_manager.DnsAuthorizat it is returned to user code. """ return response - def pre_list_certificate_issuance_configs(self, request: certificate_issuance_config.ListCertificateIssuanceConfigsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_issuance_config.ListCertificateIssuanceConfigsRequest, Sequence[Tuple[str, str]]]: + + def pre_list_certificate_issuance_configs( + self, + request: certificate_issuance_config.ListCertificateIssuanceConfigsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_issuance_config.ListCertificateIssuanceConfigsRequest, + Sequence[Tuple[str, str]], + ]: """Pre-rpc interceptor for list_certificate_issuance_configs Override in a subclass to manipulate the request or metadata @@ -517,7 +660,10 @@ def pre_list_certificate_issuance_configs(self, request: certificate_issuance_co """ return request, metadata - def post_list_certificate_issuance_configs(self, response: certificate_issuance_config.ListCertificateIssuanceConfigsResponse) -> certificate_issuance_config.ListCertificateIssuanceConfigsResponse: + def post_list_certificate_issuance_configs( + self, + response: certificate_issuance_config.ListCertificateIssuanceConfigsResponse, + ) -> certificate_issuance_config.ListCertificateIssuanceConfigsResponse: """Post-rpc interceptor for list_certificate_issuance_configs Override in a subclass to manipulate the response @@ -525,7 +671,14 @@ def post_list_certificate_issuance_configs(self, response: certificate_issuance_ it is returned to user code. """ return response - def pre_list_certificate_map_entries(self, request: certificate_manager.ListCertificateMapEntriesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.ListCertificateMapEntriesRequest, Sequence[Tuple[str, str]]]: + + def pre_list_certificate_map_entries( + self, + request: certificate_manager.ListCertificateMapEntriesRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.ListCertificateMapEntriesRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for list_certificate_map_entries Override in a subclass to manipulate the request or metadata @@ -533,7 +686,9 @@ def pre_list_certificate_map_entries(self, request: certificate_manager.ListCert """ return request, metadata - def post_list_certificate_map_entries(self, response: certificate_manager.ListCertificateMapEntriesResponse) -> certificate_manager.ListCertificateMapEntriesResponse: + def post_list_certificate_map_entries( + self, response: certificate_manager.ListCertificateMapEntriesResponse + ) -> certificate_manager.ListCertificateMapEntriesResponse: """Post-rpc interceptor for list_certificate_map_entries Override in a subclass to manipulate the response @@ -541,7 +696,14 @@ def post_list_certificate_map_entries(self, response: certificate_manager.ListCe it is returned to user code. """ return response - def pre_list_certificate_maps(self, request: certificate_manager.ListCertificateMapsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.ListCertificateMapsRequest, Sequence[Tuple[str, str]]]: + + def pre_list_certificate_maps( + self, + request: certificate_manager.ListCertificateMapsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.ListCertificateMapsRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for list_certificate_maps Override in a subclass to manipulate the request or metadata @@ -549,7 +711,9 @@ def pre_list_certificate_maps(self, request: certificate_manager.ListCertificate """ return request, metadata - def post_list_certificate_maps(self, response: certificate_manager.ListCertificateMapsResponse) -> certificate_manager.ListCertificateMapsResponse: + def post_list_certificate_maps( + self, response: certificate_manager.ListCertificateMapsResponse + ) -> certificate_manager.ListCertificateMapsResponse: """Post-rpc interceptor for list_certificate_maps Override in a subclass to manipulate the response @@ -557,7 +721,12 @@ def post_list_certificate_maps(self, response: certificate_manager.ListCertifica it is returned to user code. """ return response - def pre_list_certificates(self, request: certificate_manager.ListCertificatesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.ListCertificatesRequest, Sequence[Tuple[str, str]]]: + + def pre_list_certificates( + self, + request: certificate_manager.ListCertificatesRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[certificate_manager.ListCertificatesRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for list_certificates Override in a subclass to manipulate the request or metadata @@ -565,7 +734,9 @@ def pre_list_certificates(self, request: certificate_manager.ListCertificatesReq """ return request, metadata - def post_list_certificates(self, response: certificate_manager.ListCertificatesResponse) -> certificate_manager.ListCertificatesResponse: + def post_list_certificates( + self, response: certificate_manager.ListCertificatesResponse + ) -> certificate_manager.ListCertificatesResponse: """Post-rpc interceptor for list_certificates Override in a subclass to manipulate the response @@ -573,7 +744,14 @@ def post_list_certificates(self, response: certificate_manager.ListCertificatesR it is returned to user code. """ return response - def pre_list_dns_authorizations(self, request: certificate_manager.ListDnsAuthorizationsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.ListDnsAuthorizationsRequest, Sequence[Tuple[str, str]]]: + + def pre_list_dns_authorizations( + self, + request: certificate_manager.ListDnsAuthorizationsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.ListDnsAuthorizationsRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for list_dns_authorizations Override in a subclass to manipulate the request or metadata @@ -581,7 +759,9 @@ def pre_list_dns_authorizations(self, request: certificate_manager.ListDnsAuthor """ return request, metadata - def post_list_dns_authorizations(self, response: certificate_manager.ListDnsAuthorizationsResponse) -> certificate_manager.ListDnsAuthorizationsResponse: + def post_list_dns_authorizations( + self, response: certificate_manager.ListDnsAuthorizationsResponse + ) -> certificate_manager.ListDnsAuthorizationsResponse: """Post-rpc interceptor for list_dns_authorizations Override in a subclass to manipulate the response @@ -589,7 +769,12 @@ def post_list_dns_authorizations(self, response: certificate_manager.ListDnsAuth it is returned to user code. """ return response - def pre_update_certificate(self, request: certificate_manager.UpdateCertificateRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.UpdateCertificateRequest, Sequence[Tuple[str, str]]]: + + def pre_update_certificate( + self, + request: certificate_manager.UpdateCertificateRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[certificate_manager.UpdateCertificateRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for update_certificate Override in a subclass to manipulate the request or metadata @@ -597,7 +782,9 @@ def pre_update_certificate(self, request: certificate_manager.UpdateCertificateR """ return request, metadata - def post_update_certificate(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_update_certificate( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for update_certificate Override in a subclass to manipulate the response @@ -605,7 +792,14 @@ def post_update_certificate(self, response: operations_pb2.Operation) -> operati it is returned to user code. """ return response - def pre_update_certificate_map(self, request: certificate_manager.UpdateCertificateMapRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.UpdateCertificateMapRequest, Sequence[Tuple[str, str]]]: + + def pre_update_certificate_map( + self, + request: certificate_manager.UpdateCertificateMapRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.UpdateCertificateMapRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for update_certificate_map Override in a subclass to manipulate the request or metadata @@ -613,7 +807,9 @@ def pre_update_certificate_map(self, request: certificate_manager.UpdateCertific """ return request, metadata - def post_update_certificate_map(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_update_certificate_map( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for update_certificate_map Override in a subclass to manipulate the response @@ -621,7 +817,14 @@ def post_update_certificate_map(self, response: operations_pb2.Operation) -> ope it is returned to user code. """ return response - def pre_update_certificate_map_entry(self, request: certificate_manager.UpdateCertificateMapEntryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.UpdateCertificateMapEntryRequest, Sequence[Tuple[str, str]]]: + + def pre_update_certificate_map_entry( + self, + request: certificate_manager.UpdateCertificateMapEntryRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.UpdateCertificateMapEntryRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for update_certificate_map_entry Override in a subclass to manipulate the request or metadata @@ -629,7 +832,9 @@ def pre_update_certificate_map_entry(self, request: certificate_manager.UpdateCe """ return request, metadata - def post_update_certificate_map_entry(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_update_certificate_map_entry( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for update_certificate_map_entry Override in a subclass to manipulate the response @@ -637,7 +842,14 @@ def post_update_certificate_map_entry(self, response: operations_pb2.Operation) it is returned to user code. """ return response - def pre_update_dns_authorization(self, request: certificate_manager.UpdateDnsAuthorizationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[certificate_manager.UpdateDnsAuthorizationRequest, Sequence[Tuple[str, str]]]: + + def pre_update_dns_authorization( + self, + request: certificate_manager.UpdateDnsAuthorizationRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[ + certificate_manager.UpdateDnsAuthorizationRequest, Sequence[Tuple[str, str]] + ]: """Pre-rpc interceptor for update_dns_authorization Override in a subclass to manipulate the request or metadata @@ -645,7 +857,9 @@ def pre_update_dns_authorization(self, request: certificate_manager.UpdateDnsAut """ return request, metadata - def post_update_dns_authorization(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + def post_update_dns_authorization( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for update_dns_authorization Override in a subclass to manipulate the response @@ -654,7 +868,11 @@ def post_update_dns_authorization(self, response: operations_pb2.Operation) -> o """ return response - def pre_get_location(self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]]) -> locations_pb2.Location: + def pre_get_location( + self, + request: locations_pb2.GetLocationRequest, + metadata: Sequence[Tuple[str, str]], + ) -> locations_pb2.Location: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -662,7 +880,9 @@ def pre_get_location(self, request: locations_pb2.GetLocationRequest, metadata: """ return request, metadata - def post_get_location(self, response: locations_pb2.GetLocationRequest) -> locations_pb2.Location: + def post_get_location( + self, response: locations_pb2.GetLocationRequest + ) -> locations_pb2.Location: """Post-rpc interceptor for get_location Override in a subclass to manipulate the response @@ -670,7 +890,12 @@ def post_get_location(self, response: locations_pb2.GetLocationRequest) -> locat it is returned to user code. """ return response - def pre_list_locations(self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]]) -> locations_pb2.ListLocationsResponse: + + def pre_list_locations( + self, + request: locations_pb2.ListLocationsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> locations_pb2.ListLocationsResponse: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -678,7 +903,9 @@ def pre_list_locations(self, request: locations_pb2.ListLocationsRequest, metada """ return request, metadata - def post_list_locations(self, response: locations_pb2.ListLocationsRequest) -> locations_pb2.ListLocationsResponse: + def post_list_locations( + self, response: locations_pb2.ListLocationsRequest + ) -> locations_pb2.ListLocationsResponse: """Post-rpc interceptor for list_locations Override in a subclass to manipulate the response @@ -686,7 +913,12 @@ def post_list_locations(self, response: locations_pb2.ListLocationsRequest) -> l it is returned to user code. """ return response - def pre_cancel_operation(self, request: operations_pb2.CancelOperationRequest, metadata: Sequence[Tuple[str, str]]) -> None: + + def pre_cancel_operation( + self, + request: operations_pb2.CancelOperationRequest, + metadata: Sequence[Tuple[str, str]], + ) -> None: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -694,7 +926,9 @@ def pre_cancel_operation(self, request: operations_pb2.CancelOperationRequest, m """ return request, metadata - def post_cancel_operation(self, response: operations_pb2.CancelOperationRequest) -> None: + def post_cancel_operation( + self, response: operations_pb2.CancelOperationRequest + ) -> None: """Post-rpc interceptor for cancel_operation Override in a subclass to manipulate the response @@ -702,7 +936,12 @@ def post_cancel_operation(self, response: operations_pb2.CancelOperationRequest) it is returned to user code. """ return response - def pre_delete_operation(self, request: operations_pb2.DeleteOperationRequest, metadata: Sequence[Tuple[str, str]]) -> None: + + def pre_delete_operation( + self, + request: operations_pb2.DeleteOperationRequest, + metadata: Sequence[Tuple[str, str]], + ) -> None: """Pre-rpc interceptor for delete_operation Override in a subclass to manipulate the request or metadata @@ -710,7 +949,9 @@ def pre_delete_operation(self, request: operations_pb2.DeleteOperationRequest, m """ return request, metadata - def post_delete_operation(self, response: operations_pb2.DeleteOperationRequest) -> None: + def post_delete_operation( + self, response: operations_pb2.DeleteOperationRequest + ) -> None: """Post-rpc interceptor for delete_operation Override in a subclass to manipulate the response @@ -718,7 +959,12 @@ def post_delete_operation(self, response: operations_pb2.DeleteOperationRequest) it is returned to user code. """ return response - def pre_get_operation(self, request: operations_pb2.GetOperationRequest, metadata: Sequence[Tuple[str, str]]) -> operations_pb2.Operation: + + def pre_get_operation( + self, + request: operations_pb2.GetOperationRequest, + metadata: Sequence[Tuple[str, str]], + ) -> operations_pb2.Operation: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -726,7 +972,9 @@ def pre_get_operation(self, request: operations_pb2.GetOperationRequest, metadat """ return request, metadata - def post_get_operation(self, response: operations_pb2.GetOperationRequest) -> operations_pb2.Operation: + def post_get_operation( + self, response: operations_pb2.GetOperationRequest + ) -> operations_pb2.Operation: """Post-rpc interceptor for get_operation Override in a subclass to manipulate the response @@ -734,7 +982,12 @@ def post_get_operation(self, response: operations_pb2.GetOperationRequest) -> op it is returned to user code. """ return response - def pre_list_operations(self, request: operations_pb2.ListOperationsRequest, metadata: Sequence[Tuple[str, str]]) -> operations_pb2.ListOperationsResponse: + + def pre_list_operations( + self, + request: operations_pb2.ListOperationsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> operations_pb2.ListOperationsResponse: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -742,7 +995,9 @@ def pre_list_operations(self, request: operations_pb2.ListOperationsRequest, met """ return request, metadata - def post_list_operations(self, response: operations_pb2.ListOperationsRequest) -> operations_pb2.ListOperationsResponse: + def post_list_operations( + self, response: operations_pb2.ListOperationsRequest + ) -> operations_pb2.ListOperationsResponse: """Post-rpc interceptor for list_operations Override in a subclass to manipulate the response @@ -799,20 +1054,21 @@ class CertificateManagerRestTransport(CertificateManagerTransport): """ - def __init__(self, *, - host: str = 'certificatemanager.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - client_cert_source_for_mtls: Optional[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, - url_scheme: str = 'https', - interceptor: Optional[CertificateManagerRestInterceptor] = None, - api_audience: Optional[str] = None, - ) -> None: + def __init__( + self, + *, + host: str = "certificatemanager.googleapis.com", + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + client_cert_source_for_mtls: Optional[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, + url_scheme: str = "https", + interceptor: Optional[CertificateManagerRestInterceptor] = None, + api_audience: Optional[str] = None, + ) -> None: """Instantiate the transport. Args: @@ -851,7 +1107,9 @@ def __init__(self, *, # credentials object maybe_url_match = re.match("^(?Phttp(?:s)?://)?(?P.*)$", host) if maybe_url_match is None: - raise ValueError(f"Unexpected hostname structure: {host}") # pragma: NO COVER + raise ValueError( + f"Unexpected hostname structure: {host}" + ) # pragma: NO COVER url_match_items = maybe_url_match.groupdict() @@ -862,10 +1120,11 @@ def __init__(self, *, credentials=credentials, client_info=client_info, always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience + api_audience=api_audience, ) self._session = AuthorizedSession( - self._credentials, default_host=self.DEFAULT_HOST) + self._credentials, default_host=self.DEFAULT_HOST + ) self._operations_client: Optional[operations_v1.AbstractOperationsClient] = None if client_cert_source_for_mtls: self._session.configure_mtls_channel(client_cert_source_for_mtls) @@ -882,42 +1141,45 @@ def operations_client(self) -> operations_v1.AbstractOperationsClient: # Only create a new client if we do not already have one. if self._operations_client is None: http_options: Dict[str, List[Dict[str, str]]] = { - 'google.longrunning.Operations.CancelOperation': [ + "google.longrunning.Operations.CancelOperation": [ { - 'method': 'post', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', - 'body': '*', + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/operations/*}:cancel", + "body": "*", }, ], - 'google.longrunning.Operations.DeleteOperation': [ + "google.longrunning.Operations.DeleteOperation": [ { - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/operations/*}", }, ], - 'google.longrunning.Operations.GetOperation': [ + "google.longrunning.Operations.GetOperation": [ { - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/operations/*}", }, ], - 'google.longrunning.Operations.ListOperations': [ + "google.longrunning.Operations.ListOperations": [ { - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*}/operations', + "method": "get", + "uri": "/v1/{name=projects/*/locations/*}/operations", }, ], } rest_transport = operations_v1.OperationsRestTransport( - host=self._host, - # use the credentials which are saved - credentials=self._credentials, - scopes=self._scopes, - http_options=http_options, - path_prefix="v1") + host=self._host, + # use the credentials which are saved + credentials=self._credentials, + scopes=self._scopes, + http_options=http_options, + path_prefix="v1", + ) - self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) + self._operations_client = operations_v1.AbstractOperationsClient( + transport=rest_transport + ) # Return the client from cache. return self._operations_client @@ -926,19 +1188,26 @@ class _CreateCertificate(CertificateManagerRestStub): def __hash__(self): return hash("CreateCertificate") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - "certificateId" : "", } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "certificateId": "", + } @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.CreateCertificateRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.CreateCertificateRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: r"""Call the create certificate method over HTTP. Args: @@ -958,46 +1227,51 @@ def __call__(self, """ - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/certificates', - 'body': 'certificate', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/certificates", + "body": "certificate", + }, ] - request, metadata = self._interceptor.pre_create_certificate(request, metadata) + request, metadata = self._interceptor.pre_create_certificate( + request, metadata + ) pb_request = certificate_manager.CreateCertificateRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], + transcoded_request["body"], including_default_value_fields=False, - use_integers_for_enums=True + use_integers_for_enums=True, ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), data=body, - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -1014,81 +1288,98 @@ class _CreateCertificateIssuanceConfig(CertificateManagerRestStub): def __hash__(self): return hash("CreateCertificateIssuanceConfig") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - "certificateIssuanceConfigId" : "", } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "certificateIssuanceConfigId": "", + } @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: r"""Call the create certificate - issuance config method over HTTP. + issuance config method over HTTP. - Args: - request (~.gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest): - The request object. Request for the ``CreateCertificateIssuanceConfig`` - method. + Args: + request (~.gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest): + The request object. Request for the ``CreateCertificateIssuanceConfig`` + 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. + 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: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/certificateIssuanceConfigs', - 'body': 'certificate_issuance_config', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/certificateIssuanceConfigs", + "body": "certificate_issuance_config", + }, ] - request, metadata = self._interceptor.pre_create_certificate_issuance_config(request, metadata) - pb_request = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest.pb(request) + ( + request, + metadata, + ) = self._interceptor.pre_create_certificate_issuance_config( + request, metadata + ) + pb_request = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], + transcoded_request["body"], including_default_value_fields=False, - use_integers_for_enums=True + use_integers_for_enums=True, ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), data=body, - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -1105,19 +1396,26 @@ class _CreateCertificateMap(CertificateManagerRestStub): def __hash__(self): return hash("CreateCertificateMap") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - "certificateMapId" : "", } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "certificateMapId": "", + } @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.CreateCertificateMapRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.CreateCertificateMapRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: r"""Call the create certificate map method over HTTP. Args: @@ -1137,46 +1435,51 @@ def __call__(self, """ - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/certificateMaps', - 'body': 'certificate_map', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/certificateMaps", + "body": "certificate_map", + }, ] - request, metadata = self._interceptor.pre_create_certificate_map(request, metadata) + request, metadata = self._interceptor.pre_create_certificate_map( + request, metadata + ) pb_request = certificate_manager.CreateCertificateMapRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], + transcoded_request["body"], including_default_value_fields=False, - use_integers_for_enums=True + use_integers_for_enums=True, ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), data=body, - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -1193,79 +1496,93 @@ class _CreateCertificateMapEntry(CertificateManagerRestStub): def __hash__(self): return hash("CreateCertificateMapEntry") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - "certificateMapEntryId" : "", } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "certificateMapEntryId": "", + } @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.CreateCertificateMapEntryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the create certificate map - entry method over HTTP. - - Args: - request (~.certificate_manager.CreateCertificateMapEntryRequest): - The request object. Request for the ``CreateCertificateMapEntry`` 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. + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + def __call__( + self, + request: certificate_manager.CreateCertificateMapEntryRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the create certificate map + entry method over HTTP. + + Args: + request (~.certificate_manager.CreateCertificateMapEntryRequest): + The request object. Request for the ``CreateCertificateMapEntry`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*/certificateMaps/*}/certificateMapEntries', - 'body': 'certificate_map_entry', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/certificateMaps/*}/certificateMapEntries", + "body": "certificate_map_entry", + }, ] - request, metadata = self._interceptor.pre_create_certificate_map_entry(request, metadata) - pb_request = certificate_manager.CreateCertificateMapEntryRequest.pb(request) + request, metadata = self._interceptor.pre_create_certificate_map_entry( + request, metadata + ) + pb_request = certificate_manager.CreateCertificateMapEntryRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], + transcoded_request["body"], including_default_value_fields=False, - use_integers_for_enums=True + use_integers_for_enums=True, ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), data=body, - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -1282,19 +1599,26 @@ class _CreateDnsAuthorization(CertificateManagerRestStub): def __hash__(self): return hash("CreateDnsAuthorization") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - "dnsAuthorizationId" : "", } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "dnsAuthorizationId": "", + } @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.CreateDnsAuthorizationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.CreateDnsAuthorizationRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: r"""Call the create dns authorization method over HTTP. Args: @@ -1314,46 +1638,51 @@ def __call__(self, """ - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/dnsAuthorizations', - 'body': 'dns_authorization', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/dnsAuthorizations", + "body": "dns_authorization", + }, ] - request, metadata = self._interceptor.pre_create_dns_authorization(request, metadata) + request, metadata = self._interceptor.pre_create_dns_authorization( + request, metadata + ) pb_request = certificate_manager.CreateDnsAuthorizationRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], + transcoded_request["body"], including_default_value_fields=False, - use_integers_for_enums=True + use_integers_for_enums=True, ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), data=body, - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -1370,19 +1699,24 @@ class _DeleteCertificate(CertificateManagerRestStub): def __hash__(self): return hash("DeleteCertificate") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.DeleteCertificateRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.DeleteCertificateRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: r"""Call the delete certificate method over HTTP. Args: @@ -1402,37 +1736,42 @@ def __call__(self, """ - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/certificates/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/certificates/*}", + }, ] - request, metadata = self._interceptor.pre_delete_certificate(request, metadata) + request, metadata = self._interceptor.pre_delete_certificate( + request, metadata + ) pb_request = certificate_manager.DeleteCertificateRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -1449,72 +1788,89 @@ class _DeleteCertificateIssuanceConfig(CertificateManagerRestStub): def __hash__(self): return hash("DeleteCertificateIssuanceConfig") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: r"""Call the delete certificate - issuance config method over HTTP. + issuance config method over HTTP. - Args: - request (~.certificate_issuance_config.DeleteCertificateIssuanceConfigRequest): - The request object. Request for the ``DeleteCertificateIssuanceConfig`` - method. + Args: + request (~.certificate_issuance_config.DeleteCertificateIssuanceConfigRequest): + The request object. Request for the ``DeleteCertificateIssuanceConfig`` + 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. + 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: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/certificateIssuanceConfigs/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/certificateIssuanceConfigs/*}", + }, ] - request, metadata = self._interceptor.pre_delete_certificate_issuance_config(request, metadata) - pb_request = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest.pb(request) + ( + request, + metadata, + ) = self._interceptor.pre_delete_certificate_issuance_config( + request, metadata + ) + pb_request = ( + certificate_issuance_config.DeleteCertificateIssuanceConfigRequest.pb( + request + ) + ) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -1531,19 +1887,24 @@ class _DeleteCertificateMap(CertificateManagerRestStub): def __hash__(self): return hash("DeleteCertificateMap") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.DeleteCertificateMapRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.DeleteCertificateMapRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: r"""Call the delete certificate map method over HTTP. Args: @@ -1563,37 +1924,42 @@ def __call__(self, """ - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/certificateMaps/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/certificateMaps/*}", + }, ] - request, metadata = self._interceptor.pre_delete_certificate_map(request, metadata) + request, metadata = self._interceptor.pre_delete_certificate_map( + request, metadata + ) pb_request = certificate_manager.DeleteCertificateMapRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -1610,70 +1976,82 @@ class _DeleteCertificateMapEntry(CertificateManagerRestStub): def __hash__(self): return hash("DeleteCertificateMapEntry") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.DeleteCertificateMapEntryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete certificate map - entry method over HTTP. - - Args: - request (~.certificate_manager.DeleteCertificateMapEntryRequest): - The request object. Request for the ``DeleteCertificateMapEntry`` 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. + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + def __call__( + self, + request: certificate_manager.DeleteCertificateMapEntryRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete certificate map + entry method over HTTP. + + Args: + request (~.certificate_manager.DeleteCertificateMapEntryRequest): + The request object. Request for the ``DeleteCertificateMapEntry`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}", + }, ] - request, metadata = self._interceptor.pre_delete_certificate_map_entry(request, metadata) - pb_request = certificate_manager.DeleteCertificateMapEntryRequest.pb(request) + request, metadata = self._interceptor.pre_delete_certificate_map_entry( + request, metadata + ) + pb_request = certificate_manager.DeleteCertificateMapEntryRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -1690,19 +2068,24 @@ class _DeleteDnsAuthorization(CertificateManagerRestStub): def __hash__(self): return hash("DeleteDnsAuthorization") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.DeleteDnsAuthorizationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.DeleteDnsAuthorizationRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: r"""Call the delete dns authorization method over HTTP. Args: @@ -1722,37 +2105,42 @@ def __call__(self, """ - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/dnsAuthorizations/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/dnsAuthorizations/*}", + }, ] - request, metadata = self._interceptor.pre_delete_dns_authorization(request, metadata) + request, metadata = self._interceptor.pre_delete_dns_authorization( + request, metadata + ) pb_request = certificate_manager.DeleteDnsAuthorizationRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -1769,19 +2157,24 @@ class _GetCertificate(CertificateManagerRestStub): def __hash__(self): return hash("GetCertificate") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.GetCertificateRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> certificate_manager.Certificate: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.GetCertificateRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.Certificate: r"""Call the get certificate method over HTTP. Args: @@ -1798,37 +2191,40 @@ def __call__(self, Defines TLS certificate. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/certificates/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/certificates/*}", + }, ] request, metadata = self._interceptor.pre_get_certificate(request, metadata) pb_request = certificate_manager.GetCertificateRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -1847,69 +2243,83 @@ class _GetCertificateIssuanceConfig(CertificateManagerRestStub): def __hash__(self): return hash("GetCertificateIssuanceConfig") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_issuance_config.GetCertificateIssuanceConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> certificate_issuance_config.CertificateIssuanceConfig: - r"""Call the get certificate issuance - config method over HTTP. - - Args: - request (~.certificate_issuance_config.GetCertificateIssuanceConfigRequest): - The request object. Request for the ``GetCertificateIssuanceConfig`` 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. + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } - Returns: - ~.certificate_issuance_config.CertificateIssuanceConfig: - CertificateIssuanceConfig specifies - how to issue and manage a certificate. + def __call__( + self, + request: certificate_issuance_config.GetCertificateIssuanceConfigRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_issuance_config.CertificateIssuanceConfig: + r"""Call the get certificate issuance + config method over HTTP. + + Args: + request (~.certificate_issuance_config.GetCertificateIssuanceConfigRequest): + The request object. Request for the ``GetCertificateIssuanceConfig`` 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: + ~.certificate_issuance_config.CertificateIssuanceConfig: + CertificateIssuanceConfig specifies + how to issue and manage a certificate. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/certificateIssuanceConfigs/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/certificateIssuanceConfigs/*}", + }, ] - request, metadata = self._interceptor.pre_get_certificate_issuance_config(request, metadata) - pb_request = certificate_issuance_config.GetCertificateIssuanceConfigRequest.pb(request) + request, metadata = self._interceptor.pre_get_certificate_issuance_config( + request, metadata + ) + pb_request = ( + certificate_issuance_config.GetCertificateIssuanceConfigRequest.pb( + request + ) + ) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -1928,19 +2338,24 @@ class _GetCertificateMap(CertificateManagerRestStub): def __hash__(self): return hash("GetCertificateMap") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.GetCertificateMapRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> certificate_manager.CertificateMap: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.GetCertificateMapRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.CertificateMap: r"""Call the get certificate map method over HTTP. Args: @@ -1959,37 +2374,42 @@ def __call__(self, """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/certificateMaps/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/certificateMaps/*}", + }, ] - request, metadata = self._interceptor.pre_get_certificate_map(request, metadata) + request, metadata = self._interceptor.pre_get_certificate_map( + request, metadata + ) pb_request = certificate_manager.GetCertificateMapRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -2008,19 +2428,24 @@ class _GetCertificateMapEntry(CertificateManagerRestStub): def __hash__(self): return hash("GetCertificateMapEntry") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.GetCertificateMapEntryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> certificate_manager.CertificateMapEntry: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.GetCertificateMapEntryRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.CertificateMapEntry: r"""Call the get certificate map entry method over HTTP. Args: @@ -2037,37 +2462,42 @@ def __call__(self, Defines a certificate map entry. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}", + }, ] - request, metadata = self._interceptor.pre_get_certificate_map_entry(request, metadata) + request, metadata = self._interceptor.pre_get_certificate_map_entry( + request, metadata + ) pb_request = certificate_manager.GetCertificateMapEntryRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -2086,19 +2516,24 @@ class _GetDnsAuthorization(CertificateManagerRestStub): def __hash__(self): return hash("GetDnsAuthorization") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.GetDnsAuthorizationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> certificate_manager.DnsAuthorization: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.GetDnsAuthorizationRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.DnsAuthorization: r"""Call the get dns authorization method over HTTP. Args: @@ -2118,37 +2553,42 @@ def __call__(self, """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/dnsAuthorizations/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/dnsAuthorizations/*}", + }, ] - request, metadata = self._interceptor.pre_get_dns_authorization(request, metadata) + request, metadata = self._interceptor.pre_get_dns_authorization( + request, metadata + ) pb_request = certificate_manager.GetDnsAuthorizationRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -2167,71 +2607,85 @@ class _ListCertificateIssuanceConfigs(CertificateManagerRestStub): def __hash__(self): return hash("ListCertificateIssuanceConfigs") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_issuance_config.ListCertificateIssuanceConfigsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> certificate_issuance_config.ListCertificateIssuanceConfigsResponse: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_issuance_config.ListCertificateIssuanceConfigsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_issuance_config.ListCertificateIssuanceConfigsResponse: r"""Call the list certificate issuance - configs method over HTTP. + configs method over HTTP. - Args: - request (~.certificate_issuance_config.ListCertificateIssuanceConfigsRequest): - The request object. Request for the ``ListCertificateIssuanceConfigs`` - method. + Args: + request (~.certificate_issuance_config.ListCertificateIssuanceConfigsRequest): + The request object. Request for the ``ListCertificateIssuanceConfigs`` + 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. + 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: - ~.certificate_issuance_config.ListCertificateIssuanceConfigsResponse: - Response for the ``ListCertificateIssuanceConfigs`` - method. + Returns: + ~.certificate_issuance_config.ListCertificateIssuanceConfigsResponse: + Response for the ``ListCertificateIssuanceConfigs`` + method. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/certificateIssuanceConfigs', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/certificateIssuanceConfigs", + }, ] - request, metadata = self._interceptor.pre_list_certificate_issuance_configs(request, metadata) - pb_request = certificate_issuance_config.ListCertificateIssuanceConfigsRequest.pb(request) + request, metadata = self._interceptor.pre_list_certificate_issuance_configs( + request, metadata + ) + pb_request = ( + certificate_issuance_config.ListCertificateIssuanceConfigsRequest.pb( + request + ) + ) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -2240,7 +2694,11 @@ def __call__(self, # Return the response resp = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() - pb_resp = certificate_issuance_config.ListCertificateIssuanceConfigsResponse.pb(resp) + pb_resp = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse.pb( + resp + ) + ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_list_certificate_issuance_configs(resp) @@ -2250,67 +2708,79 @@ class _ListCertificateMapEntries(CertificateManagerRestStub): def __hash__(self): return hash("ListCertificateMapEntries") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.ListCertificateMapEntriesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> certificate_manager.ListCertificateMapEntriesResponse: - r"""Call the list certificate map - entries method over HTTP. - - Args: - request (~.certificate_manager.ListCertificateMapEntriesRequest): - The request object. Request for the ``ListCertificateMapEntries`` 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. + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } - Returns: - ~.certificate_manager.ListCertificateMapEntriesResponse: - Response for the ``ListCertificateMapEntries`` method. + def __call__( + self, + request: certificate_manager.ListCertificateMapEntriesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.ListCertificateMapEntriesResponse: + r"""Call the list certificate map + entries method over HTTP. + + Args: + request (~.certificate_manager.ListCertificateMapEntriesRequest): + The request object. Request for the ``ListCertificateMapEntries`` 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: + ~.certificate_manager.ListCertificateMapEntriesResponse: + Response for the ``ListCertificateMapEntries`` method. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/certificateMaps/*}/certificateMapEntries', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/certificateMaps/*}/certificateMapEntries", + }, ] - request, metadata = self._interceptor.pre_list_certificate_map_entries(request, metadata) - pb_request = certificate_manager.ListCertificateMapEntriesRequest.pb(request) + request, metadata = self._interceptor.pre_list_certificate_map_entries( + request, metadata + ) + pb_request = certificate_manager.ListCertificateMapEntriesRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -2329,19 +2799,24 @@ class _ListCertificateMaps(CertificateManagerRestStub): def __hash__(self): return hash("ListCertificateMaps") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.ListCertificateMapsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> certificate_manager.ListCertificateMapsResponse: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.ListCertificateMapsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.ListCertificateMapsResponse: r"""Call the list certificate maps method over HTTP. Args: @@ -2358,37 +2833,42 @@ def __call__(self, Response for the ``ListCertificateMaps`` method. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/certificateMaps', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/certificateMaps", + }, ] - request, metadata = self._interceptor.pre_list_certificate_maps(request, metadata) + request, metadata = self._interceptor.pre_list_certificate_maps( + request, metadata + ) pb_request = certificate_manager.ListCertificateMapsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -2407,19 +2887,24 @@ class _ListCertificates(CertificateManagerRestStub): def __hash__(self): return hash("ListCertificates") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.ListCertificatesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> certificate_manager.ListCertificatesResponse: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.ListCertificatesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.ListCertificatesResponse: r"""Call the list certificates method over HTTP. Args: @@ -2436,37 +2921,42 @@ def __call__(self, Response for the ``ListCertificates`` method. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/certificates', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/certificates", + }, ] - request, metadata = self._interceptor.pre_list_certificates(request, metadata) + request, metadata = self._interceptor.pre_list_certificates( + request, metadata + ) pb_request = certificate_manager.ListCertificatesRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -2485,19 +2975,24 @@ class _ListDnsAuthorizations(CertificateManagerRestStub): def __hash__(self): return hash("ListDnsAuthorizations") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.ListDnsAuthorizationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> certificate_manager.ListDnsAuthorizationsResponse: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.ListDnsAuthorizationsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> certificate_manager.ListDnsAuthorizationsResponse: r"""Call the list dns authorizations method over HTTP. Args: @@ -2514,37 +3009,42 @@ def __call__(self, Response for the ``ListDnsAuthorizations`` method. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/dnsAuthorizations', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/dnsAuthorizations", + }, ] - request, metadata = self._interceptor.pre_list_dns_authorizations(request, metadata) + request, metadata = self._interceptor.pre_list_dns_authorizations( + request, metadata + ) pb_request = certificate_manager.ListDnsAuthorizationsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -2563,19 +3063,26 @@ class _UpdateCertificate(CertificateManagerRestStub): def __hash__(self): return hash("UpdateCertificate") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - "updateMask" : {}, } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "updateMask": {}, + } @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.UpdateCertificateRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.UpdateCertificateRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: r"""Call the update certificate method over HTTP. Args: @@ -2595,46 +3102,51 @@ def __call__(self, """ - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{certificate.name=projects/*/locations/*/certificates/*}', - 'body': 'certificate', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{certificate.name=projects/*/locations/*/certificates/*}", + "body": "certificate", + }, ] - request, metadata = self._interceptor.pre_update_certificate(request, metadata) + request, metadata = self._interceptor.pre_update_certificate( + request, metadata + ) pb_request = certificate_manager.UpdateCertificateRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], + transcoded_request["body"], including_default_value_fields=False, - use_integers_for_enums=True + use_integers_for_enums=True, ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), data=body, - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -2651,19 +3163,26 @@ class _UpdateCertificateMap(CertificateManagerRestStub): def __hash__(self): return hash("UpdateCertificateMap") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - "updateMask" : {}, } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "updateMask": {}, + } @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.UpdateCertificateMapRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.UpdateCertificateMapRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: r"""Call the update certificate map method over HTTP. Args: @@ -2683,46 +3202,51 @@ def __call__(self, """ - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{certificate_map.name=projects/*/locations/*/certificateMaps/*}', - 'body': 'certificate_map', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{certificate_map.name=projects/*/locations/*/certificateMaps/*}", + "body": "certificate_map", + }, ] - request, metadata = self._interceptor.pre_update_certificate_map(request, metadata) + request, metadata = self._interceptor.pre_update_certificate_map( + request, metadata + ) pb_request = certificate_manager.UpdateCertificateMapRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], + transcoded_request["body"], including_default_value_fields=False, - use_integers_for_enums=True + use_integers_for_enums=True, ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), data=body, - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -2739,79 +3263,93 @@ class _UpdateCertificateMapEntry(CertificateManagerRestStub): def __hash__(self): return hash("UpdateCertificateMapEntry") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - "updateMask" : {}, } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "updateMask": {}, + } @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.UpdateCertificateMapEntryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the update certificate map - entry method over HTTP. - - Args: - request (~.certificate_manager.UpdateCertificateMapEntryRequest): - The request object. Request for the ``UpdateCertificateMapEntry`` 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. + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + def __call__( + self, + request: certificate_manager.UpdateCertificateMapEntryRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the update certificate map + entry method over HTTP. + + Args: + request (~.certificate_manager.UpdateCertificateMapEntryRequest): + The request object. Request for the ``UpdateCertificateMapEntry`` 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: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{certificate_map_entry.name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}', - 'body': 'certificate_map_entry', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{certificate_map_entry.name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}", + "body": "certificate_map_entry", + }, ] - request, metadata = self._interceptor.pre_update_certificate_map_entry(request, metadata) - pb_request = certificate_manager.UpdateCertificateMapEntryRequest.pb(request) + request, metadata = self._interceptor.pre_update_certificate_map_entry( + request, metadata + ) + pb_request = certificate_manager.UpdateCertificateMapEntryRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], + transcoded_request["body"], including_default_value_fields=False, - use_integers_for_enums=True + use_integers_for_enums=True, ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), data=body, - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -2828,19 +3366,26 @@ class _UpdateDnsAuthorization(CertificateManagerRestStub): def __hash__(self): return hash("UpdateDnsAuthorization") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { - "updateMask" : {}, } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { + "updateMask": {}, + } @classmethod def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: certificate_manager.UpdateDnsAuthorizationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: certificate_manager.UpdateDnsAuthorizationRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: r"""Call the update dns authorization method over HTTP. Args: @@ -2860,46 +3405,51 @@ def __call__(self, """ - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{dns_authorization.name=projects/*/locations/*/dnsAuthorizations/*}', - 'body': 'dns_authorization', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{dns_authorization.name=projects/*/locations/*/dnsAuthorizations/*}", + "body": "dns_authorization", + }, ] - request, metadata = self._interceptor.pre_update_dns_authorization(request, metadata) + request, metadata = self._interceptor.pre_update_dns_authorization( + request, metadata + ) pb_request = certificate_manager.UpdateDnsAuthorizationRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], + transcoded_request["body"], including_default_value_fields=False, - use_integers_for_enums=True + use_integers_for_enums=True, ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) query_params.update(self._get_unset_required_fields(query_params)) query_params["$alt"] = "json;enum-encoding=int" # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), data=body, - ) + ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception # subclass. @@ -2913,208 +3463,269 @@ def __call__(self, return resp @property - def create_certificate(self) -> Callable[ - [certificate_manager.CreateCertificateRequest], - operations_pb2.Operation]: + def create_certificate( + self, + ) -> Callable[ + [certificate_manager.CreateCertificateRequest], operations_pb2.Operation + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._CreateCertificate(self._session, self._host, self._interceptor) # type: ignore + return self._CreateCertificate(self._session, self._host, self._interceptor) # type: ignore @property - def create_certificate_issuance_config(self) -> Callable[ - [gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest], - operations_pb2.Operation]: + def create_certificate_issuance_config( + self, + ) -> Callable[ + [gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest], + operations_pb2.Operation, + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._CreateCertificateIssuanceConfig(self._session, self._host, self._interceptor) # type: ignore + return self._CreateCertificateIssuanceConfig(self._session, self._host, self._interceptor) # type: ignore @property - def create_certificate_map(self) -> Callable[ - [certificate_manager.CreateCertificateMapRequest], - operations_pb2.Operation]: + def create_certificate_map( + self, + ) -> Callable[ + [certificate_manager.CreateCertificateMapRequest], operations_pb2.Operation + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._CreateCertificateMap(self._session, self._host, self._interceptor) # type: ignore + return self._CreateCertificateMap(self._session, self._host, self._interceptor) # type: ignore @property - def create_certificate_map_entry(self) -> Callable[ - [certificate_manager.CreateCertificateMapEntryRequest], - operations_pb2.Operation]: + def create_certificate_map_entry( + self, + ) -> Callable[ + [certificate_manager.CreateCertificateMapEntryRequest], operations_pb2.Operation + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._CreateCertificateMapEntry(self._session, self._host, self._interceptor) # type: ignore + return self._CreateCertificateMapEntry(self._session, self._host, self._interceptor) # type: ignore @property - def create_dns_authorization(self) -> Callable[ - [certificate_manager.CreateDnsAuthorizationRequest], - operations_pb2.Operation]: + def create_dns_authorization( + self, + ) -> Callable[ + [certificate_manager.CreateDnsAuthorizationRequest], operations_pb2.Operation + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._CreateDnsAuthorization(self._session, self._host, self._interceptor) # type: ignore + return self._CreateDnsAuthorization(self._session, self._host, self._interceptor) # type: ignore @property - def delete_certificate(self) -> Callable[ - [certificate_manager.DeleteCertificateRequest], - operations_pb2.Operation]: + def delete_certificate( + self, + ) -> Callable[ + [certificate_manager.DeleteCertificateRequest], operations_pb2.Operation + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._DeleteCertificate(self._session, self._host, self._interceptor) # type: ignore + return self._DeleteCertificate(self._session, self._host, self._interceptor) # type: ignore @property - def delete_certificate_issuance_config(self) -> Callable[ - [certificate_issuance_config.DeleteCertificateIssuanceConfigRequest], - operations_pb2.Operation]: + def delete_certificate_issuance_config( + self, + ) -> Callable[ + [certificate_issuance_config.DeleteCertificateIssuanceConfigRequest], + operations_pb2.Operation, + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._DeleteCertificateIssuanceConfig(self._session, self._host, self._interceptor) # type: ignore + return self._DeleteCertificateIssuanceConfig(self._session, self._host, self._interceptor) # type: ignore @property - def delete_certificate_map(self) -> Callable[ - [certificate_manager.DeleteCertificateMapRequest], - operations_pb2.Operation]: + def delete_certificate_map( + self, + ) -> Callable[ + [certificate_manager.DeleteCertificateMapRequest], operations_pb2.Operation + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._DeleteCertificateMap(self._session, self._host, self._interceptor) # type: ignore + return self._DeleteCertificateMap(self._session, self._host, self._interceptor) # type: ignore @property - def delete_certificate_map_entry(self) -> Callable[ - [certificate_manager.DeleteCertificateMapEntryRequest], - operations_pb2.Operation]: + def delete_certificate_map_entry( + self, + ) -> Callable[ + [certificate_manager.DeleteCertificateMapEntryRequest], operations_pb2.Operation + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._DeleteCertificateMapEntry(self._session, self._host, self._interceptor) # type: ignore + return self._DeleteCertificateMapEntry(self._session, self._host, self._interceptor) # type: ignore @property - def delete_dns_authorization(self) -> Callable[ - [certificate_manager.DeleteDnsAuthorizationRequest], - operations_pb2.Operation]: + def delete_dns_authorization( + self, + ) -> Callable[ + [certificate_manager.DeleteDnsAuthorizationRequest], operations_pb2.Operation + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._DeleteDnsAuthorization(self._session, self._host, self._interceptor) # type: ignore + return self._DeleteDnsAuthorization(self._session, self._host, self._interceptor) # type: ignore @property - def get_certificate(self) -> Callable[ - [certificate_manager.GetCertificateRequest], - certificate_manager.Certificate]: + def get_certificate( + self, + ) -> Callable[ + [certificate_manager.GetCertificateRequest], certificate_manager.Certificate + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._GetCertificate(self._session, self._host, self._interceptor) # type: ignore + return self._GetCertificate(self._session, self._host, self._interceptor) # type: ignore @property - def get_certificate_issuance_config(self) -> Callable[ - [certificate_issuance_config.GetCertificateIssuanceConfigRequest], - certificate_issuance_config.CertificateIssuanceConfig]: + def get_certificate_issuance_config( + self, + ) -> Callable[ + [certificate_issuance_config.GetCertificateIssuanceConfigRequest], + certificate_issuance_config.CertificateIssuanceConfig, + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._GetCertificateIssuanceConfig(self._session, self._host, self._interceptor) # type: ignore + return self._GetCertificateIssuanceConfig(self._session, self._host, self._interceptor) # type: ignore @property - def get_certificate_map(self) -> Callable[ - [certificate_manager.GetCertificateMapRequest], - certificate_manager.CertificateMap]: + def get_certificate_map( + self, + ) -> Callable[ + [certificate_manager.GetCertificateMapRequest], + certificate_manager.CertificateMap, + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._GetCertificateMap(self._session, self._host, self._interceptor) # type: ignore + return self._GetCertificateMap(self._session, self._host, self._interceptor) # type: ignore @property - def get_certificate_map_entry(self) -> Callable[ - [certificate_manager.GetCertificateMapEntryRequest], - certificate_manager.CertificateMapEntry]: + def get_certificate_map_entry( + self, + ) -> Callable[ + [certificate_manager.GetCertificateMapEntryRequest], + certificate_manager.CertificateMapEntry, + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._GetCertificateMapEntry(self._session, self._host, self._interceptor) # type: ignore + return self._GetCertificateMapEntry(self._session, self._host, self._interceptor) # type: ignore @property - def get_dns_authorization(self) -> Callable[ - [certificate_manager.GetDnsAuthorizationRequest], - certificate_manager.DnsAuthorization]: + def get_dns_authorization( + self, + ) -> Callable[ + [certificate_manager.GetDnsAuthorizationRequest], + certificate_manager.DnsAuthorization, + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._GetDnsAuthorization(self._session, self._host, self._interceptor) # type: ignore + return self._GetDnsAuthorization(self._session, self._host, self._interceptor) # type: ignore @property - def list_certificate_issuance_configs(self) -> Callable[ - [certificate_issuance_config.ListCertificateIssuanceConfigsRequest], - certificate_issuance_config.ListCertificateIssuanceConfigsResponse]: + def list_certificate_issuance_configs( + self, + ) -> Callable[ + [certificate_issuance_config.ListCertificateIssuanceConfigsRequest], + certificate_issuance_config.ListCertificateIssuanceConfigsResponse, + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._ListCertificateIssuanceConfigs(self._session, self._host, self._interceptor) # type: ignore + return self._ListCertificateIssuanceConfigs(self._session, self._host, self._interceptor) # type: ignore @property - def list_certificate_map_entries(self) -> Callable[ - [certificate_manager.ListCertificateMapEntriesRequest], - certificate_manager.ListCertificateMapEntriesResponse]: + def list_certificate_map_entries( + self, + ) -> Callable[ + [certificate_manager.ListCertificateMapEntriesRequest], + certificate_manager.ListCertificateMapEntriesResponse, + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._ListCertificateMapEntries(self._session, self._host, self._interceptor) # type: ignore + return self._ListCertificateMapEntries(self._session, self._host, self._interceptor) # type: ignore @property - def list_certificate_maps(self) -> Callable[ - [certificate_manager.ListCertificateMapsRequest], - certificate_manager.ListCertificateMapsResponse]: + def list_certificate_maps( + self, + ) -> Callable[ + [certificate_manager.ListCertificateMapsRequest], + certificate_manager.ListCertificateMapsResponse, + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._ListCertificateMaps(self._session, self._host, self._interceptor) # type: ignore + return self._ListCertificateMaps(self._session, self._host, self._interceptor) # type: ignore @property - def list_certificates(self) -> Callable[ - [certificate_manager.ListCertificatesRequest], - certificate_manager.ListCertificatesResponse]: + def list_certificates( + self, + ) -> Callable[ + [certificate_manager.ListCertificatesRequest], + certificate_manager.ListCertificatesResponse, + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._ListCertificates(self._session, self._host, self._interceptor) # type: ignore + return self._ListCertificates(self._session, self._host, self._interceptor) # type: ignore @property - def list_dns_authorizations(self) -> Callable[ - [certificate_manager.ListDnsAuthorizationsRequest], - certificate_manager.ListDnsAuthorizationsResponse]: + def list_dns_authorizations( + self, + ) -> Callable[ + [certificate_manager.ListDnsAuthorizationsRequest], + certificate_manager.ListDnsAuthorizationsResponse, + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._ListDnsAuthorizations(self._session, self._host, self._interceptor) # type: ignore + return self._ListDnsAuthorizations(self._session, self._host, self._interceptor) # type: ignore @property - def update_certificate(self) -> Callable[ - [certificate_manager.UpdateCertificateRequest], - operations_pb2.Operation]: + def update_certificate( + self, + ) -> Callable[ + [certificate_manager.UpdateCertificateRequest], operations_pb2.Operation + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._UpdateCertificate(self._session, self._host, self._interceptor) # type: ignore + return self._UpdateCertificate(self._session, self._host, self._interceptor) # type: ignore @property - def update_certificate_map(self) -> Callable[ - [certificate_manager.UpdateCertificateMapRequest], - operations_pb2.Operation]: + def update_certificate_map( + self, + ) -> Callable[ + [certificate_manager.UpdateCertificateMapRequest], operations_pb2.Operation + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._UpdateCertificateMap(self._session, self._host, self._interceptor) # type: ignore + return self._UpdateCertificateMap(self._session, self._host, self._interceptor) # type: ignore @property - def update_certificate_map_entry(self) -> Callable[ - [certificate_manager.UpdateCertificateMapEntryRequest], - operations_pb2.Operation]: + def update_certificate_map_entry( + self, + ) -> Callable[ + [certificate_manager.UpdateCertificateMapEntryRequest], operations_pb2.Operation + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._UpdateCertificateMapEntry(self._session, self._host, self._interceptor) # type: ignore + return self._UpdateCertificateMapEntry(self._session, self._host, self._interceptor) # type: ignore @property - def update_dns_authorization(self) -> Callable[ - [certificate_manager.UpdateDnsAuthorizationRequest], - operations_pb2.Operation]: + def update_dns_authorization( + self, + ) -> Callable[ + [certificate_manager.UpdateDnsAuthorizationRequest], operations_pb2.Operation + ]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast - return self._UpdateDnsAuthorization(self._session, self._host, self._interceptor) # type: ignore + return self._UpdateDnsAuthorization(self._session, self._host, self._interceptor) # type: ignore @property def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore + return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore class _GetLocation(CertificateManagerRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: + def __call__( + self, + request: locations_pb2.GetLocationRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -3131,26 +3742,26 @@ def __call__(self, locations_pb2.Location: Response from GetLocation method. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*}", + }, ] request, metadata = self._interceptor.pre_get_location(request, metadata) request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) + transcoded_request = path_template.transcode(http_options, **request_kwargs) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json.dumps(transcoded_request['query_params'])) + query_params = json.loads(json.dumps(transcoded_request["query_params"])) # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), @@ -3171,15 +3782,17 @@ def __call__(self, @property def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore + return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore class _ListLocations(CertificateManagerRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: + def __call__( + self, + request: locations_pb2.ListLocationsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -3196,26 +3809,26 @@ def __call__(self, locations_pb2.ListLocationsResponse: Response from ListLocations method. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*}/locations', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*}/locations", + }, ] request, metadata = self._interceptor.pre_list_locations(request, metadata) request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) + transcoded_request = path_template.transcode(http_options, **request_kwargs) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json.dumps(transcoded_request['query_params'])) + query_params = json.loads(json.dumps(transcoded_request["query_params"])) # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), @@ -3236,15 +3849,17 @@ def __call__(self, @property def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore + return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore class _CancelOperation(CertificateManagerRestStub): - def __call__(self, - request: operations_pb2.CancelOperationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> None: + def __call__( + self, + request: operations_pb2.CancelOperationRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: r"""Call the cancel operation method over HTTP. @@ -3258,28 +3873,30 @@ def __call__(self, sent along with the request as metadata. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', - 'body': '*', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/operations/*}:cancel", + "body": "*", + }, ] - request, metadata = self._interceptor.pre_cancel_operation(request, metadata) + request, metadata = self._interceptor.pre_cancel_operation( + request, metadata + ) request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) + transcoded_request = path_template.transcode(http_options, **request_kwargs) - body = json.loads(json.dumps(transcoded_request['body'])) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + body = json.loads(json.dumps(transcoded_request["body"])) + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json.dumps(transcoded_request['query_params'])) + query_params = json.loads(json.dumps(transcoded_request["query_params"])) # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), @@ -3298,15 +3915,17 @@ def __call__(self, @property def delete_operation(self): - return self._DeleteOperation(self._session, self._host, self._interceptor) # type: ignore + return self._DeleteOperation(self._session, self._host, self._interceptor) # type: ignore class _DeleteOperation(CertificateManagerRestStub): - def __call__(self, - request: operations_pb2.DeleteOperationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> None: + def __call__( + self, + request: operations_pb2.DeleteOperationRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: r"""Call the delete operation method over HTTP. @@ -3320,26 +3939,28 @@ def __call__(self, sent along with the request as metadata. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/operations/*}", + }, ] - request, metadata = self._interceptor.pre_delete_operation(request, metadata) + request, metadata = self._interceptor.pre_delete_operation( + request, metadata + ) request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) + transcoded_request = path_template.transcode(http_options, **request_kwargs) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json.dumps(transcoded_request['query_params'])) + query_params = json.loads(json.dumps(transcoded_request["query_params"])) # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), @@ -3357,15 +3978,17 @@ def __call__(self, @property def get_operation(self): - return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore + return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore class _GetOperation(CertificateManagerRestStub): - def __call__(self, - request: operations_pb2.GetOperationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: + def __call__( + self, + request: operations_pb2.GetOperationRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -3382,26 +4005,26 @@ def __call__(self, operations_pb2.Operation: Response from GetOperation method. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/operations/*}", + }, ] request, metadata = self._interceptor.pre_get_operation(request, metadata) request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) + transcoded_request = path_template.transcode(http_options, **request_kwargs) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json.dumps(transcoded_request['query_params'])) + query_params = json.loads(json.dumps(transcoded_request["query_params"])) # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), @@ -3422,15 +4045,17 @@ def __call__(self, @property def list_operations(self): - return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore + return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore class _ListOperations(CertificateManagerRestStub): - def __call__(self, - request: operations_pb2.ListOperationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.ListOperationsResponse: + def __call__( + self, + request: operations_pb2.ListOperationsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -3447,26 +4072,26 @@ def __call__(self, operations_pb2.ListOperationsResponse: Response from ListOperations method. """ - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*}/operations', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*}/operations", + }, ] request, metadata = self._interceptor.pre_list_operations(request, metadata) request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) + transcoded_request = path_template.transcode(http_options, **request_kwargs) - uri = transcoded_request['uri'] - method = transcoded_request['method'] + uri = transcoded_request["uri"] + method = transcoded_request["method"] # Jsonify the query params - query_params = json.loads(json.dumps(transcoded_request['query_params'])) + query_params = json.loads(json.dumps(transcoded_request["query_params"])) # Send the request headers = dict(metadata) - headers['Content-Type'] = 'application/json' + headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), @@ -3493,6 +4118,4 @@ def close(self): self._session.close() -__all__=( - 'CertificateManagerRestTransport', -) +__all__ = ("CertificateManagerRestTransport",) diff --git a/owl-bot-staging/v1/.coveragerc b/owl-bot-staging/v1/.coveragerc deleted file mode 100644 index ca7b438..0000000 --- a/owl-bot-staging/v1/.coveragerc +++ /dev/null @@ -1,13 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/certificate_manager/__init__.py - google/cloud/certificate_manager/gapic_version.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ diff --git a/owl-bot-staging/v1/.flake8 b/owl-bot-staging/v1/.flake8 deleted file mode 100644 index 29227d4..0000000 --- a/owl-bot-staging/v1/.flake8 +++ /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 -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Generated by synthtool. DO NOT EDIT! -[flake8] -ignore = E203, E266, E501, W503 -exclude = - # Exclude generated code. - **/proto/** - **/gapic/** - **/services/** - **/types/** - *_pb2.py - - # Standard linting exemptions. - **/.nox/** - __pycache__, - .git, - *.pyc, - conf.py diff --git a/owl-bot-staging/v1/MANIFEST.in b/owl-bot-staging/v1/MANIFEST.in deleted file mode 100644 index 7f4b675..0000000 --- a/owl-bot-staging/v1/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/certificate_manager *.py -recursive-include google/cloud/certificate_manager_v1 *.py diff --git a/owl-bot-staging/v1/README.rst b/owl-bot-staging/v1/README.rst deleted file mode 100644 index 531c68e..0000000 --- a/owl-bot-staging/v1/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Certificate Manager 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 Certificate Manager 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/certificate_manager_v1/certificate_manager.rst b/owl-bot-staging/v1/docs/certificate_manager_v1/certificate_manager.rst deleted file mode 100644 index 46e71d3..0000000 --- a/owl-bot-staging/v1/docs/certificate_manager_v1/certificate_manager.rst +++ /dev/null @@ -1,10 +0,0 @@ -CertificateManager ------------------------------------- - -.. automodule:: google.cloud.certificate_manager_v1.services.certificate_manager - :members: - :inherited-members: - -.. automodule:: google.cloud.certificate_manager_v1.services.certificate_manager.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v1/docs/certificate_manager_v1/services.rst b/owl-bot-staging/v1/docs/certificate_manager_v1/services.rst deleted file mode 100644 index e52959e..0000000 --- a/owl-bot-staging/v1/docs/certificate_manager_v1/services.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Certificate Manager v1 API -==================================================== -.. toctree:: - :maxdepth: 2 - - certificate_manager diff --git a/owl-bot-staging/v1/docs/certificate_manager_v1/types.rst b/owl-bot-staging/v1/docs/certificate_manager_v1/types.rst deleted file mode 100644 index cb69a66..0000000 --- a/owl-bot-staging/v1/docs/certificate_manager_v1/types.rst +++ /dev/null @@ -1,6 +0,0 @@ -Types for Google Cloud Certificate Manager v1 API -================================================= - -.. automodule:: google.cloud.certificate_manager_v1.types - :members: - :show-inheritance: diff --git a/owl-bot-staging/v1/docs/conf.py b/owl-bot-staging/v1/docs/conf.py deleted file mode 100644 index b7f32aa..0000000 --- a/owl-bot-staging/v1/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# google-cloud-certificate-manager 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 = "4.0.1" - -# 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 root toctree document. -root_doc = "index" - -# General information about the project. -project = u"google-cloud-certificate-manager" -copyright = u"2022, 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-certificate-manager-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 = [ - ( - root_doc, - "google-cloud-certificate-manager.tex", - u"google-cloud-certificate-manager 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 = [ - ( - root_doc, - "google-cloud-certificate-manager", - u"Google Cloud Certificate Manager 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 = [ - ( - root_doc, - "google-cloud-certificate-manager", - u"google-cloud-certificate-manager Documentation", - author, - "google-cloud-certificate-manager", - "GAPIC library for Google Cloud Certificate Manager 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 b0ad281..0000000 --- a/owl-bot-staging/v1/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - certificate_manager_v1/services - certificate_manager_v1/types diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager/__init__.py b/owl-bot-staging/v1/google/cloud/certificate_manager/__init__.py deleted file mode 100644 index 0a9d6ba..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager/__init__.py +++ /dev/null @@ -1,99 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from google.cloud.certificate_manager import gapic_version as package_version - -__version__ = package_version.__version__ - - -from google.cloud.certificate_manager_v1.services.certificate_manager.client import CertificateManagerClient -from google.cloud.certificate_manager_v1.services.certificate_manager.async_client import CertificateManagerAsyncClient - -from google.cloud.certificate_manager_v1.types.certificate_issuance_config import CertificateIssuanceConfig -from google.cloud.certificate_manager_v1.types.certificate_issuance_config import CreateCertificateIssuanceConfigRequest -from google.cloud.certificate_manager_v1.types.certificate_issuance_config import DeleteCertificateIssuanceConfigRequest -from google.cloud.certificate_manager_v1.types.certificate_issuance_config import GetCertificateIssuanceConfigRequest -from google.cloud.certificate_manager_v1.types.certificate_issuance_config import ListCertificateIssuanceConfigsRequest -from google.cloud.certificate_manager_v1.types.certificate_issuance_config import ListCertificateIssuanceConfigsResponse -from google.cloud.certificate_manager_v1.types.certificate_manager import Certificate -from google.cloud.certificate_manager_v1.types.certificate_manager import CertificateMap -from google.cloud.certificate_manager_v1.types.certificate_manager import CertificateMapEntry -from google.cloud.certificate_manager_v1.types.certificate_manager import CreateCertificateMapEntryRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import CreateCertificateMapRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import CreateCertificateRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import CreateDnsAuthorizationRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import DeleteCertificateMapEntryRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import DeleteCertificateMapRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import DeleteCertificateRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import DeleteDnsAuthorizationRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import DnsAuthorization -from google.cloud.certificate_manager_v1.types.certificate_manager import GetCertificateMapEntryRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import GetCertificateMapRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import GetCertificateRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import GetDnsAuthorizationRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import ListCertificateMapEntriesRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import ListCertificateMapEntriesResponse -from google.cloud.certificate_manager_v1.types.certificate_manager import ListCertificateMapsRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import ListCertificateMapsResponse -from google.cloud.certificate_manager_v1.types.certificate_manager import ListCertificatesRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import ListCertificatesResponse -from google.cloud.certificate_manager_v1.types.certificate_manager import ListDnsAuthorizationsRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import ListDnsAuthorizationsResponse -from google.cloud.certificate_manager_v1.types.certificate_manager import OperationMetadata -from google.cloud.certificate_manager_v1.types.certificate_manager import UpdateCertificateMapEntryRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import UpdateCertificateMapRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import UpdateCertificateRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import UpdateDnsAuthorizationRequest -from google.cloud.certificate_manager_v1.types.certificate_manager import ServingState - -__all__ = ('CertificateManagerClient', - 'CertificateManagerAsyncClient', - 'CertificateIssuanceConfig', - 'CreateCertificateIssuanceConfigRequest', - 'DeleteCertificateIssuanceConfigRequest', - 'GetCertificateIssuanceConfigRequest', - 'ListCertificateIssuanceConfigsRequest', - 'ListCertificateIssuanceConfigsResponse', - 'Certificate', - 'CertificateMap', - 'CertificateMapEntry', - 'CreateCertificateMapEntryRequest', - 'CreateCertificateMapRequest', - 'CreateCertificateRequest', - 'CreateDnsAuthorizationRequest', - 'DeleteCertificateMapEntryRequest', - 'DeleteCertificateMapRequest', - 'DeleteCertificateRequest', - 'DeleteDnsAuthorizationRequest', - 'DnsAuthorization', - 'GetCertificateMapEntryRequest', - 'GetCertificateMapRequest', - 'GetCertificateRequest', - 'GetDnsAuthorizationRequest', - 'ListCertificateMapEntriesRequest', - 'ListCertificateMapEntriesResponse', - 'ListCertificateMapsRequest', - 'ListCertificateMapsResponse', - 'ListCertificatesRequest', - 'ListCertificatesResponse', - 'ListDnsAuthorizationsRequest', - 'ListDnsAuthorizationsResponse', - 'OperationMetadata', - 'UpdateCertificateMapEntryRequest', - 'UpdateCertificateMapRequest', - 'UpdateCertificateRequest', - 'UpdateDnsAuthorizationRequest', - 'ServingState', -) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager/gapic_version.py b/owl-bot-staging/v1/google/cloud/certificate_manager/gapic_version.py deleted file mode 100644 index 405b1ce..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -__version__ = "0.1.0" # {x-release-please-version} diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager/py.typed b/owl-bot-staging/v1/google/cloud/certificate_manager/py.typed deleted file mode 100644 index 9e0b37d..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-certificate-manager package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/__init__.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/__init__.py deleted file mode 100644 index 6134c17..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/__init__.py +++ /dev/null @@ -1,100 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from google.cloud.certificate_manager_v1 import gapic_version as package_version - -__version__ = package_version.__version__ - - -from .services.certificate_manager import CertificateManagerClient -from .services.certificate_manager import CertificateManagerAsyncClient - -from .types.certificate_issuance_config import CertificateIssuanceConfig -from .types.certificate_issuance_config import CreateCertificateIssuanceConfigRequest -from .types.certificate_issuance_config import DeleteCertificateIssuanceConfigRequest -from .types.certificate_issuance_config import GetCertificateIssuanceConfigRequest -from .types.certificate_issuance_config import ListCertificateIssuanceConfigsRequest -from .types.certificate_issuance_config import ListCertificateIssuanceConfigsResponse -from .types.certificate_manager import Certificate -from .types.certificate_manager import CertificateMap -from .types.certificate_manager import CertificateMapEntry -from .types.certificate_manager import CreateCertificateMapEntryRequest -from .types.certificate_manager import CreateCertificateMapRequest -from .types.certificate_manager import CreateCertificateRequest -from .types.certificate_manager import CreateDnsAuthorizationRequest -from .types.certificate_manager import DeleteCertificateMapEntryRequest -from .types.certificate_manager import DeleteCertificateMapRequest -from .types.certificate_manager import DeleteCertificateRequest -from .types.certificate_manager import DeleteDnsAuthorizationRequest -from .types.certificate_manager import DnsAuthorization -from .types.certificate_manager import GetCertificateMapEntryRequest -from .types.certificate_manager import GetCertificateMapRequest -from .types.certificate_manager import GetCertificateRequest -from .types.certificate_manager import GetDnsAuthorizationRequest -from .types.certificate_manager import ListCertificateMapEntriesRequest -from .types.certificate_manager import ListCertificateMapEntriesResponse -from .types.certificate_manager import ListCertificateMapsRequest -from .types.certificate_manager import ListCertificateMapsResponse -from .types.certificate_manager import ListCertificatesRequest -from .types.certificate_manager import ListCertificatesResponse -from .types.certificate_manager import ListDnsAuthorizationsRequest -from .types.certificate_manager import ListDnsAuthorizationsResponse -from .types.certificate_manager import OperationMetadata -from .types.certificate_manager import UpdateCertificateMapEntryRequest -from .types.certificate_manager import UpdateCertificateMapRequest -from .types.certificate_manager import UpdateCertificateRequest -from .types.certificate_manager import UpdateDnsAuthorizationRequest -from .types.certificate_manager import ServingState - -__all__ = ( - 'CertificateManagerAsyncClient', -'Certificate', -'CertificateIssuanceConfig', -'CertificateManagerClient', -'CertificateMap', -'CertificateMapEntry', -'CreateCertificateIssuanceConfigRequest', -'CreateCertificateMapEntryRequest', -'CreateCertificateMapRequest', -'CreateCertificateRequest', -'CreateDnsAuthorizationRequest', -'DeleteCertificateIssuanceConfigRequest', -'DeleteCertificateMapEntryRequest', -'DeleteCertificateMapRequest', -'DeleteCertificateRequest', -'DeleteDnsAuthorizationRequest', -'DnsAuthorization', -'GetCertificateIssuanceConfigRequest', -'GetCertificateMapEntryRequest', -'GetCertificateMapRequest', -'GetCertificateRequest', -'GetDnsAuthorizationRequest', -'ListCertificateIssuanceConfigsRequest', -'ListCertificateIssuanceConfigsResponse', -'ListCertificateMapEntriesRequest', -'ListCertificateMapEntriesResponse', -'ListCertificateMapsRequest', -'ListCertificateMapsResponse', -'ListCertificatesRequest', -'ListCertificatesResponse', -'ListDnsAuthorizationsRequest', -'ListDnsAuthorizationsResponse', -'OperationMetadata', -'ServingState', -'UpdateCertificateMapEntryRequest', -'UpdateCertificateMapRequest', -'UpdateCertificateRequest', -'UpdateDnsAuthorizationRequest', -) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_metadata.json b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_metadata.json deleted file mode 100644 index 0c07957..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_metadata.json +++ /dev/null @@ -1,388 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.certificate_manager_v1", - "protoPackage": "google.cloud.certificatemanager.v1", - "schema": "1.0", - "services": { - "CertificateManager": { - "clients": { - "grpc": { - "libraryClient": "CertificateManagerClient", - "rpcs": { - "CreateCertificate": { - "methods": [ - "create_certificate" - ] - }, - "CreateCertificateIssuanceConfig": { - "methods": [ - "create_certificate_issuance_config" - ] - }, - "CreateCertificateMap": { - "methods": [ - "create_certificate_map" - ] - }, - "CreateCertificateMapEntry": { - "methods": [ - "create_certificate_map_entry" - ] - }, - "CreateDnsAuthorization": { - "methods": [ - "create_dns_authorization" - ] - }, - "DeleteCertificate": { - "methods": [ - "delete_certificate" - ] - }, - "DeleteCertificateIssuanceConfig": { - "methods": [ - "delete_certificate_issuance_config" - ] - }, - "DeleteCertificateMap": { - "methods": [ - "delete_certificate_map" - ] - }, - "DeleteCertificateMapEntry": { - "methods": [ - "delete_certificate_map_entry" - ] - }, - "DeleteDnsAuthorization": { - "methods": [ - "delete_dns_authorization" - ] - }, - "GetCertificate": { - "methods": [ - "get_certificate" - ] - }, - "GetCertificateIssuanceConfig": { - "methods": [ - "get_certificate_issuance_config" - ] - }, - "GetCertificateMap": { - "methods": [ - "get_certificate_map" - ] - }, - "GetCertificateMapEntry": { - "methods": [ - "get_certificate_map_entry" - ] - }, - "GetDnsAuthorization": { - "methods": [ - "get_dns_authorization" - ] - }, - "ListCertificateIssuanceConfigs": { - "methods": [ - "list_certificate_issuance_configs" - ] - }, - "ListCertificateMapEntries": { - "methods": [ - "list_certificate_map_entries" - ] - }, - "ListCertificateMaps": { - "methods": [ - "list_certificate_maps" - ] - }, - "ListCertificates": { - "methods": [ - "list_certificates" - ] - }, - "ListDnsAuthorizations": { - "methods": [ - "list_dns_authorizations" - ] - }, - "UpdateCertificate": { - "methods": [ - "update_certificate" - ] - }, - "UpdateCertificateMap": { - "methods": [ - "update_certificate_map" - ] - }, - "UpdateCertificateMapEntry": { - "methods": [ - "update_certificate_map_entry" - ] - }, - "UpdateDnsAuthorization": { - "methods": [ - "update_dns_authorization" - ] - } - } - }, - "grpc-async": { - "libraryClient": "CertificateManagerAsyncClient", - "rpcs": { - "CreateCertificate": { - "methods": [ - "create_certificate" - ] - }, - "CreateCertificateIssuanceConfig": { - "methods": [ - "create_certificate_issuance_config" - ] - }, - "CreateCertificateMap": { - "methods": [ - "create_certificate_map" - ] - }, - "CreateCertificateMapEntry": { - "methods": [ - "create_certificate_map_entry" - ] - }, - "CreateDnsAuthorization": { - "methods": [ - "create_dns_authorization" - ] - }, - "DeleteCertificate": { - "methods": [ - "delete_certificate" - ] - }, - "DeleteCertificateIssuanceConfig": { - "methods": [ - "delete_certificate_issuance_config" - ] - }, - "DeleteCertificateMap": { - "methods": [ - "delete_certificate_map" - ] - }, - "DeleteCertificateMapEntry": { - "methods": [ - "delete_certificate_map_entry" - ] - }, - "DeleteDnsAuthorization": { - "methods": [ - "delete_dns_authorization" - ] - }, - "GetCertificate": { - "methods": [ - "get_certificate" - ] - }, - "GetCertificateIssuanceConfig": { - "methods": [ - "get_certificate_issuance_config" - ] - }, - "GetCertificateMap": { - "methods": [ - "get_certificate_map" - ] - }, - "GetCertificateMapEntry": { - "methods": [ - "get_certificate_map_entry" - ] - }, - "GetDnsAuthorization": { - "methods": [ - "get_dns_authorization" - ] - }, - "ListCertificateIssuanceConfigs": { - "methods": [ - "list_certificate_issuance_configs" - ] - }, - "ListCertificateMapEntries": { - "methods": [ - "list_certificate_map_entries" - ] - }, - "ListCertificateMaps": { - "methods": [ - "list_certificate_maps" - ] - }, - "ListCertificates": { - "methods": [ - "list_certificates" - ] - }, - "ListDnsAuthorizations": { - "methods": [ - "list_dns_authorizations" - ] - }, - "UpdateCertificate": { - "methods": [ - "update_certificate" - ] - }, - "UpdateCertificateMap": { - "methods": [ - "update_certificate_map" - ] - }, - "UpdateCertificateMapEntry": { - "methods": [ - "update_certificate_map_entry" - ] - }, - "UpdateDnsAuthorization": { - "methods": [ - "update_dns_authorization" - ] - } - } - }, - "rest": { - "libraryClient": "CertificateManagerClient", - "rpcs": { - "CreateCertificate": { - "methods": [ - "create_certificate" - ] - }, - "CreateCertificateIssuanceConfig": { - "methods": [ - "create_certificate_issuance_config" - ] - }, - "CreateCertificateMap": { - "methods": [ - "create_certificate_map" - ] - }, - "CreateCertificateMapEntry": { - "methods": [ - "create_certificate_map_entry" - ] - }, - "CreateDnsAuthorization": { - "methods": [ - "create_dns_authorization" - ] - }, - "DeleteCertificate": { - "methods": [ - "delete_certificate" - ] - }, - "DeleteCertificateIssuanceConfig": { - "methods": [ - "delete_certificate_issuance_config" - ] - }, - "DeleteCertificateMap": { - "methods": [ - "delete_certificate_map" - ] - }, - "DeleteCertificateMapEntry": { - "methods": [ - "delete_certificate_map_entry" - ] - }, - "DeleteDnsAuthorization": { - "methods": [ - "delete_dns_authorization" - ] - }, - "GetCertificate": { - "methods": [ - "get_certificate" - ] - }, - "GetCertificateIssuanceConfig": { - "methods": [ - "get_certificate_issuance_config" - ] - }, - "GetCertificateMap": { - "methods": [ - "get_certificate_map" - ] - }, - "GetCertificateMapEntry": { - "methods": [ - "get_certificate_map_entry" - ] - }, - "GetDnsAuthorization": { - "methods": [ - "get_dns_authorization" - ] - }, - "ListCertificateIssuanceConfigs": { - "methods": [ - "list_certificate_issuance_configs" - ] - }, - "ListCertificateMapEntries": { - "methods": [ - "list_certificate_map_entries" - ] - }, - "ListCertificateMaps": { - "methods": [ - "list_certificate_maps" - ] - }, - "ListCertificates": { - "methods": [ - "list_certificates" - ] - }, - "ListDnsAuthorizations": { - "methods": [ - "list_dns_authorizations" - ] - }, - "UpdateCertificate": { - "methods": [ - "update_certificate" - ] - }, - "UpdateCertificateMap": { - "methods": [ - "update_certificate_map" - ] - }, - "UpdateCertificateMapEntry": { - "methods": [ - "update_certificate_map_entry" - ] - }, - "UpdateDnsAuthorization": { - "methods": [ - "update_dns_authorization" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_version.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_version.py deleted file mode 100644 index 405b1ce..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -__version__ = "0.1.0" # {x-release-please-version} diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/py.typed b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/py.typed deleted file mode 100644 index 9e0b37d..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-certificate-manager package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/__init__.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/__init__.py deleted file mode 100644 index e8e1c38..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/__init__.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/__init__.py deleted file mode 100644 index b41279d..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from .client import CertificateManagerClient -from .async_client import CertificateManagerAsyncClient - -__all__ = ( - 'CertificateManagerClient', - 'CertificateManagerAsyncClient', -) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/async_client.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/async_client.py deleted file mode 100644 index da2753e..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/async_client.py +++ /dev/null @@ -1,3616 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -import functools -import re -from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union - -from google.cloud.certificate_manager_v1 import gapic_version as package_version - -from google.api_core.client_options import ClientOptions -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.certificate_manager_v1.services.certificate_manager import pagers -from google.cloud.certificate_manager_v1.types import certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_manager -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import duration_pb2 # type: ignore -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 CertificateManagerTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import CertificateManagerGrpcAsyncIOTransport -from .client import CertificateManagerClient - - -class CertificateManagerAsyncClient: - """API Overview - - Certificates Manager API allows customers to see and manage all - their TLS certificates. - - Certificates Manager API service provides methods to manage - certificates, group them into collections, and create serving - configuration that can be easily applied to other Cloud resources - e.g. Target Proxies. - - Data Model - - The Certificates Manager service exposes the following resources: - - - ``Certificate`` that describes a single TLS certificate. - - ``CertificateMap`` that describes a collection of certificates - that can be attached to a target resource. - - ``CertificateMapEntry`` that describes a single configuration - entry that consists of a SNI and a group of certificates. It's a - subresource of CertificateMap. - - Certificate, CertificateMap and CertificateMapEntry IDs have to - fully match the regexp ``[a-z0-9-]{1,63}``. In other words, - - - only lower case letters, digits, and hyphen are allowed - - length of the resource ID has to be in [1,63] range. - - Provides methods to manage Cloud Certificate Manager entities. - """ - - _client: CertificateManagerClient - - DEFAULT_ENDPOINT = CertificateManagerClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = CertificateManagerClient.DEFAULT_MTLS_ENDPOINT - - ca_pool_path = staticmethod(CertificateManagerClient.ca_pool_path) - parse_ca_pool_path = staticmethod(CertificateManagerClient.parse_ca_pool_path) - certificate_path = staticmethod(CertificateManagerClient.certificate_path) - parse_certificate_path = staticmethod(CertificateManagerClient.parse_certificate_path) - certificate_issuance_config_path = staticmethod(CertificateManagerClient.certificate_issuance_config_path) - parse_certificate_issuance_config_path = staticmethod(CertificateManagerClient.parse_certificate_issuance_config_path) - certificate_map_path = staticmethod(CertificateManagerClient.certificate_map_path) - parse_certificate_map_path = staticmethod(CertificateManagerClient.parse_certificate_map_path) - certificate_map_entry_path = staticmethod(CertificateManagerClient.certificate_map_entry_path) - parse_certificate_map_entry_path = staticmethod(CertificateManagerClient.parse_certificate_map_entry_path) - dns_authorization_path = staticmethod(CertificateManagerClient.dns_authorization_path) - parse_dns_authorization_path = staticmethod(CertificateManagerClient.parse_dns_authorization_path) - common_billing_account_path = staticmethod(CertificateManagerClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(CertificateManagerClient.parse_common_billing_account_path) - common_folder_path = staticmethod(CertificateManagerClient.common_folder_path) - parse_common_folder_path = staticmethod(CertificateManagerClient.parse_common_folder_path) - common_organization_path = staticmethod(CertificateManagerClient.common_organization_path) - parse_common_organization_path = staticmethod(CertificateManagerClient.parse_common_organization_path) - common_project_path = staticmethod(CertificateManagerClient.common_project_path) - parse_common_project_path = staticmethod(CertificateManagerClient.parse_common_project_path) - common_location_path = staticmethod(CertificateManagerClient.common_location_path) - parse_common_location_path = staticmethod(CertificateManagerClient.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: - CertificateManagerAsyncClient: The constructed client. - """ - return CertificateManagerClient.from_service_account_info.__func__(CertificateManagerAsyncClient, 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: - CertificateManagerAsyncClient: The constructed client. - """ - return CertificateManagerClient.from_service_account_file.__func__(CertificateManagerAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @classmethod - def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[ClientOptions] = None): - """Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variable is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - return CertificateManagerClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> CertificateManagerTransport: - """Returns the transport used by the client instance. - - Returns: - CertificateManagerTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(CertificateManagerClient).get_transport_class, type(CertificateManagerClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, CertificateManagerTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the certificate manager 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, ~.CertificateManagerTransport]): 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 = CertificateManagerClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_certificates(self, - request: Optional[Union[certificate_manager.ListCertificatesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificatesAsyncPager: - r"""Lists Certificates in a given project and location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_list_certificates(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificatesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificates(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.ListCertificatesRequest, dict]]): - The request object. Request for the `ListCertificates` - method. - parent (:class:`str`): - Required. The project and location from which the - certificate should 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificatesAsyncPager: - Response for the ListCertificates method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_manager.ListCertificatesRequest(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_certificates, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("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.ListCertificatesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_certificate(self, - request: Optional[Union[certificate_manager.GetCertificateRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> certificate_manager.Certificate: - r"""Gets details of a single Certificate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_get_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateRequest( - name="name_value", - ) - - # Make the request - response = await client.get_certificate(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.GetCertificateRequest, dict]]): - The request object. Request for the `GetCertificate` - method. - name (:class:`str`): - Required. A name of the certificate to describe. Must be - in the format ``projects/*/locations/*/certificates/*``. - - 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.certificate_manager_v1.types.Certificate: - Defines TLS certificate. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_manager.GetCertificateRequest(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_certificate, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_certificate(self, - request: Optional[Union[certificate_manager.CreateCertificateRequest, dict]] = None, - *, - parent: Optional[str] = None, - certificate: Optional[certificate_manager.Certificate] = None, - certificate_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a new Certificate in a given project and - location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_create_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.CreateCertificateRequest( - parent="parent_value", - certificate_id="certificate_id_value", - ) - - # Make the request - operation = client.create_certificate(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.CreateCertificateRequest, dict]]): - The request object. Request for the `CreateCertificate` - method. - parent (:class:`str`): - Required. The parent resource of the certificate. Must - be in the format ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate (:class:`google.cloud.certificate_manager_v1.types.Certificate`): - Required. A definition of the - certificate to create. - - This corresponds to the ``certificate`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_id (:class:`str`): - Required. A user-provided name of the - certificate. - - This corresponds to the ``certificate_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.certificate_manager_v1.types.Certificate` - Defines TLS certificate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate, certificate_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 = certificate_manager.CreateCertificateRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate is not None: - request.certificate = certificate - if certificate_id is not None: - request.certificate_id = certificate_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_certificate, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("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, - certificate_manager.Certificate, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_certificate(self, - request: Optional[Union[certificate_manager.UpdateCertificateRequest, dict]] = None, - *, - certificate: Optional[certificate_manager.Certificate] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates a Certificate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_update_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.UpdateCertificateRequest( - ) - - # Make the request - operation = client.update_certificate(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.UpdateCertificateRequest, dict]]): - The request object. Request for the `UpdateCertificate` - method. - certificate (:class:`google.cloud.certificate_manager_v1.types.Certificate`): - Required. A definition of the - certificate to update. - - This corresponds to the ``certificate`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.certificate_manager_v1.types.Certificate` - Defines TLS certificate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate, 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 = certificate_manager.UpdateCertificateRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate is not None: - request.certificate = certificate - 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_certificate, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("certificate.name", request.certificate.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, - certificate_manager.Certificate, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_certificate(self, - request: Optional[Union[certificate_manager.DeleteCertificateRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a single Certificate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_delete_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.DeleteCertificateRequest, dict]]): - The request object. Request for the `DeleteCertificate` - method. - name (:class:`str`): - Required. A name of the certificate to delete. Must be - in the format ``projects/*/locations/*/certificates/*``. - - 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); - - } - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_manager.DeleteCertificateRequest(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_certificate, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_certificate_maps(self, - request: Optional[Union[certificate_manager.ListCertificateMapsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateMapsAsyncPager: - r"""Lists CertificateMaps in a given project and - location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_list_certificate_maps(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificateMapsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificate_maps(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.ListCertificateMapsRequest, dict]]): - The request object. Request for the - `ListCertificateMaps` method. - parent (:class:`str`): - Required. The project and location from which the - certificate maps should 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapsAsyncPager: - Response for the ListCertificateMaps method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_manager.ListCertificateMapsRequest(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_certificate_maps, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("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.ListCertificateMapsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_certificate_map(self, - request: Optional[Union[certificate_manager.GetCertificateMapRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> certificate_manager.CertificateMap: - r"""Gets details of a single CertificateMap. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_get_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateMapRequest( - name="name_value", - ) - - # Make the request - response = await client.get_certificate_map(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.GetCertificateMapRequest, dict]]): - The request object. Request for the `GetCertificateMap` - method. - name (:class:`str`): - Required. A name of the certificate map to describe. - Must be in the format - ``projects/*/locations/*/certificateMaps/*``. - - 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.certificate_manager_v1.types.CertificateMap: - Defines a collection of certificate - configurations. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_manager.GetCertificateMapRequest(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_certificate_map, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_certificate_map(self, - request: Optional[Union[certificate_manager.CreateCertificateMapRequest, dict]] = None, - *, - parent: Optional[str] = None, - certificate_map: Optional[certificate_manager.CertificateMap] = None, - certificate_map_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a new CertificateMap in a given project and - location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_create_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.CreateCertificateMapRequest( - parent="parent_value", - certificate_map_id="certificate_map_id_value", - ) - - # Make the request - operation = client.create_certificate_map(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.CreateCertificateMapRequest, dict]]): - The request object. Request for the - `CreateCertificateMap` method. - parent (:class:`str`): - Required. The parent resource of the certificate map. - Must be in the format ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_map (:class:`google.cloud.certificate_manager_v1.types.CertificateMap`): - Required. A definition of the - certificate map to create. - - This corresponds to the ``certificate_map`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_map_id (:class:`str`): - Required. A user-provided name of the - certificate map. - - This corresponds to the ``certificate_map_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.certificate_manager_v1.types.CertificateMap` - Defines a collection of certificate configurations. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate_map, certificate_map_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 = certificate_manager.CreateCertificateMapRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate_map is not None: - request.certificate_map = certificate_map - if certificate_map_id is not None: - request.certificate_map_id = certificate_map_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_certificate_map, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("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, - certificate_manager.CertificateMap, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_certificate_map(self, - request: Optional[Union[certificate_manager.UpdateCertificateMapRequest, dict]] = None, - *, - certificate_map: Optional[certificate_manager.CertificateMap] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates a CertificateMap. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_update_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.UpdateCertificateMapRequest( - ) - - # Make the request - operation = client.update_certificate_map(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.UpdateCertificateMapRequest, dict]]): - The request object. Request for the - `UpdateCertificateMap` method. - certificate_map (:class:`google.cloud.certificate_manager_v1.types.CertificateMap`): - Required. A definition of the - certificate map to update. - - This corresponds to the ``certificate_map`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.certificate_manager_v1.types.CertificateMap` - Defines a collection of certificate configurations. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_map, 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 = certificate_manager.UpdateCertificateMapRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_map is not None: - request.certificate_map = certificate_map - 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_certificate_map, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("certificate_map.name", request.certificate_map.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, - certificate_manager.CertificateMap, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_certificate_map(self, - request: Optional[Union[certificate_manager.DeleteCertificateMapRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a single CertificateMap. A Certificate Map - can't be deleted if it contains Certificate Map Entries. - Remove all the entries from the map before calling this - method. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_delete_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateMapRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate_map(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.DeleteCertificateMapRequest, dict]]): - The request object. Request for the - `DeleteCertificateMap` method. - name (:class:`str`): - Required. A name of the certificate map to delete. Must - be in the format - ``projects/*/locations/*/certificateMaps/*``. - - 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); - - } - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_manager.DeleteCertificateMapRequest(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_certificate_map, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_certificate_map_entries(self, - request: Optional[Union[certificate_manager.ListCertificateMapEntriesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateMapEntriesAsyncPager: - r"""Lists CertificateMapEntries in a given project and - location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_list_certificate_map_entries(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificateMapEntriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificate_map_entries(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesRequest, dict]]): - The request object. Request for the - `ListCertificateMapEntries` method. - parent (:class:`str`): - Required. The project, location and certificate map from - which the certificate map entries should be listed, - specified in the format - ``projects/*/locations/*/certificateMaps/*``. - - 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapEntriesAsyncPager: - Response for the ListCertificateMapEntries method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_manager.ListCertificateMapEntriesRequest(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_certificate_map_entries, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("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.ListCertificateMapEntriesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_certificate_map_entry(self, - request: Optional[Union[certificate_manager.GetCertificateMapEntryRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> certificate_manager.CertificateMapEntry: - r"""Gets details of a single CertificateMapEntry. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_get_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateMapEntryRequest( - name="name_value", - ) - - # Make the request - response = await client.get_certificate_map_entry(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.GetCertificateMapEntryRequest, dict]]): - The request object. Request for the - `GetCertificateMapEntry` method. - name (:class:`str`): - Required. A name of the certificate map entry to - describe. Must be in the format - ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. - - 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.certificate_manager_v1.types.CertificateMapEntry: - Defines a certificate map entry. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_manager.GetCertificateMapEntryRequest(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_certificate_map_entry, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_certificate_map_entry(self, - request: Optional[Union[certificate_manager.CreateCertificateMapEntryRequest, dict]] = None, - *, - parent: Optional[str] = None, - certificate_map_entry: Optional[certificate_manager.CertificateMapEntry] = None, - certificate_map_entry_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a new CertificateMapEntry in a given project - and location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_create_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - certificate_map_entry = certificate_manager_v1.CertificateMapEntry() - certificate_map_entry.hostname = "hostname_value" - - request = certificate_manager_v1.CreateCertificateMapEntryRequest( - parent="parent_value", - certificate_map_entry_id="certificate_map_entry_id_value", - certificate_map_entry=certificate_map_entry, - ) - - # Make the request - operation = client.create_certificate_map_entry(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.CreateCertificateMapEntryRequest, dict]]): - The request object. Request for the - `CreateCertificateMapEntry` method. - parent (:class:`str`): - Required. The parent resource of the certificate map - entry. Must be in the format - ``projects/*/locations/*/certificateMaps/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_map_entry (:class:`google.cloud.certificate_manager_v1.types.CertificateMapEntry`): - Required. A definition of the - certificate map entry to create. - - This corresponds to the ``certificate_map_entry`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_map_entry_id (:class:`str`): - Required. A user-provided name of the - certificate map entry. - - This corresponds to the ``certificate_map_entry_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.certificate_manager_v1.types.CertificateMapEntry` - Defines a certificate map entry. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate_map_entry, certificate_map_entry_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 = certificate_manager.CreateCertificateMapEntryRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate_map_entry is not None: - request.certificate_map_entry = certificate_map_entry - if certificate_map_entry_id is not None: - request.certificate_map_entry_id = certificate_map_entry_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_certificate_map_entry, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("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, - certificate_manager.CertificateMapEntry, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_certificate_map_entry(self, - request: Optional[Union[certificate_manager.UpdateCertificateMapEntryRequest, dict]] = None, - *, - certificate_map_entry: Optional[certificate_manager.CertificateMapEntry] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates a CertificateMapEntry. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_update_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - certificate_map_entry = certificate_manager_v1.CertificateMapEntry() - certificate_map_entry.hostname = "hostname_value" - - request = certificate_manager_v1.UpdateCertificateMapEntryRequest( - certificate_map_entry=certificate_map_entry, - ) - - # Make the request - operation = client.update_certificate_map_entry(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.UpdateCertificateMapEntryRequest, dict]]): - The request object. Request for the - `UpdateCertificateMapEntry` method. - certificate_map_entry (:class:`google.cloud.certificate_manager_v1.types.CertificateMapEntry`): - Required. A definition of the - certificate map entry to create map - entry. - - This corresponds to the ``certificate_map_entry`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.certificate_manager_v1.types.CertificateMapEntry` - Defines a certificate map entry. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_map_entry, 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 = certificate_manager.UpdateCertificateMapEntryRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_map_entry is not None: - request.certificate_map_entry = certificate_map_entry - 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_certificate_map_entry, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("certificate_map_entry.name", request.certificate_map_entry.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, - certificate_manager.CertificateMapEntry, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_certificate_map_entry(self, - request: Optional[Union[certificate_manager.DeleteCertificateMapEntryRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a single CertificateMapEntry. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_delete_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateMapEntryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate_map_entry(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.DeleteCertificateMapEntryRequest, dict]]): - The request object. Request for the - `DeleteCertificateMapEntry` method. - name (:class:`str`): - Required. A name of the certificate map entry to delete. - Must be in the format - ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. - - 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); - - } - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_manager.DeleteCertificateMapEntryRequest(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_certificate_map_entry, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_dns_authorizations(self, - request: Optional[Union[certificate_manager.ListDnsAuthorizationsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListDnsAuthorizationsAsyncPager: - r"""Lists DnsAuthorizations in a given project and - location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_list_dns_authorizations(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListDnsAuthorizationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_dns_authorizations(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsRequest, dict]]): - The request object. Request for the - `ListDnsAuthorizations` method. - parent (:class:`str`): - Required. The project and location from which the dns - authorizations should 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.certificate_manager_v1.services.certificate_manager.pagers.ListDnsAuthorizationsAsyncPager: - Response for the ListDnsAuthorizations method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_manager.ListDnsAuthorizationsRequest(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_dns_authorizations, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("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.ListDnsAuthorizationsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_dns_authorization(self, - request: Optional[Union[certificate_manager.GetDnsAuthorizationRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> certificate_manager.DnsAuthorization: - r"""Gets details of a single DnsAuthorization. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_get_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetDnsAuthorizationRequest( - name="name_value", - ) - - # Make the request - response = await client.get_dns_authorization(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.GetDnsAuthorizationRequest, dict]]): - The request object. Request for the - `GetDnsAuthorization` method. - name (:class:`str`): - Required. A name of the dns authorization to describe. - Must be in the format - ``projects/*/locations/*/dnsAuthorizations/*``. - - 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.certificate_manager_v1.types.DnsAuthorization: - A DnsAuthorization resource describes - a way to perform domain authorization - for certificate issuance. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_manager.GetDnsAuthorizationRequest(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_dns_authorization, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_dns_authorization(self, - request: Optional[Union[certificate_manager.CreateDnsAuthorizationRequest, dict]] = None, - *, - parent: Optional[str] = None, - dns_authorization: Optional[certificate_manager.DnsAuthorization] = None, - dns_authorization_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a new DnsAuthorization in a given project and - location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_create_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - dns_authorization = certificate_manager_v1.DnsAuthorization() - dns_authorization.domain = "domain_value" - - request = certificate_manager_v1.CreateDnsAuthorizationRequest( - parent="parent_value", - dns_authorization_id="dns_authorization_id_value", - dns_authorization=dns_authorization, - ) - - # Make the request - operation = client.create_dns_authorization(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.CreateDnsAuthorizationRequest, dict]]): - The request object. Request for the - `CreateDnsAuthorization` method. - parent (:class:`str`): - Required. The parent resource of the dns authorization. - Must be in the format ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - dns_authorization (:class:`google.cloud.certificate_manager_v1.types.DnsAuthorization`): - Required. A definition of the dns - authorization to create. - - This corresponds to the ``dns_authorization`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - dns_authorization_id (:class:`str`): - Required. A user-provided name of the - dns authorization. - - This corresponds to the ``dns_authorization_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.certificate_manager_v1.types.DnsAuthorization` A DnsAuthorization resource describes a way to perform domain authorization - for certificate issuance. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, dns_authorization, dns_authorization_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 = certificate_manager.CreateDnsAuthorizationRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if dns_authorization is not None: - request.dns_authorization = dns_authorization - if dns_authorization_id is not None: - request.dns_authorization_id = dns_authorization_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_dns_authorization, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("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, - certificate_manager.DnsAuthorization, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_dns_authorization(self, - request: Optional[Union[certificate_manager.UpdateDnsAuthorizationRequest, dict]] = None, - *, - dns_authorization: Optional[certificate_manager.DnsAuthorization] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates a DnsAuthorization. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_update_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - dns_authorization = certificate_manager_v1.DnsAuthorization() - dns_authorization.domain = "domain_value" - - request = certificate_manager_v1.UpdateDnsAuthorizationRequest( - dns_authorization=dns_authorization, - ) - - # Make the request - operation = client.update_dns_authorization(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.UpdateDnsAuthorizationRequest, dict]]): - The request object. Request for the - `UpdateDnsAuthorization` method. - dns_authorization (:class:`google.cloud.certificate_manager_v1.types.DnsAuthorization`): - Required. A definition of the dns - authorization to update. - - This corresponds to the ``dns_authorization`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.certificate_manager_v1.types.DnsAuthorization` A DnsAuthorization resource describes a way to perform domain authorization - for certificate issuance. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([dns_authorization, 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 = certificate_manager.UpdateDnsAuthorizationRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if dns_authorization is not None: - request.dns_authorization = dns_authorization - 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_dns_authorization, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("dns_authorization.name", request.dns_authorization.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, - certificate_manager.DnsAuthorization, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_dns_authorization(self, - request: Optional[Union[certificate_manager.DeleteDnsAuthorizationRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a single DnsAuthorization. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_delete_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteDnsAuthorizationRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_dns_authorization(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.DeleteDnsAuthorizationRequest, dict]]): - The request object. Request for the - `DeleteDnsAuthorization` method. - name (:class:`str`): - Required. A name of the dns authorization to delete. - Must be in the format - ``projects/*/locations/*/dnsAuthorizations/*``. - - 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); - - } - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_manager.DeleteDnsAuthorizationRequest(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_dns_authorization, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_certificate_issuance_configs(self, - request: Optional[Union[certificate_issuance_config.ListCertificateIssuanceConfigsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateIssuanceConfigsAsyncPager: - r"""Lists CertificateIssuanceConfigs in a given project - and location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_list_certificate_issuance_configs(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificateIssuanceConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificate_issuance_configs(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsRequest, dict]]): - The request object. Request for the - `ListCertificateIssuanceConfigs` method. - parent (:class:`str`): - Required. The project and location from which the - certificate should 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateIssuanceConfigsAsyncPager: - Response for the ListCertificateIssuanceConfigs method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_issuance_config.ListCertificateIssuanceConfigsRequest(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_certificate_issuance_configs, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("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.ListCertificateIssuanceConfigsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_certificate_issuance_config(self, - request: Optional[Union[certificate_issuance_config.GetCertificateIssuanceConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> certificate_issuance_config.CertificateIssuanceConfig: - r"""Gets details of a single CertificateIssuanceConfig. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_get_certificate_issuance_config(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateIssuanceConfigRequest( - name="name_value", - ) - - # Make the request - response = await client.get_certificate_issuance_config(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.GetCertificateIssuanceConfigRequest, dict]]): - The request object. Request for the - `GetCertificateIssuanceConfig` method. - name (:class:`str`): - Required. A name of the certificate issuance config to - describe. Must be in the format - ``projects/*/locations/*/certificateIssuanceConfigs/*``. - - 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.certificate_manager_v1.types.CertificateIssuanceConfig: - CertificateIssuanceConfig specifies - how to issue and manage a certificate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_issuance_config.GetCertificateIssuanceConfigRequest(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_certificate_issuance_config, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_certificate_issuance_config(self, - request: Optional[Union[gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, dict]] = None, - *, - parent: Optional[str] = None, - certificate_issuance_config: Optional[gcc_certificate_issuance_config.CertificateIssuanceConfig] = None, - certificate_issuance_config_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a new CertificateIssuanceConfig in a given - project and location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_create_certificate_issuance_config(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - certificate_issuance_config = certificate_manager_v1.CertificateIssuanceConfig() - certificate_issuance_config.certificate_authority_config.certificate_authority_service_config.ca_pool = "ca_pool_value" - certificate_issuance_config.rotation_window_percentage = 2788 - certificate_issuance_config.key_algorithm = "ECDSA_P256" - - request = certificate_manager_v1.CreateCertificateIssuanceConfigRequest( - parent="parent_value", - certificate_issuance_config_id="certificate_issuance_config_id_value", - certificate_issuance_config=certificate_issuance_config, - ) - - # Make the request - operation = client.create_certificate_issuance_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.CreateCertificateIssuanceConfigRequest, dict]]): - The request object. Request for the - `CreateCertificateIssuanceConfig` method. - parent (:class:`str`): - Required. The parent resource of the certificate - issuance config. Must be in the format - ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_issuance_config (:class:`google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig`): - Required. A definition of the - certificate issuance config to create. - - This corresponds to the ``certificate_issuance_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_issuance_config_id (:class:`str`): - Required. A user-provided name of the - certificate config. - - This corresponds to the ``certificate_issuance_config_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.certificate_manager_v1.types.CertificateIssuanceConfig` - CertificateIssuanceConfig specifies how to issue and - manage a certificate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate_issuance_config, certificate_issuance_config_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 = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate_issuance_config is not None: - request.certificate_issuance_config = certificate_issuance_config - if certificate_issuance_config_id is not None: - request.certificate_issuance_config_id = certificate_issuance_config_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_certificate_issuance_config, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("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, - gcc_certificate_issuance_config.CertificateIssuanceConfig, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_certificate_issuance_config(self, - request: Optional[Union[certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a single CertificateIssuanceConfig. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - async def sample_delete_certificate_issuance_config(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateIssuanceConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate_issuance_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.certificate_manager_v1.types.DeleteCertificateIssuanceConfigRequest, dict]]): - The request object. Request for the - `DeleteCertificateIssuanceConfig` method. - name (:class:`str`): - Required. A name of the certificate issuance config to - delete. Must be in the format - ``projects/*/locations/*/certificateIssuanceConfigs/*``. - - 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); - - } - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest(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_certificate_issuance_config, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_operations( - self, - request: Optional[operations_pb2.ListOperationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.ListOperationsResponse: - r"""Lists operations that match the specified filter in the request. - - Args: - request (:class:`~.operations_pb2.ListOperationsRequest`): - The request object. Request message for - `ListOperations` 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: - ~.operations_pb2.ListOperationsResponse: - Response message for ``ListOperations`` method. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.ListOperationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._client._transport.list_operations, - 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_operation( - self, - request: Optional[operations_pb2.GetOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Gets the latest state of a long-running operation. - - Args: - request (:class:`~.operations_pb2.GetOperationRequest`): - The request object. Request message for - `GetOperation` 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: - ~.operations_pb2.Operation: - An ``Operation`` object. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.GetOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._client._transport.get_operation, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Send the request. - response = await rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - async def delete_operation( - self, - request: Optional[operations_pb2.DeleteOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a long-running operation. - - This method indicates that the client is no longer interested - in the operation result. It does not cancel the operation. - If the server doesn't support this method, it returns - `google.rpc.Code.UNIMPLEMENTED`. - - Args: - request (:class:`~.operations_pb2.DeleteOperationRequest`): - The request object. Request message for - `DeleteOperation` 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: - None - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.DeleteOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._client._transport.delete_operation, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Send the request. - await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - async def cancel_operation( - self, - request: Optional[operations_pb2.CancelOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Starts asynchronous cancellation on a long-running operation. - - The server makes a best effort to cancel the operation, but success - is not guaranteed. If the server doesn't support this method, it returns - `google.rpc.Code.UNIMPLEMENTED`. - - Args: - request (:class:`~.operations_pb2.CancelOperationRequest`): - The request object. Request message for - `CancelOperation` 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: - None - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.CancelOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._client._transport.cancel_operation, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Send the request. - await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - async def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location object. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._client._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` method. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._client._transport.list_locations, - 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 __aenter__(self): - return self - - async def __aexit__(self, exc_type, exc, tb): - await self.transport.close() - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "CertificateManagerAsyncClient", -) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/client.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/client.py deleted file mode 100644 index 5396a2e..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/client.py +++ /dev/null @@ -1,3716 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -import os -import re -from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast - -from google.cloud.certificate_manager_v1 import gapic_version as package_version - -from google.api_core import client_options as client_options_lib -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.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 - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.certificate_manager_v1.services.certificate_manager import pagers -from google.cloud.certificate_manager_v1.types import certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_manager -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import duration_pb2 # type: ignore -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 CertificateManagerTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import CertificateManagerGrpcTransport -from .transports.grpc_asyncio import CertificateManagerGrpcAsyncIOTransport -from .transports.rest import CertificateManagerRestTransport - - -class CertificateManagerClientMeta(type): - """Metaclass for the CertificateManager 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[CertificateManagerTransport]] - _transport_registry["grpc"] = CertificateManagerGrpcTransport - _transport_registry["grpc_asyncio"] = CertificateManagerGrpcAsyncIOTransport - _transport_registry["rest"] = CertificateManagerRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[CertificateManagerTransport]: - """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 CertificateManagerClient(metaclass=CertificateManagerClientMeta): - """API Overview - - Certificates Manager API allows customers to see and manage all - their TLS certificates. - - Certificates Manager API service provides methods to manage - certificates, group them into collections, and create serving - configuration that can be easily applied to other Cloud resources - e.g. Target Proxies. - - Data Model - - The Certificates Manager service exposes the following resources: - - - ``Certificate`` that describes a single TLS certificate. - - ``CertificateMap`` that describes a collection of certificates - that can be attached to a target resource. - - ``CertificateMapEntry`` that describes a single configuration - entry that consists of a SNI and a group of certificates. It's a - subresource of CertificateMap. - - Certificate, CertificateMap and CertificateMapEntry IDs have to - fully match the regexp ``[a-z0-9-]{1,63}``. In other words, - - - only lower case letters, digits, and hyphen are allowed - - length of the resource ID has to be in [1,63] range. - - Provides methods to manage Cloud Certificate Manager entities. - """ - - @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 = "certificatemanager.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: - CertificateManagerClient: 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: - CertificateManagerClient: 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) -> CertificateManagerTransport: - """Returns the transport used by the client instance. - - Returns: - CertificateManagerTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def ca_pool_path(project: str,location: str,ca_pool: str,) -> str: - """Returns a fully-qualified ca_pool string.""" - return "projects/{project}/locations/{location}/caPools/{ca_pool}".format(project=project, location=location, ca_pool=ca_pool, ) - - @staticmethod - def parse_ca_pool_path(path: str) -> Dict[str,str]: - """Parses a ca_pool path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/caPools/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def certificate_path(project: str,location: str,certificate: str,) -> str: - """Returns a fully-qualified certificate string.""" - return "projects/{project}/locations/{location}/certificates/{certificate}".format(project=project, location=location, certificate=certificate, ) - - @staticmethod - def parse_certificate_path(path: str) -> Dict[str,str]: - """Parses a certificate path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificates/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def certificate_issuance_config_path(project: str,location: str,certificate_issuance_config: str,) -> str: - """Returns a fully-qualified certificate_issuance_config string.""" - return "projects/{project}/locations/{location}/certificateIssuanceConfigs/{certificate_issuance_config}".format(project=project, location=location, certificate_issuance_config=certificate_issuance_config, ) - - @staticmethod - def parse_certificate_issuance_config_path(path: str) -> Dict[str,str]: - """Parses a certificate_issuance_config path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificateIssuanceConfigs/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def certificate_map_path(project: str,location: str,certificate_map: str,) -> str: - """Returns a fully-qualified certificate_map string.""" - return "projects/{project}/locations/{location}/certificateMaps/{certificate_map}".format(project=project, location=location, certificate_map=certificate_map, ) - - @staticmethod - def parse_certificate_map_path(path: str) -> Dict[str,str]: - """Parses a certificate_map path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificateMaps/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def certificate_map_entry_path(project: str,location: str,certificate_map: str,certificate_map_entry: str,) -> str: - """Returns a fully-qualified certificate_map_entry string.""" - return "projects/{project}/locations/{location}/certificateMaps/{certificate_map}/certificateMapEntries/{certificate_map_entry}".format(project=project, location=location, certificate_map=certificate_map, certificate_map_entry=certificate_map_entry, ) - - @staticmethod - def parse_certificate_map_entry_path(path: str) -> Dict[str,str]: - """Parses a certificate_map_entry path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificateMaps/(?P.+?)/certificateMapEntries/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def dns_authorization_path(project: str,location: str,dns_authorization: str,) -> str: - """Returns a fully-qualified dns_authorization string.""" - return "projects/{project}/locations/{location}/dnsAuthorizations/{dns_authorization}".format(project=project, location=location, dns_authorization=dns_authorization, ) - - @staticmethod - def parse_dns_authorization_path(path: str) -> Dict[str,str]: - """Parses a dns_authorization path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/dnsAuthorizations/(?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 {} - - @classmethod - def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_options_lib.ClientOptions] = None): - """Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variable is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - if client_options is None: - client_options = client_options_lib.ClientOptions() - use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") - use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_client_cert not in ("true", "false"): - raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`") - if use_mtls_endpoint not in ("auto", "never", "always"): - raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`") - - # Figure out the client cert source to use. - client_cert_source = None - if use_client_cert == "true": - if client_options.client_cert_source: - client_cert_source = client_options.client_cert_source - elif mtls.has_default_client_cert_source(): - client_cert_source = mtls.default_client_cert_source() - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source): - api_endpoint = cls.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = cls.DEFAULT_ENDPOINT - - return api_endpoint, client_cert_source - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Optional[Union[str, CertificateManagerTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the certificate manager 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, CertificateManagerTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): 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() - client_options = cast(client_options_lib.ClientOptions, client_options) - - api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(client_options) - - api_key_value = getattr(client_options, "api_key", None) - if api_key_value and credentials: - raise ValueError("client_options.api_key and credentials are mutually exclusive") - - # 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, CertificateManagerTransport): - # transport is a CertificateManagerTransport instance. - if credentials or client_options.credentials_file or api_key_value: - 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: - import google.auth._default # type: ignore - - if api_key_value and hasattr(google.auth._default, "get_api_key_credentials"): - credentials = google.auth._default.get_api_key_credentials(api_key_value) - - 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, - always_use_jwt_access=True, - api_audience=client_options.api_audience, - ) - - def list_certificates(self, - request: Optional[Union[certificate_manager.ListCertificatesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificatesPager: - r"""Lists Certificates in a given project and location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_list_certificates(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificatesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificates(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.ListCertificatesRequest, dict]): - The request object. Request for the `ListCertificates` - method. - parent (str): - Required. The project and location from which the - certificate should 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificatesPager: - Response for the ListCertificates method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_manager.ListCertificatesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.ListCertificatesRequest): - request = certificate_manager.ListCertificatesRequest(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_certificates] - - # 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.ListCertificatesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_certificate(self, - request: Optional[Union[certificate_manager.GetCertificateRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> certificate_manager.Certificate: - r"""Gets details of a single Certificate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_get_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateRequest( - name="name_value", - ) - - # Make the request - response = client.get_certificate(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.GetCertificateRequest, dict]): - The request object. Request for the `GetCertificate` - method. - name (str): - Required. A name of the certificate to describe. Must be - in the format ``projects/*/locations/*/certificates/*``. - - 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.certificate_manager_v1.types.Certificate: - Defines TLS certificate. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_manager.GetCertificateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.GetCertificateRequest): - request = certificate_manager.GetCertificateRequest(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_certificate] - - # 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_certificate(self, - request: Optional[Union[certificate_manager.CreateCertificateRequest, dict]] = None, - *, - parent: Optional[str] = None, - certificate: Optional[certificate_manager.Certificate] = None, - certificate_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates a new Certificate in a given project and - location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_create_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.CreateCertificateRequest( - parent="parent_value", - certificate_id="certificate_id_value", - ) - - # Make the request - operation = client.create_certificate(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.CreateCertificateRequest, dict]): - The request object. Request for the `CreateCertificate` - method. - parent (str): - Required. The parent resource of the certificate. Must - be in the format ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate (google.cloud.certificate_manager_v1.types.Certificate): - Required. A definition of the - certificate to create. - - This corresponds to the ``certificate`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_id (str): - Required. A user-provided name of the - certificate. - - This corresponds to the ``certificate_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.certificate_manager_v1.types.Certificate` - Defines TLS certificate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate, certificate_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 certificate_manager.CreateCertificateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.CreateCertificateRequest): - request = certificate_manager.CreateCertificateRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate is not None: - request.certificate = certificate - if certificate_id is not None: - request.certificate_id = certificate_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_certificate] - - # 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, - certificate_manager.Certificate, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_certificate(self, - request: Optional[Union[certificate_manager.UpdateCertificateRequest, dict]] = None, - *, - certificate: Optional[certificate_manager.Certificate] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Updates a Certificate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_update_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.UpdateCertificateRequest( - ) - - # Make the request - operation = client.update_certificate(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.UpdateCertificateRequest, dict]): - The request object. Request for the `UpdateCertificate` - method. - certificate (google.cloud.certificate_manager_v1.types.Certificate): - Required. A definition of the - certificate to update. - - This corresponds to the ``certificate`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.certificate_manager_v1.types.Certificate` - Defines TLS certificate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate, 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 certificate_manager.UpdateCertificateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.UpdateCertificateRequest): - request = certificate_manager.UpdateCertificateRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate is not None: - request.certificate = certificate - 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_certificate] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("certificate.name", request.certificate.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, - certificate_manager.Certificate, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_certificate(self, - request: Optional[Union[certificate_manager.DeleteCertificateRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Deletes a single Certificate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_delete_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.DeleteCertificateRequest, dict]): - The request object. Request for the `DeleteCertificate` - method. - name (str): - Required. A name of the certificate to delete. Must be - in the format ``projects/*/locations/*/certificates/*``. - - 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); - - } - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_manager.DeleteCertificateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.DeleteCertificateRequest): - request = certificate_manager.DeleteCertificateRequest(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_certificate] - - # 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=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_certificate_maps(self, - request: Optional[Union[certificate_manager.ListCertificateMapsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateMapsPager: - r"""Lists CertificateMaps in a given project and - location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_list_certificate_maps(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificateMapsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificate_maps(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.ListCertificateMapsRequest, dict]): - The request object. Request for the - `ListCertificateMaps` method. - parent (str): - Required. The project and location from which the - certificate maps should 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapsPager: - Response for the ListCertificateMaps method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_manager.ListCertificateMapsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.ListCertificateMapsRequest): - request = certificate_manager.ListCertificateMapsRequest(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_certificate_maps] - - # 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.ListCertificateMapsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_certificate_map(self, - request: Optional[Union[certificate_manager.GetCertificateMapRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> certificate_manager.CertificateMap: - r"""Gets details of a single CertificateMap. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_get_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateMapRequest( - name="name_value", - ) - - # Make the request - response = client.get_certificate_map(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.GetCertificateMapRequest, dict]): - The request object. Request for the `GetCertificateMap` - method. - name (str): - Required. A name of the certificate map to describe. - Must be in the format - ``projects/*/locations/*/certificateMaps/*``. - - 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.certificate_manager_v1.types.CertificateMap: - Defines a collection of certificate - configurations. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_manager.GetCertificateMapRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.GetCertificateMapRequest): - request = certificate_manager.GetCertificateMapRequest(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_certificate_map] - - # 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_certificate_map(self, - request: Optional[Union[certificate_manager.CreateCertificateMapRequest, dict]] = None, - *, - parent: Optional[str] = None, - certificate_map: Optional[certificate_manager.CertificateMap] = None, - certificate_map_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates a new CertificateMap in a given project and - location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_create_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.CreateCertificateMapRequest( - parent="parent_value", - certificate_map_id="certificate_map_id_value", - ) - - # Make the request - operation = client.create_certificate_map(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.CreateCertificateMapRequest, dict]): - The request object. Request for the - `CreateCertificateMap` method. - parent (str): - Required. The parent resource of the certificate map. - Must be in the format ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_map (google.cloud.certificate_manager_v1.types.CertificateMap): - Required. A definition of the - certificate map to create. - - This corresponds to the ``certificate_map`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_map_id (str): - Required. A user-provided name of the - certificate map. - - This corresponds to the ``certificate_map_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.certificate_manager_v1.types.CertificateMap` - Defines a collection of certificate configurations. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate_map, certificate_map_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 certificate_manager.CreateCertificateMapRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.CreateCertificateMapRequest): - request = certificate_manager.CreateCertificateMapRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate_map is not None: - request.certificate_map = certificate_map - if certificate_map_id is not None: - request.certificate_map_id = certificate_map_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_certificate_map] - - # 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, - certificate_manager.CertificateMap, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_certificate_map(self, - request: Optional[Union[certificate_manager.UpdateCertificateMapRequest, dict]] = None, - *, - certificate_map: Optional[certificate_manager.CertificateMap] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Updates a CertificateMap. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_update_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.UpdateCertificateMapRequest( - ) - - # Make the request - operation = client.update_certificate_map(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.UpdateCertificateMapRequest, dict]): - The request object. Request for the - `UpdateCertificateMap` method. - certificate_map (google.cloud.certificate_manager_v1.types.CertificateMap): - Required. A definition of the - certificate map to update. - - This corresponds to the ``certificate_map`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.certificate_manager_v1.types.CertificateMap` - Defines a collection of certificate configurations. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_map, 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 certificate_manager.UpdateCertificateMapRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.UpdateCertificateMapRequest): - request = certificate_manager.UpdateCertificateMapRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_map is not None: - request.certificate_map = certificate_map - 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_certificate_map] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("certificate_map.name", request.certificate_map.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, - certificate_manager.CertificateMap, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_certificate_map(self, - request: Optional[Union[certificate_manager.DeleteCertificateMapRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Deletes a single CertificateMap. A Certificate Map - can't be deleted if it contains Certificate Map Entries. - Remove all the entries from the map before calling this - method. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_delete_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateMapRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate_map(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.DeleteCertificateMapRequest, dict]): - The request object. Request for the - `DeleteCertificateMap` method. - name (str): - Required. A name of the certificate map to delete. Must - be in the format - ``projects/*/locations/*/certificateMaps/*``. - - 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); - - } - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_manager.DeleteCertificateMapRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.DeleteCertificateMapRequest): - request = certificate_manager.DeleteCertificateMapRequest(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_certificate_map] - - # 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=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_certificate_map_entries(self, - request: Optional[Union[certificate_manager.ListCertificateMapEntriesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateMapEntriesPager: - r"""Lists CertificateMapEntries in a given project and - location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_list_certificate_map_entries(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificateMapEntriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificate_map_entries(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesRequest, dict]): - The request object. Request for the - `ListCertificateMapEntries` method. - parent (str): - Required. The project, location and certificate map from - which the certificate map entries should be listed, - specified in the format - ``projects/*/locations/*/certificateMaps/*``. - - 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapEntriesPager: - Response for the ListCertificateMapEntries method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_manager.ListCertificateMapEntriesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.ListCertificateMapEntriesRequest): - request = certificate_manager.ListCertificateMapEntriesRequest(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_certificate_map_entries] - - # 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.ListCertificateMapEntriesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_certificate_map_entry(self, - request: Optional[Union[certificate_manager.GetCertificateMapEntryRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> certificate_manager.CertificateMapEntry: - r"""Gets details of a single CertificateMapEntry. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_get_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateMapEntryRequest( - name="name_value", - ) - - # Make the request - response = client.get_certificate_map_entry(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.GetCertificateMapEntryRequest, dict]): - The request object. Request for the - `GetCertificateMapEntry` method. - name (str): - Required. A name of the certificate map entry to - describe. Must be in the format - ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. - - 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.certificate_manager_v1.types.CertificateMapEntry: - Defines a certificate map entry. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_manager.GetCertificateMapEntryRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.GetCertificateMapEntryRequest): - request = certificate_manager.GetCertificateMapEntryRequest(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_certificate_map_entry] - - # 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_certificate_map_entry(self, - request: Optional[Union[certificate_manager.CreateCertificateMapEntryRequest, dict]] = None, - *, - parent: Optional[str] = None, - certificate_map_entry: Optional[certificate_manager.CertificateMapEntry] = None, - certificate_map_entry_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates a new CertificateMapEntry in a given project - and location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_create_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - certificate_map_entry = certificate_manager_v1.CertificateMapEntry() - certificate_map_entry.hostname = "hostname_value" - - request = certificate_manager_v1.CreateCertificateMapEntryRequest( - parent="parent_value", - certificate_map_entry_id="certificate_map_entry_id_value", - certificate_map_entry=certificate_map_entry, - ) - - # Make the request - operation = client.create_certificate_map_entry(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.CreateCertificateMapEntryRequest, dict]): - The request object. Request for the - `CreateCertificateMapEntry` method. - parent (str): - Required. The parent resource of the certificate map - entry. Must be in the format - ``projects/*/locations/*/certificateMaps/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_map_entry (google.cloud.certificate_manager_v1.types.CertificateMapEntry): - Required. A definition of the - certificate map entry to create. - - This corresponds to the ``certificate_map_entry`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_map_entry_id (str): - Required. A user-provided name of the - certificate map entry. - - This corresponds to the ``certificate_map_entry_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.certificate_manager_v1.types.CertificateMapEntry` - Defines a certificate map entry. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate_map_entry, certificate_map_entry_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 certificate_manager.CreateCertificateMapEntryRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.CreateCertificateMapEntryRequest): - request = certificate_manager.CreateCertificateMapEntryRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate_map_entry is not None: - request.certificate_map_entry = certificate_map_entry - if certificate_map_entry_id is not None: - request.certificate_map_entry_id = certificate_map_entry_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_certificate_map_entry] - - # 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, - certificate_manager.CertificateMapEntry, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_certificate_map_entry(self, - request: Optional[Union[certificate_manager.UpdateCertificateMapEntryRequest, dict]] = None, - *, - certificate_map_entry: Optional[certificate_manager.CertificateMapEntry] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Updates a CertificateMapEntry. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_update_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - certificate_map_entry = certificate_manager_v1.CertificateMapEntry() - certificate_map_entry.hostname = "hostname_value" - - request = certificate_manager_v1.UpdateCertificateMapEntryRequest( - certificate_map_entry=certificate_map_entry, - ) - - # Make the request - operation = client.update_certificate_map_entry(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.UpdateCertificateMapEntryRequest, dict]): - The request object. Request for the - `UpdateCertificateMapEntry` method. - certificate_map_entry (google.cloud.certificate_manager_v1.types.CertificateMapEntry): - Required. A definition of the - certificate map entry to create map - entry. - - This corresponds to the ``certificate_map_entry`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.certificate_manager_v1.types.CertificateMapEntry` - Defines a certificate map entry. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_map_entry, 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 certificate_manager.UpdateCertificateMapEntryRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.UpdateCertificateMapEntryRequest): - request = certificate_manager.UpdateCertificateMapEntryRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_map_entry is not None: - request.certificate_map_entry = certificate_map_entry - 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_certificate_map_entry] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("certificate_map_entry.name", request.certificate_map_entry.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, - certificate_manager.CertificateMapEntry, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_certificate_map_entry(self, - request: Optional[Union[certificate_manager.DeleteCertificateMapEntryRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Deletes a single CertificateMapEntry. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_delete_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateMapEntryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate_map_entry(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.DeleteCertificateMapEntryRequest, dict]): - The request object. Request for the - `DeleteCertificateMapEntry` method. - name (str): - Required. A name of the certificate map entry to delete. - Must be in the format - ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. - - 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); - - } - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_manager.DeleteCertificateMapEntryRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.DeleteCertificateMapEntryRequest): - request = certificate_manager.DeleteCertificateMapEntryRequest(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_certificate_map_entry] - - # 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=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_dns_authorizations(self, - request: Optional[Union[certificate_manager.ListDnsAuthorizationsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListDnsAuthorizationsPager: - r"""Lists DnsAuthorizations in a given project and - location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_list_dns_authorizations(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListDnsAuthorizationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_dns_authorizations(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsRequest, dict]): - The request object. Request for the - `ListDnsAuthorizations` method. - parent (str): - Required. The project and location from which the dns - authorizations should 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.certificate_manager_v1.services.certificate_manager.pagers.ListDnsAuthorizationsPager: - Response for the ListDnsAuthorizations method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_manager.ListDnsAuthorizationsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.ListDnsAuthorizationsRequest): - request = certificate_manager.ListDnsAuthorizationsRequest(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_dns_authorizations] - - # 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.ListDnsAuthorizationsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_dns_authorization(self, - request: Optional[Union[certificate_manager.GetDnsAuthorizationRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> certificate_manager.DnsAuthorization: - r"""Gets details of a single DnsAuthorization. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_get_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetDnsAuthorizationRequest( - name="name_value", - ) - - # Make the request - response = client.get_dns_authorization(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.GetDnsAuthorizationRequest, dict]): - The request object. Request for the - `GetDnsAuthorization` method. - name (str): - Required. A name of the dns authorization to describe. - Must be in the format - ``projects/*/locations/*/dnsAuthorizations/*``. - - 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.certificate_manager_v1.types.DnsAuthorization: - A DnsAuthorization resource describes - a way to perform domain authorization - for certificate issuance. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_manager.GetDnsAuthorizationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.GetDnsAuthorizationRequest): - request = certificate_manager.GetDnsAuthorizationRequest(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_dns_authorization] - - # 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_dns_authorization(self, - request: Optional[Union[certificate_manager.CreateDnsAuthorizationRequest, dict]] = None, - *, - parent: Optional[str] = None, - dns_authorization: Optional[certificate_manager.DnsAuthorization] = None, - dns_authorization_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates a new DnsAuthorization in a given project and - location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_create_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - dns_authorization = certificate_manager_v1.DnsAuthorization() - dns_authorization.domain = "domain_value" - - request = certificate_manager_v1.CreateDnsAuthorizationRequest( - parent="parent_value", - dns_authorization_id="dns_authorization_id_value", - dns_authorization=dns_authorization, - ) - - # Make the request - operation = client.create_dns_authorization(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.CreateDnsAuthorizationRequest, dict]): - The request object. Request for the - `CreateDnsAuthorization` method. - parent (str): - Required. The parent resource of the dns authorization. - Must be in the format ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - dns_authorization (google.cloud.certificate_manager_v1.types.DnsAuthorization): - Required. A definition of the dns - authorization to create. - - This corresponds to the ``dns_authorization`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - dns_authorization_id (str): - Required. A user-provided name of the - dns authorization. - - This corresponds to the ``dns_authorization_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.certificate_manager_v1.types.DnsAuthorization` A DnsAuthorization resource describes a way to perform domain authorization - for certificate issuance. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, dns_authorization, dns_authorization_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 certificate_manager.CreateDnsAuthorizationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.CreateDnsAuthorizationRequest): - request = certificate_manager.CreateDnsAuthorizationRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if dns_authorization is not None: - request.dns_authorization = dns_authorization - if dns_authorization_id is not None: - request.dns_authorization_id = dns_authorization_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_dns_authorization] - - # 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, - certificate_manager.DnsAuthorization, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_dns_authorization(self, - request: Optional[Union[certificate_manager.UpdateDnsAuthorizationRequest, dict]] = None, - *, - dns_authorization: Optional[certificate_manager.DnsAuthorization] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Updates a DnsAuthorization. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_update_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - dns_authorization = certificate_manager_v1.DnsAuthorization() - dns_authorization.domain = "domain_value" - - request = certificate_manager_v1.UpdateDnsAuthorizationRequest( - dns_authorization=dns_authorization, - ) - - # Make the request - operation = client.update_dns_authorization(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.UpdateDnsAuthorizationRequest, dict]): - The request object. Request for the - `UpdateDnsAuthorization` method. - dns_authorization (google.cloud.certificate_manager_v1.types.DnsAuthorization): - Required. A definition of the dns - authorization to update. - - This corresponds to the ``dns_authorization`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.certificate_manager_v1.types.DnsAuthorization` A DnsAuthorization resource describes a way to perform domain authorization - for certificate issuance. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([dns_authorization, 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 certificate_manager.UpdateDnsAuthorizationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.UpdateDnsAuthorizationRequest): - request = certificate_manager.UpdateDnsAuthorizationRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if dns_authorization is not None: - request.dns_authorization = dns_authorization - 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_dns_authorization] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("dns_authorization.name", request.dns_authorization.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, - certificate_manager.DnsAuthorization, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_dns_authorization(self, - request: Optional[Union[certificate_manager.DeleteDnsAuthorizationRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Deletes a single DnsAuthorization. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_delete_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteDnsAuthorizationRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_dns_authorization(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.DeleteDnsAuthorizationRequest, dict]): - The request object. Request for the - `DeleteDnsAuthorization` method. - name (str): - Required. A name of the dns authorization to delete. - Must be in the format - ``projects/*/locations/*/dnsAuthorizations/*``. - - 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); - - } - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_manager.DeleteDnsAuthorizationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_manager.DeleteDnsAuthorizationRequest): - request = certificate_manager.DeleteDnsAuthorizationRequest(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_dns_authorization] - - # 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=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_certificate_issuance_configs(self, - request: Optional[Union[certificate_issuance_config.ListCertificateIssuanceConfigsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateIssuanceConfigsPager: - r"""Lists CertificateIssuanceConfigs in a given project - and location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_list_certificate_issuance_configs(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificateIssuanceConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificate_issuance_configs(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsRequest, dict]): - The request object. Request for the - `ListCertificateIssuanceConfigs` method. - parent (str): - Required. The project and location from which the - certificate should 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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateIssuanceConfigsPager: - Response for the ListCertificateIssuanceConfigs method. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_issuance_config.ListCertificateIssuanceConfigsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_issuance_config.ListCertificateIssuanceConfigsRequest): - request = certificate_issuance_config.ListCertificateIssuanceConfigsRequest(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_certificate_issuance_configs] - - # 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.ListCertificateIssuanceConfigsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_certificate_issuance_config(self, - request: Optional[Union[certificate_issuance_config.GetCertificateIssuanceConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> certificate_issuance_config.CertificateIssuanceConfig: - r"""Gets details of a single CertificateIssuanceConfig. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_get_certificate_issuance_config(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateIssuanceConfigRequest( - name="name_value", - ) - - # Make the request - response = client.get_certificate_issuance_config(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.GetCertificateIssuanceConfigRequest, dict]): - The request object. Request for the - `GetCertificateIssuanceConfig` method. - name (str): - Required. A name of the certificate issuance config to - describe. Must be in the format - ``projects/*/locations/*/certificateIssuanceConfigs/*``. - - 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.certificate_manager_v1.types.CertificateIssuanceConfig: - CertificateIssuanceConfig specifies - how to issue and manage a certificate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_issuance_config.GetCertificateIssuanceConfigRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_issuance_config.GetCertificateIssuanceConfigRequest): - request = certificate_issuance_config.GetCertificateIssuanceConfigRequest(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_certificate_issuance_config] - - # 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_certificate_issuance_config(self, - request: Optional[Union[gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, dict]] = None, - *, - parent: Optional[str] = None, - certificate_issuance_config: Optional[gcc_certificate_issuance_config.CertificateIssuanceConfig] = None, - certificate_issuance_config_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates a new CertificateIssuanceConfig in a given - project and location. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_create_certificate_issuance_config(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - certificate_issuance_config = certificate_manager_v1.CertificateIssuanceConfig() - certificate_issuance_config.certificate_authority_config.certificate_authority_service_config.ca_pool = "ca_pool_value" - certificate_issuance_config.rotation_window_percentage = 2788 - certificate_issuance_config.key_algorithm = "ECDSA_P256" - - request = certificate_manager_v1.CreateCertificateIssuanceConfigRequest( - parent="parent_value", - certificate_issuance_config_id="certificate_issuance_config_id_value", - certificate_issuance_config=certificate_issuance_config, - ) - - # Make the request - operation = client.create_certificate_issuance_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.CreateCertificateIssuanceConfigRequest, dict]): - The request object. Request for the - `CreateCertificateIssuanceConfig` method. - parent (str): - Required. The parent resource of the certificate - issuance config. Must be in the format - ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_issuance_config (google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig): - Required. A definition of the - certificate issuance config to create. - - This corresponds to the ``certificate_issuance_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_issuance_config_id (str): - Required. A user-provided name of the - certificate config. - - This corresponds to the ``certificate_issuance_config_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.certificate_manager_v1.types.CertificateIssuanceConfig` - CertificateIssuanceConfig specifies how to issue and - manage a certificate. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate_issuance_config, certificate_issuance_config_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 gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest): - request = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate_issuance_config is not None: - request.certificate_issuance_config = certificate_issuance_config - if certificate_issuance_config_id is not None: - request.certificate_issuance_config_id = certificate_issuance_config_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_certificate_issuance_config] - - # 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, - gcc_certificate_issuance_config.CertificateIssuanceConfig, - metadata_type=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_certificate_issuance_config(self, - request: Optional[Union[certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Deletes a single CertificateIssuanceConfig. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import certificate_manager_v1 - - def sample_delete_certificate_issuance_config(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateIssuanceConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate_issuance_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.certificate_manager_v1.types.DeleteCertificateIssuanceConfigRequest, dict]): - The request object. Request for the - `DeleteCertificateIssuanceConfig` method. - name (str): - Required. A name of the certificate issuance config to - delete. Must be in the format - ``projects/*/locations/*/certificateIssuanceConfigs/*``. - - 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); - - } - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a certificate_issuance_config.DeleteCertificateIssuanceConfigRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, certificate_issuance_config.DeleteCertificateIssuanceConfigRequest): - request = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest(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_certificate_issuance_config] - - # 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=certificate_manager.OperationMetadata, - ) - - # Done; return the response. - return response - - def __enter__(self) -> "CertificateManagerClient": - return self - - def __exit__(self, type, value, traceback): - """Releases underlying transport's resources. - - .. warning:: - ONLY use as a context manager if the transport is NOT shared - with other clients! Exiting the with block will CLOSE the transport - and may cause errors in other clients! - """ - self.transport.close() - - def list_operations( - self, - request: Optional[operations_pb2.ListOperationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.ListOperationsResponse: - r"""Lists operations that match the specified filter in the request. - - Args: - request (:class:`~.operations_pb2.ListOperationsRequest`): - The request object. Request message for - `ListOperations` 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: - ~.operations_pb2.ListOperationsResponse: - Response message for ``ListOperations`` method. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.ListOperationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_operations, - 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 = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - def get_operation( - self, - request: Optional[operations_pb2.GetOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Gets the latest state of a long-running operation. - - Args: - request (:class:`~.operations_pb2.GetOperationRequest`): - The request object. Request message for - `GetOperation` 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: - ~.operations_pb2.Operation: - An ``Operation`` object. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.GetOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_operation, - 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 = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - def delete_operation( - self, - request: Optional[operations_pb2.DeleteOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a long-running operation. - - This method indicates that the client is no longer interested - in the operation result. It does not cancel the operation. - If the server doesn't support this method, it returns - `google.rpc.Code.UNIMPLEMENTED`. - - Args: - request (:class:`~.operations_pb2.DeleteOperationRequest`): - The request object. Request message for - `DeleteOperation` 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: - None - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.DeleteOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.delete_operation, - 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. - rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - def cancel_operation( - self, - request: Optional[operations_pb2.CancelOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Starts asynchronous cancellation on a long-running operation. - - The server makes a best effort to cancel the operation, but success - is not guaranteed. If the server doesn't support this method, it returns - `google.rpc.Code.UNIMPLEMENTED`. - - Args: - request (:class:`~.operations_pb2.CancelOperationRequest`): - The request object. Request message for - `CancelOperation` 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: - None - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.CancelOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.cancel_operation, - 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. - rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location object. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - def list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` method. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "CertificateManagerClient", -) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/pagers.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/pagers.py deleted file mode 100644 index 364a957..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/pagers.py +++ /dev/null @@ -1,624 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator - -from google.cloud.certificate_manager_v1.types import certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_manager - - -class ListCertificatesPager: - """A pager for iterating through ``list_certificates`` requests. - - This class thinly wraps an initial - :class:`google.cloud.certificate_manager_v1.types.ListCertificatesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``certificates`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCertificates`` requests and continue to iterate - through the ``certificates`` field on the - corresponding responses. - - All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificatesResponse` - 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[..., certificate_manager.ListCertificatesResponse], - request: certificate_manager.ListCertificatesRequest, - response: certificate_manager.ListCertificatesResponse, - *, - 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.certificate_manager_v1.types.ListCertificatesRequest): - The initial request object. - response (google.cloud.certificate_manager_v1.types.ListCertificatesResponse): - 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 = certificate_manager.ListCertificatesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[certificate_manager.ListCertificatesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[certificate_manager.Certificate]: - for page in self.pages: - yield from page.certificates - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificatesAsyncPager: - """A pager for iterating through ``list_certificates`` requests. - - This class thinly wraps an initial - :class:`google.cloud.certificate_manager_v1.types.ListCertificatesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``certificates`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCertificates`` requests and continue to iterate - through the ``certificates`` field on the - corresponding responses. - - All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificatesResponse` - 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[certificate_manager.ListCertificatesResponse]], - request: certificate_manager.ListCertificatesRequest, - response: certificate_manager.ListCertificatesResponse, - *, - 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.certificate_manager_v1.types.ListCertificatesRequest): - The initial request object. - response (google.cloud.certificate_manager_v1.types.ListCertificatesResponse): - 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 = certificate_manager.ListCertificatesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[certificate_manager.ListCertificatesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[certificate_manager.Certificate]: - async def async_generator(): - async for page in self.pages: - for response in page.certificates: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateMapsPager: - """A pager for iterating through ``list_certificate_maps`` requests. - - This class thinly wraps an initial - :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``certificate_maps`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCertificateMaps`` requests and continue to iterate - through the ``certificate_maps`` field on the - corresponding responses. - - All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapsResponse` - 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[..., certificate_manager.ListCertificateMapsResponse], - request: certificate_manager.ListCertificateMapsRequest, - response: certificate_manager.ListCertificateMapsResponse, - *, - 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.certificate_manager_v1.types.ListCertificateMapsRequest): - The initial request object. - response (google.cloud.certificate_manager_v1.types.ListCertificateMapsResponse): - 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 = certificate_manager.ListCertificateMapsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[certificate_manager.ListCertificateMapsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[certificate_manager.CertificateMap]: - for page in self.pages: - yield from page.certificate_maps - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateMapsAsyncPager: - """A pager for iterating through ``list_certificate_maps`` requests. - - This class thinly wraps an initial - :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``certificate_maps`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCertificateMaps`` requests and continue to iterate - through the ``certificate_maps`` field on the - corresponding responses. - - All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapsResponse` - 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[certificate_manager.ListCertificateMapsResponse]], - request: certificate_manager.ListCertificateMapsRequest, - response: certificate_manager.ListCertificateMapsResponse, - *, - 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.certificate_manager_v1.types.ListCertificateMapsRequest): - The initial request object. - response (google.cloud.certificate_manager_v1.types.ListCertificateMapsResponse): - 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 = certificate_manager.ListCertificateMapsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[certificate_manager.ListCertificateMapsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[certificate_manager.CertificateMap]: - async def async_generator(): - async for page in self.pages: - for response in page.certificate_maps: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateMapEntriesPager: - """A pager for iterating through ``list_certificate_map_entries`` requests. - - This class thinly wraps an initial - :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``certificate_map_entries`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCertificateMapEntries`` requests and continue to iterate - through the ``certificate_map_entries`` field on the - corresponding responses. - - All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesResponse` - 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[..., certificate_manager.ListCertificateMapEntriesResponse], - request: certificate_manager.ListCertificateMapEntriesRequest, - response: certificate_manager.ListCertificateMapEntriesResponse, - *, - 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.certificate_manager_v1.types.ListCertificateMapEntriesRequest): - The initial request object. - response (google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesResponse): - 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 = certificate_manager.ListCertificateMapEntriesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[certificate_manager.ListCertificateMapEntriesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[certificate_manager.CertificateMapEntry]: - for page in self.pages: - yield from page.certificate_map_entries - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateMapEntriesAsyncPager: - """A pager for iterating through ``list_certificate_map_entries`` requests. - - This class thinly wraps an initial - :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``certificate_map_entries`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCertificateMapEntries`` requests and continue to iterate - through the ``certificate_map_entries`` field on the - corresponding responses. - - All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesResponse` - 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[certificate_manager.ListCertificateMapEntriesResponse]], - request: certificate_manager.ListCertificateMapEntriesRequest, - response: certificate_manager.ListCertificateMapEntriesResponse, - *, - 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.certificate_manager_v1.types.ListCertificateMapEntriesRequest): - The initial request object. - response (google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesResponse): - 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 = certificate_manager.ListCertificateMapEntriesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[certificate_manager.ListCertificateMapEntriesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[certificate_manager.CertificateMapEntry]: - async def async_generator(): - async for page in self.pages: - for response in page.certificate_map_entries: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListDnsAuthorizationsPager: - """A pager for iterating through ``list_dns_authorizations`` requests. - - This class thinly wraps an initial - :class:`google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``dns_authorizations`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListDnsAuthorizations`` requests and continue to iterate - through the ``dns_authorizations`` field on the - corresponding responses. - - All the usual :class:`google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsResponse` - 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[..., certificate_manager.ListDnsAuthorizationsResponse], - request: certificate_manager.ListDnsAuthorizationsRequest, - response: certificate_manager.ListDnsAuthorizationsResponse, - *, - 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.certificate_manager_v1.types.ListDnsAuthorizationsRequest): - The initial request object. - response (google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsResponse): - 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 = certificate_manager.ListDnsAuthorizationsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[certificate_manager.ListDnsAuthorizationsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[certificate_manager.DnsAuthorization]: - for page in self.pages: - yield from page.dns_authorizations - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListDnsAuthorizationsAsyncPager: - """A pager for iterating through ``list_dns_authorizations`` requests. - - This class thinly wraps an initial - :class:`google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``dns_authorizations`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListDnsAuthorizations`` requests and continue to iterate - through the ``dns_authorizations`` field on the - corresponding responses. - - All the usual :class:`google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsResponse` - 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[certificate_manager.ListDnsAuthorizationsResponse]], - request: certificate_manager.ListDnsAuthorizationsRequest, - response: certificate_manager.ListDnsAuthorizationsResponse, - *, - 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.certificate_manager_v1.types.ListDnsAuthorizationsRequest): - The initial request object. - response (google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsResponse): - 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 = certificate_manager.ListDnsAuthorizationsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[certificate_manager.ListDnsAuthorizationsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[certificate_manager.DnsAuthorization]: - async def async_generator(): - async for page in self.pages: - for response in page.dns_authorizations: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateIssuanceConfigsPager: - """A pager for iterating through ``list_certificate_issuance_configs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``certificate_issuance_configs`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCertificateIssuanceConfigs`` requests and continue to iterate - through the ``certificate_issuance_configs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsResponse` - 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[..., certificate_issuance_config.ListCertificateIssuanceConfigsResponse], - request: certificate_issuance_config.ListCertificateIssuanceConfigsRequest, - response: certificate_issuance_config.ListCertificateIssuanceConfigsResponse, - *, - 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.certificate_manager_v1.types.ListCertificateIssuanceConfigsRequest): - The initial request object. - response (google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsResponse): - 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 = certificate_issuance_config.ListCertificateIssuanceConfigsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[certificate_issuance_config.ListCertificateIssuanceConfigsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[certificate_issuance_config.CertificateIssuanceConfig]: - for page in self.pages: - yield from page.certificate_issuance_configs - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateIssuanceConfigsAsyncPager: - """A pager for iterating through ``list_certificate_issuance_configs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``certificate_issuance_configs`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCertificateIssuanceConfigs`` requests and continue to iterate - through the ``certificate_issuance_configs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsResponse` - 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[certificate_issuance_config.ListCertificateIssuanceConfigsResponse]], - request: certificate_issuance_config.ListCertificateIssuanceConfigsRequest, - response: certificate_issuance_config.ListCertificateIssuanceConfigsResponse, - *, - 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.certificate_manager_v1.types.ListCertificateIssuanceConfigsRequest): - The initial request object. - response (google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsResponse): - 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 = certificate_issuance_config.ListCertificateIssuanceConfigsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[certificate_issuance_config.ListCertificateIssuanceConfigsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[certificate_issuance_config.CertificateIssuanceConfig]: - async def async_generator(): - async for page in self.pages: - for response in page.certificate_issuance_configs: - 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/certificate_manager_v1/services/certificate_manager/transports/__init__.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/__init__.py deleted file mode 100644 index 2dc03cd..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/__init__.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -from typing import Dict, Type - -from .base import CertificateManagerTransport -from .grpc import CertificateManagerGrpcTransport -from .grpc_asyncio import CertificateManagerGrpcAsyncIOTransport -from .rest import CertificateManagerRestTransport -from .rest import CertificateManagerRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[CertificateManagerTransport]] -_transport_registry['grpc'] = CertificateManagerGrpcTransport -_transport_registry['grpc_asyncio'] = CertificateManagerGrpcAsyncIOTransport -_transport_registry['rest'] = CertificateManagerRestTransport - -__all__ = ( - 'CertificateManagerTransport', - 'CertificateManagerGrpcTransport', - 'CertificateManagerGrpcAsyncIOTransport', - 'CertificateManagerRestTransport', - 'CertificateManagerRestInterceptor', -) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/base.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/base.py deleted file mode 100644 index 5d56c3e..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/base.py +++ /dev/null @@ -1,677 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union - -from google.cloud.certificate_manager_v1 import gapic_version as package_version - -import google.auth # type: ignore -import google.api_core -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.certificate_manager_v1.types import certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_manager -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class CertificateManagerTransport(abc.ABC): - """Abstract transport class for CertificateManager.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) - - DEFAULT_HOST: str = 'certificatemanager.googleapis.com' - def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: Optional[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, - api_audience: Optional[str] = None, - **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. - """ - - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_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) - # Don't apply audience if the credentials file passed from user. - if hasattr(credentials, "with_gdch_audience"): - credentials = credentials.with_gdch_audience(api_audience if api_audience else host) - - # If the credentials are 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 - - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' - self._host = host - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.list_certificates: gapic_v1.method.wrap_method( - self.list_certificates, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_certificate: gapic_v1.method.wrap_method( - self.get_certificate, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_certificate: gapic_v1.method.wrap_method( - self.create_certificate, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.update_certificate: gapic_v1.method.wrap_method( - self.update_certificate, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.delete_certificate: gapic_v1.method.wrap_method( - self.delete_certificate, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_certificate_maps: gapic_v1.method.wrap_method( - self.list_certificate_maps, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_certificate_map: gapic_v1.method.wrap_method( - self.get_certificate_map, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_certificate_map: gapic_v1.method.wrap_method( - self.create_certificate_map, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.update_certificate_map: gapic_v1.method.wrap_method( - self.update_certificate_map, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.delete_certificate_map: gapic_v1.method.wrap_method( - self.delete_certificate_map, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_certificate_map_entries: gapic_v1.method.wrap_method( - self.list_certificate_map_entries, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_certificate_map_entry: gapic_v1.method.wrap_method( - self.get_certificate_map_entry, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_certificate_map_entry: gapic_v1.method.wrap_method( - self.create_certificate_map_entry, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.update_certificate_map_entry: gapic_v1.method.wrap_method( - self.update_certificate_map_entry, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.delete_certificate_map_entry: gapic_v1.method.wrap_method( - self.delete_certificate_map_entry, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_dns_authorizations: gapic_v1.method.wrap_method( - self.list_dns_authorizations, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_dns_authorization: gapic_v1.method.wrap_method( - self.get_dns_authorization, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_dns_authorization: gapic_v1.method.wrap_method( - self.create_dns_authorization, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.update_dns_authorization: gapic_v1.method.wrap_method( - self.update_dns_authorization, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.delete_dns_authorization: gapic_v1.method.wrap_method( - self.delete_dns_authorization, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_certificate_issuance_configs: gapic_v1.method.wrap_method( - self.list_certificate_issuance_configs, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_certificate_issuance_config: gapic_v1.method.wrap_method( - self.get_certificate_issuance_config, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_certificate_issuance_config: gapic_v1.method.wrap_method( - self.create_certificate_issuance_config, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.delete_certificate_issuance_config: gapic_v1.method.wrap_method( - self.delete_certificate_issuance_config, - default_retry=retries.Retry( -initial=1.0,maximum=10.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - } - - def close(self): - """Closes resources associated with the transport. - - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! - """ - raise NotImplementedError() - - @property - def operations_client(self): - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def list_certificates(self) -> Callable[ - [certificate_manager.ListCertificatesRequest], - Union[ - certificate_manager.ListCertificatesResponse, - Awaitable[certificate_manager.ListCertificatesResponse] - ]]: - raise NotImplementedError() - - @property - def get_certificate(self) -> Callable[ - [certificate_manager.GetCertificateRequest], - Union[ - certificate_manager.Certificate, - Awaitable[certificate_manager.Certificate] - ]]: - raise NotImplementedError() - - @property - def create_certificate(self) -> Callable[ - [certificate_manager.CreateCertificateRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_certificate(self) -> Callable[ - [certificate_manager.UpdateCertificateRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_certificate(self) -> Callable[ - [certificate_manager.DeleteCertificateRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_certificate_maps(self) -> Callable[ - [certificate_manager.ListCertificateMapsRequest], - Union[ - certificate_manager.ListCertificateMapsResponse, - Awaitable[certificate_manager.ListCertificateMapsResponse] - ]]: - raise NotImplementedError() - - @property - def get_certificate_map(self) -> Callable[ - [certificate_manager.GetCertificateMapRequest], - Union[ - certificate_manager.CertificateMap, - Awaitable[certificate_manager.CertificateMap] - ]]: - raise NotImplementedError() - - @property - def create_certificate_map(self) -> Callable[ - [certificate_manager.CreateCertificateMapRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_certificate_map(self) -> Callable[ - [certificate_manager.UpdateCertificateMapRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_certificate_map(self) -> Callable[ - [certificate_manager.DeleteCertificateMapRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_certificate_map_entries(self) -> Callable[ - [certificate_manager.ListCertificateMapEntriesRequest], - Union[ - certificate_manager.ListCertificateMapEntriesResponse, - Awaitable[certificate_manager.ListCertificateMapEntriesResponse] - ]]: - raise NotImplementedError() - - @property - def get_certificate_map_entry(self) -> Callable[ - [certificate_manager.GetCertificateMapEntryRequest], - Union[ - certificate_manager.CertificateMapEntry, - Awaitable[certificate_manager.CertificateMapEntry] - ]]: - raise NotImplementedError() - - @property - def create_certificate_map_entry(self) -> Callable[ - [certificate_manager.CreateCertificateMapEntryRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_certificate_map_entry(self) -> Callable[ - [certificate_manager.UpdateCertificateMapEntryRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_certificate_map_entry(self) -> Callable[ - [certificate_manager.DeleteCertificateMapEntryRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_dns_authorizations(self) -> Callable[ - [certificate_manager.ListDnsAuthorizationsRequest], - Union[ - certificate_manager.ListDnsAuthorizationsResponse, - Awaitable[certificate_manager.ListDnsAuthorizationsResponse] - ]]: - raise NotImplementedError() - - @property - def get_dns_authorization(self) -> Callable[ - [certificate_manager.GetDnsAuthorizationRequest], - Union[ - certificate_manager.DnsAuthorization, - Awaitable[certificate_manager.DnsAuthorization] - ]]: - raise NotImplementedError() - - @property - def create_dns_authorization(self) -> Callable[ - [certificate_manager.CreateDnsAuthorizationRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_dns_authorization(self) -> Callable[ - [certificate_manager.UpdateDnsAuthorizationRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_dns_authorization(self) -> Callable[ - [certificate_manager.DeleteDnsAuthorizationRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_certificate_issuance_configs(self) -> Callable[ - [certificate_issuance_config.ListCertificateIssuanceConfigsRequest], - Union[ - certificate_issuance_config.ListCertificateIssuanceConfigsResponse, - Awaitable[certificate_issuance_config.ListCertificateIssuanceConfigsResponse] - ]]: - raise NotImplementedError() - - @property - def get_certificate_issuance_config(self) -> Callable[ - [certificate_issuance_config.GetCertificateIssuanceConfigRequest], - Union[ - certificate_issuance_config.CertificateIssuanceConfig, - Awaitable[certificate_issuance_config.CertificateIssuanceConfig] - ]]: - raise NotImplementedError() - - @property - def create_certificate_issuance_config(self) -> Callable[ - [gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_certificate_issuance_config(self) -> Callable[ - [certificate_issuance_config.DeleteCertificateIssuanceConfigRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_operations( - self, - ) -> Callable[ - [operations_pb2.ListOperationsRequest], - Union[operations_pb2.ListOperationsResponse, Awaitable[operations_pb2.ListOperationsResponse]], - ]: - raise NotImplementedError() - - @property - def get_operation( - self, - ) -> Callable[ - [operations_pb2.GetOperationRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - @property - def cancel_operation( - self, - ) -> Callable[ - [operations_pb2.CancelOperationRequest], - None, - ]: - raise NotImplementedError() - - @property - def delete_operation( - self, - ) -> Callable[ - [operations_pb2.DeleteOperationRequest], - None, - ]: - raise NotImplementedError() - - @property - def get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'CertificateManagerTransport', -) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc.py deleted file mode 100644 index a6daa67..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc.py +++ /dev/null @@ -1,1036 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import operations_v1 -from google.api_core import gapic_v1 -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.certificate_manager_v1.types import certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_manager -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from .base import CertificateManagerTransport, DEFAULT_CLIENT_INFO - - -class CertificateManagerGrpcTransport(CertificateManagerTransport): - """gRPC backend transport for CertificateManager. - - API Overview - - Certificates Manager API allows customers to see and manage all - their TLS certificates. - - Certificates Manager API service provides methods to manage - certificates, group them into collections, and create serving - configuration that can be easily applied to other Cloud resources - e.g. Target Proxies. - - Data Model - - The Certificates Manager service exposes the following resources: - - - ``Certificate`` that describes a single TLS certificate. - - ``CertificateMap`` that describes a collection of certificates - that can be attached to a target resource. - - ``CertificateMapEntry`` that describes a single configuration - entry that consists of a SNI and a group of certificates. It's a - subresource of CertificateMap. - - Certificate, CertificateMap and CertificateMapEntry IDs have to - fully match the regexp ``[a-z0-9-]{1,63}``. In other words, - - - only lower case letters, digits, and hyphen are allowed - - length of the resource ID has to be in [1,63] range. - - Provides methods to manage Cloud Certificate Manager entities. - - 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 = 'certificatemanager.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[grpc.Channel] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[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, - api_audience: Optional[str] = None, - ) -> 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 application 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 the 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 a 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. - 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 - 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: Optional[operations_v1.OperationsClient] = 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=always_use_jwt_access, - api_audience=api_audience, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - 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 = 'certificatemanager.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[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. - """ - # Quick 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_certificates(self) -> Callable[ - [certificate_manager.ListCertificatesRequest], - certificate_manager.ListCertificatesResponse]: - r"""Return a callable for the list certificates method over gRPC. - - Lists Certificates in a given project and location. - - Returns: - Callable[[~.ListCertificatesRequest], - ~.ListCertificatesResponse]: - 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_certificates' not in self._stubs: - self._stubs['list_certificates'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificates', - request_serializer=certificate_manager.ListCertificatesRequest.serialize, - response_deserializer=certificate_manager.ListCertificatesResponse.deserialize, - ) - return self._stubs['list_certificates'] - - @property - def get_certificate(self) -> Callable[ - [certificate_manager.GetCertificateRequest], - certificate_manager.Certificate]: - r"""Return a callable for the get certificate method over gRPC. - - Gets details of a single Certificate. - - Returns: - Callable[[~.GetCertificateRequest], - ~.Certificate]: - 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_certificate' not in self._stubs: - self._stubs['get_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificate', - request_serializer=certificate_manager.GetCertificateRequest.serialize, - response_deserializer=certificate_manager.Certificate.deserialize, - ) - return self._stubs['get_certificate'] - - @property - def create_certificate(self) -> Callable[ - [certificate_manager.CreateCertificateRequest], - operations_pb2.Operation]: - r"""Return a callable for the create certificate method over gRPC. - - Creates a new Certificate in a given project and - location. - - Returns: - Callable[[~.CreateCertificateRequest], - ~.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_certificate' not in self._stubs: - self._stubs['create_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificate', - request_serializer=certificate_manager.CreateCertificateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate'] - - @property - def update_certificate(self) -> Callable[ - [certificate_manager.UpdateCertificateRequest], - operations_pb2.Operation]: - r"""Return a callable for the update certificate method over gRPC. - - Updates a Certificate. - - Returns: - Callable[[~.UpdateCertificateRequest], - ~.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_certificate' not in self._stubs: - self._stubs['update_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificate', - request_serializer=certificate_manager.UpdateCertificateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate'] - - @property - def delete_certificate(self) -> Callable[ - [certificate_manager.DeleteCertificateRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete certificate method over gRPC. - - Deletes a single Certificate. - - Returns: - Callable[[~.DeleteCertificateRequest], - ~.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_certificate' not in self._stubs: - self._stubs['delete_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificate', - request_serializer=certificate_manager.DeleteCertificateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_certificate'] - - @property - def list_certificate_maps(self) -> Callable[ - [certificate_manager.ListCertificateMapsRequest], - certificate_manager.ListCertificateMapsResponse]: - r"""Return a callable for the list certificate maps method over gRPC. - - Lists CertificateMaps in a given project and - location. - - Returns: - Callable[[~.ListCertificateMapsRequest], - ~.ListCertificateMapsResponse]: - 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_certificate_maps' not in self._stubs: - self._stubs['list_certificate_maps'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateMaps', - request_serializer=certificate_manager.ListCertificateMapsRequest.serialize, - response_deserializer=certificate_manager.ListCertificateMapsResponse.deserialize, - ) - return self._stubs['list_certificate_maps'] - - @property - def get_certificate_map(self) -> Callable[ - [certificate_manager.GetCertificateMapRequest], - certificate_manager.CertificateMap]: - r"""Return a callable for the get certificate map method over gRPC. - - Gets details of a single CertificateMap. - - Returns: - Callable[[~.GetCertificateMapRequest], - ~.CertificateMap]: - 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_certificate_map' not in self._stubs: - self._stubs['get_certificate_map'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateMap', - request_serializer=certificate_manager.GetCertificateMapRequest.serialize, - response_deserializer=certificate_manager.CertificateMap.deserialize, - ) - return self._stubs['get_certificate_map'] - - @property - def create_certificate_map(self) -> Callable[ - [certificate_manager.CreateCertificateMapRequest], - operations_pb2.Operation]: - r"""Return a callable for the create certificate map method over gRPC. - - Creates a new CertificateMap in a given project and - location. - - Returns: - Callable[[~.CreateCertificateMapRequest], - ~.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_certificate_map' not in self._stubs: - self._stubs['create_certificate_map'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateMap', - request_serializer=certificate_manager.CreateCertificateMapRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate_map'] - - @property - def update_certificate_map(self) -> Callable[ - [certificate_manager.UpdateCertificateMapRequest], - operations_pb2.Operation]: - r"""Return a callable for the update certificate map method over gRPC. - - Updates a CertificateMap. - - Returns: - Callable[[~.UpdateCertificateMapRequest], - ~.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_certificate_map' not in self._stubs: - self._stubs['update_certificate_map'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificateMap', - request_serializer=certificate_manager.UpdateCertificateMapRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_map'] - - @property - def delete_certificate_map(self) -> Callable[ - [certificate_manager.DeleteCertificateMapRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete certificate map method over gRPC. - - Deletes a single CertificateMap. A Certificate Map - can't be deleted if it contains Certificate Map Entries. - Remove all the entries from the map before calling this - method. - - Returns: - Callable[[~.DeleteCertificateMapRequest], - ~.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_certificate_map' not in self._stubs: - self._stubs['delete_certificate_map'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateMap', - request_serializer=certificate_manager.DeleteCertificateMapRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_certificate_map'] - - @property - def list_certificate_map_entries(self) -> Callable[ - [certificate_manager.ListCertificateMapEntriesRequest], - certificate_manager.ListCertificateMapEntriesResponse]: - r"""Return a callable for the list certificate map entries method over gRPC. - - Lists CertificateMapEntries in a given project and - location. - - Returns: - Callable[[~.ListCertificateMapEntriesRequest], - ~.ListCertificateMapEntriesResponse]: - 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_certificate_map_entries' not in self._stubs: - self._stubs['list_certificate_map_entries'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateMapEntries', - request_serializer=certificate_manager.ListCertificateMapEntriesRequest.serialize, - response_deserializer=certificate_manager.ListCertificateMapEntriesResponse.deserialize, - ) - return self._stubs['list_certificate_map_entries'] - - @property - def get_certificate_map_entry(self) -> Callable[ - [certificate_manager.GetCertificateMapEntryRequest], - certificate_manager.CertificateMapEntry]: - r"""Return a callable for the get certificate map entry method over gRPC. - - Gets details of a single CertificateMapEntry. - - Returns: - Callable[[~.GetCertificateMapEntryRequest], - ~.CertificateMapEntry]: - 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_certificate_map_entry' not in self._stubs: - self._stubs['get_certificate_map_entry'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateMapEntry', - request_serializer=certificate_manager.GetCertificateMapEntryRequest.serialize, - response_deserializer=certificate_manager.CertificateMapEntry.deserialize, - ) - return self._stubs['get_certificate_map_entry'] - - @property - def create_certificate_map_entry(self) -> Callable[ - [certificate_manager.CreateCertificateMapEntryRequest], - operations_pb2.Operation]: - r"""Return a callable for the create certificate map entry method over gRPC. - - Creates a new CertificateMapEntry in a given project - and location. - - Returns: - Callable[[~.CreateCertificateMapEntryRequest], - ~.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_certificate_map_entry' not in self._stubs: - self._stubs['create_certificate_map_entry'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateMapEntry', - request_serializer=certificate_manager.CreateCertificateMapEntryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate_map_entry'] - - @property - def update_certificate_map_entry(self) -> Callable[ - [certificate_manager.UpdateCertificateMapEntryRequest], - operations_pb2.Operation]: - r"""Return a callable for the update certificate map entry method over gRPC. - - Updates a CertificateMapEntry. - - Returns: - Callable[[~.UpdateCertificateMapEntryRequest], - ~.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_certificate_map_entry' not in self._stubs: - self._stubs['update_certificate_map_entry'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificateMapEntry', - request_serializer=certificate_manager.UpdateCertificateMapEntryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_map_entry'] - - @property - def delete_certificate_map_entry(self) -> Callable[ - [certificate_manager.DeleteCertificateMapEntryRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete certificate map entry method over gRPC. - - Deletes a single CertificateMapEntry. - - Returns: - Callable[[~.DeleteCertificateMapEntryRequest], - ~.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_certificate_map_entry' not in self._stubs: - self._stubs['delete_certificate_map_entry'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateMapEntry', - request_serializer=certificate_manager.DeleteCertificateMapEntryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_certificate_map_entry'] - - @property - def list_dns_authorizations(self) -> Callable[ - [certificate_manager.ListDnsAuthorizationsRequest], - certificate_manager.ListDnsAuthorizationsResponse]: - r"""Return a callable for the list dns authorizations method over gRPC. - - Lists DnsAuthorizations in a given project and - location. - - Returns: - Callable[[~.ListDnsAuthorizationsRequest], - ~.ListDnsAuthorizationsResponse]: - 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_dns_authorizations' not in self._stubs: - self._stubs['list_dns_authorizations'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/ListDnsAuthorizations', - request_serializer=certificate_manager.ListDnsAuthorizationsRequest.serialize, - response_deserializer=certificate_manager.ListDnsAuthorizationsResponse.deserialize, - ) - return self._stubs['list_dns_authorizations'] - - @property - def get_dns_authorization(self) -> Callable[ - [certificate_manager.GetDnsAuthorizationRequest], - certificate_manager.DnsAuthorization]: - r"""Return a callable for the get dns authorization method over gRPC. - - Gets details of a single DnsAuthorization. - - Returns: - Callable[[~.GetDnsAuthorizationRequest], - ~.DnsAuthorization]: - 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_dns_authorization' not in self._stubs: - self._stubs['get_dns_authorization'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/GetDnsAuthorization', - request_serializer=certificate_manager.GetDnsAuthorizationRequest.serialize, - response_deserializer=certificate_manager.DnsAuthorization.deserialize, - ) - return self._stubs['get_dns_authorization'] - - @property - def create_dns_authorization(self) -> Callable[ - [certificate_manager.CreateDnsAuthorizationRequest], - operations_pb2.Operation]: - r"""Return a callable for the create dns authorization method over gRPC. - - Creates a new DnsAuthorization in a given project and - location. - - Returns: - Callable[[~.CreateDnsAuthorizationRequest], - ~.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_dns_authorization' not in self._stubs: - self._stubs['create_dns_authorization'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/CreateDnsAuthorization', - request_serializer=certificate_manager.CreateDnsAuthorizationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_dns_authorization'] - - @property - def update_dns_authorization(self) -> Callable[ - [certificate_manager.UpdateDnsAuthorizationRequest], - operations_pb2.Operation]: - r"""Return a callable for the update dns authorization method over gRPC. - - Updates a DnsAuthorization. - - Returns: - Callable[[~.UpdateDnsAuthorizationRequest], - ~.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_dns_authorization' not in self._stubs: - self._stubs['update_dns_authorization'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/UpdateDnsAuthorization', - request_serializer=certificate_manager.UpdateDnsAuthorizationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_dns_authorization'] - - @property - def delete_dns_authorization(self) -> Callable[ - [certificate_manager.DeleteDnsAuthorizationRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete dns authorization method over gRPC. - - Deletes a single DnsAuthorization. - - Returns: - Callable[[~.DeleteDnsAuthorizationRequest], - ~.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_dns_authorization' not in self._stubs: - self._stubs['delete_dns_authorization'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/DeleteDnsAuthorization', - request_serializer=certificate_manager.DeleteDnsAuthorizationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_dns_authorization'] - - @property - def list_certificate_issuance_configs(self) -> Callable[ - [certificate_issuance_config.ListCertificateIssuanceConfigsRequest], - certificate_issuance_config.ListCertificateIssuanceConfigsResponse]: - r"""Return a callable for the list certificate issuance - configs method over gRPC. - - Lists CertificateIssuanceConfigs in a given project - and location. - - Returns: - Callable[[~.ListCertificateIssuanceConfigsRequest], - ~.ListCertificateIssuanceConfigsResponse]: - 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_certificate_issuance_configs' not in self._stubs: - self._stubs['list_certificate_issuance_configs'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateIssuanceConfigs', - request_serializer=certificate_issuance_config.ListCertificateIssuanceConfigsRequest.serialize, - response_deserializer=certificate_issuance_config.ListCertificateIssuanceConfigsResponse.deserialize, - ) - return self._stubs['list_certificate_issuance_configs'] - - @property - def get_certificate_issuance_config(self) -> Callable[ - [certificate_issuance_config.GetCertificateIssuanceConfigRequest], - certificate_issuance_config.CertificateIssuanceConfig]: - r"""Return a callable for the get certificate issuance - config method over gRPC. - - Gets details of a single CertificateIssuanceConfig. - - Returns: - Callable[[~.GetCertificateIssuanceConfigRequest], - ~.CertificateIssuanceConfig]: - 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_certificate_issuance_config' not in self._stubs: - self._stubs['get_certificate_issuance_config'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateIssuanceConfig', - request_serializer=certificate_issuance_config.GetCertificateIssuanceConfigRequest.serialize, - response_deserializer=certificate_issuance_config.CertificateIssuanceConfig.deserialize, - ) - return self._stubs['get_certificate_issuance_config'] - - @property - def create_certificate_issuance_config(self) -> Callable[ - [gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest], - operations_pb2.Operation]: - r"""Return a callable for the create certificate issuance - config method over gRPC. - - Creates a new CertificateIssuanceConfig in a given - project and location. - - Returns: - Callable[[~.CreateCertificateIssuanceConfigRequest], - ~.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_certificate_issuance_config' not in self._stubs: - self._stubs['create_certificate_issuance_config'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateIssuanceConfig', - request_serializer=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate_issuance_config'] - - @property - def delete_certificate_issuance_config(self) -> Callable[ - [certificate_issuance_config.DeleteCertificateIssuanceConfigRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete certificate issuance - config method over gRPC. - - Deletes a single CertificateIssuanceConfig. - - Returns: - Callable[[~.DeleteCertificateIssuanceConfigRequest], - ~.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_certificate_issuance_config' not in self._stubs: - self._stubs['delete_certificate_issuance_config'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateIssuanceConfig', - request_serializer=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_certificate_issuance_config'] - - def close(self): - self.grpc_channel.close() - - @property - def delete_operation( - self, - ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: - r"""Return a callable for the delete_operation method over gRPC. - """ - # 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_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/DeleteOperation", - request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, - response_deserializer=None, - ) - return self._stubs["delete_operation"] - - @property - def cancel_operation( - self, - ) -> Callable[[operations_pb2.CancelOperationRequest], None]: - r"""Return a callable for the cancel_operation method over gRPC. - """ - # 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 "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/CancelOperation", - request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, - response_deserializer=None, - ) - return self._stubs["cancel_operation"] - - @property - def get_operation( - self, - ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: - r"""Return a callable for the get_operation method over gRPC. - """ - # 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_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/GetOperation", - request_serializer=operations_pb2.GetOperationRequest.SerializeToString, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["get_operation"] - - @property - def list_operations( - self, - ) -> Callable[[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse]: - r"""Return a callable for the list_operations method over gRPC. - """ - # 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_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/ListOperations", - request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, - response_deserializer=operations_pb2.ListOperationsResponse.FromString, - ) - return self._stubs["list_operations"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations method over gRPC. - """ - # 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations method over gRPC. - """ - # 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'CertificateManagerGrpcTransport', -) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc_asyncio.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc_asyncio.py deleted file mode 100644 index 1c41990..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc_asyncio.py +++ /dev/null @@ -1,1035 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.certificate_manager_v1.types import certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_manager -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from .base import CertificateManagerTransport, DEFAULT_CLIENT_INFO -from .grpc import CertificateManagerGrpcTransport - - -class CertificateManagerGrpcAsyncIOTransport(CertificateManagerTransport): - """gRPC AsyncIO backend transport for CertificateManager. - - API Overview - - Certificates Manager API allows customers to see and manage all - their TLS certificates. - - Certificates Manager API service provides methods to manage - certificates, group them into collections, and create serving - configuration that can be easily applied to other Cloud resources - e.g. Target Proxies. - - Data Model - - The Certificates Manager service exposes the following resources: - - - ``Certificate`` that describes a single TLS certificate. - - ``CertificateMap`` that describes a collection of certificates - that can be attached to a target resource. - - ``CertificateMapEntry`` that describes a single configuration - entry that consists of a SNI and a group of certificates. It's a - subresource of CertificateMap. - - Certificate, CertificateMap and CertificateMapEntry IDs have to - fully match the regexp ``[a-z0-9-]{1,63}``. In other words, - - - only lower case letters, digits, and hyphen are allowed - - length of the resource ID has to be in [1,63] range. - - Provides methods to manage Cloud Certificate Manager entities. - - 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 = 'certificatemanager.googleapis.com', - credentials: Optional[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 = 'certificatemanager.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[aio.Channel] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[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, - api_audience: Optional[str] = None, - ) -> 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 application 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 the 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 a 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. - 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 - 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: Optional[operations_v1.OperationsAsyncClient] = 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=always_use_jwt_access, - api_audience=api_audience, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - 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. - """ - # Quick 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_certificates(self) -> Callable[ - [certificate_manager.ListCertificatesRequest], - Awaitable[certificate_manager.ListCertificatesResponse]]: - r"""Return a callable for the list certificates method over gRPC. - - Lists Certificates in a given project and location. - - Returns: - Callable[[~.ListCertificatesRequest], - Awaitable[~.ListCertificatesResponse]]: - 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_certificates' not in self._stubs: - self._stubs['list_certificates'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificates', - request_serializer=certificate_manager.ListCertificatesRequest.serialize, - response_deserializer=certificate_manager.ListCertificatesResponse.deserialize, - ) - return self._stubs['list_certificates'] - - @property - def get_certificate(self) -> Callable[ - [certificate_manager.GetCertificateRequest], - Awaitable[certificate_manager.Certificate]]: - r"""Return a callable for the get certificate method over gRPC. - - Gets details of a single Certificate. - - Returns: - Callable[[~.GetCertificateRequest], - Awaitable[~.Certificate]]: - 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_certificate' not in self._stubs: - self._stubs['get_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificate', - request_serializer=certificate_manager.GetCertificateRequest.serialize, - response_deserializer=certificate_manager.Certificate.deserialize, - ) - return self._stubs['get_certificate'] - - @property - def create_certificate(self) -> Callable[ - [certificate_manager.CreateCertificateRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create certificate method over gRPC. - - Creates a new Certificate in a given project and - location. - - Returns: - Callable[[~.CreateCertificateRequest], - 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_certificate' not in self._stubs: - self._stubs['create_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificate', - request_serializer=certificate_manager.CreateCertificateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate'] - - @property - def update_certificate(self) -> Callable[ - [certificate_manager.UpdateCertificateRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update certificate method over gRPC. - - Updates a Certificate. - - Returns: - Callable[[~.UpdateCertificateRequest], - 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_certificate' not in self._stubs: - self._stubs['update_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificate', - request_serializer=certificate_manager.UpdateCertificateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate'] - - @property - def delete_certificate(self) -> Callable[ - [certificate_manager.DeleteCertificateRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete certificate method over gRPC. - - Deletes a single Certificate. - - Returns: - Callable[[~.DeleteCertificateRequest], - 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_certificate' not in self._stubs: - self._stubs['delete_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificate', - request_serializer=certificate_manager.DeleteCertificateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_certificate'] - - @property - def list_certificate_maps(self) -> Callable[ - [certificate_manager.ListCertificateMapsRequest], - Awaitable[certificate_manager.ListCertificateMapsResponse]]: - r"""Return a callable for the list certificate maps method over gRPC. - - Lists CertificateMaps in a given project and - location. - - Returns: - Callable[[~.ListCertificateMapsRequest], - Awaitable[~.ListCertificateMapsResponse]]: - 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_certificate_maps' not in self._stubs: - self._stubs['list_certificate_maps'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateMaps', - request_serializer=certificate_manager.ListCertificateMapsRequest.serialize, - response_deserializer=certificate_manager.ListCertificateMapsResponse.deserialize, - ) - return self._stubs['list_certificate_maps'] - - @property - def get_certificate_map(self) -> Callable[ - [certificate_manager.GetCertificateMapRequest], - Awaitable[certificate_manager.CertificateMap]]: - r"""Return a callable for the get certificate map method over gRPC. - - Gets details of a single CertificateMap. - - Returns: - Callable[[~.GetCertificateMapRequest], - Awaitable[~.CertificateMap]]: - 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_certificate_map' not in self._stubs: - self._stubs['get_certificate_map'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateMap', - request_serializer=certificate_manager.GetCertificateMapRequest.serialize, - response_deserializer=certificate_manager.CertificateMap.deserialize, - ) - return self._stubs['get_certificate_map'] - - @property - def create_certificate_map(self) -> Callable[ - [certificate_manager.CreateCertificateMapRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create certificate map method over gRPC. - - Creates a new CertificateMap in a given project and - location. - - Returns: - Callable[[~.CreateCertificateMapRequest], - 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_certificate_map' not in self._stubs: - self._stubs['create_certificate_map'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateMap', - request_serializer=certificate_manager.CreateCertificateMapRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate_map'] - - @property - def update_certificate_map(self) -> Callable[ - [certificate_manager.UpdateCertificateMapRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update certificate map method over gRPC. - - Updates a CertificateMap. - - Returns: - Callable[[~.UpdateCertificateMapRequest], - 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_certificate_map' not in self._stubs: - self._stubs['update_certificate_map'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificateMap', - request_serializer=certificate_manager.UpdateCertificateMapRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_map'] - - @property - def delete_certificate_map(self) -> Callable[ - [certificate_manager.DeleteCertificateMapRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete certificate map method over gRPC. - - Deletes a single CertificateMap. A Certificate Map - can't be deleted if it contains Certificate Map Entries. - Remove all the entries from the map before calling this - method. - - Returns: - Callable[[~.DeleteCertificateMapRequest], - 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_certificate_map' not in self._stubs: - self._stubs['delete_certificate_map'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateMap', - request_serializer=certificate_manager.DeleteCertificateMapRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_certificate_map'] - - @property - def list_certificate_map_entries(self) -> Callable[ - [certificate_manager.ListCertificateMapEntriesRequest], - Awaitable[certificate_manager.ListCertificateMapEntriesResponse]]: - r"""Return a callable for the list certificate map entries method over gRPC. - - Lists CertificateMapEntries in a given project and - location. - - Returns: - Callable[[~.ListCertificateMapEntriesRequest], - Awaitable[~.ListCertificateMapEntriesResponse]]: - 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_certificate_map_entries' not in self._stubs: - self._stubs['list_certificate_map_entries'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateMapEntries', - request_serializer=certificate_manager.ListCertificateMapEntriesRequest.serialize, - response_deserializer=certificate_manager.ListCertificateMapEntriesResponse.deserialize, - ) - return self._stubs['list_certificate_map_entries'] - - @property - def get_certificate_map_entry(self) -> Callable[ - [certificate_manager.GetCertificateMapEntryRequest], - Awaitable[certificate_manager.CertificateMapEntry]]: - r"""Return a callable for the get certificate map entry method over gRPC. - - Gets details of a single CertificateMapEntry. - - Returns: - Callable[[~.GetCertificateMapEntryRequest], - Awaitable[~.CertificateMapEntry]]: - 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_certificate_map_entry' not in self._stubs: - self._stubs['get_certificate_map_entry'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateMapEntry', - request_serializer=certificate_manager.GetCertificateMapEntryRequest.serialize, - response_deserializer=certificate_manager.CertificateMapEntry.deserialize, - ) - return self._stubs['get_certificate_map_entry'] - - @property - def create_certificate_map_entry(self) -> Callable[ - [certificate_manager.CreateCertificateMapEntryRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create certificate map entry method over gRPC. - - Creates a new CertificateMapEntry in a given project - and location. - - Returns: - Callable[[~.CreateCertificateMapEntryRequest], - 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_certificate_map_entry' not in self._stubs: - self._stubs['create_certificate_map_entry'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateMapEntry', - request_serializer=certificate_manager.CreateCertificateMapEntryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate_map_entry'] - - @property - def update_certificate_map_entry(self) -> Callable[ - [certificate_manager.UpdateCertificateMapEntryRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update certificate map entry method over gRPC. - - Updates a CertificateMapEntry. - - Returns: - Callable[[~.UpdateCertificateMapEntryRequest], - 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_certificate_map_entry' not in self._stubs: - self._stubs['update_certificate_map_entry'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificateMapEntry', - request_serializer=certificate_manager.UpdateCertificateMapEntryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_map_entry'] - - @property - def delete_certificate_map_entry(self) -> Callable[ - [certificate_manager.DeleteCertificateMapEntryRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete certificate map entry method over gRPC. - - Deletes a single CertificateMapEntry. - - Returns: - Callable[[~.DeleteCertificateMapEntryRequest], - 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_certificate_map_entry' not in self._stubs: - self._stubs['delete_certificate_map_entry'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateMapEntry', - request_serializer=certificate_manager.DeleteCertificateMapEntryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_certificate_map_entry'] - - @property - def list_dns_authorizations(self) -> Callable[ - [certificate_manager.ListDnsAuthorizationsRequest], - Awaitable[certificate_manager.ListDnsAuthorizationsResponse]]: - r"""Return a callable for the list dns authorizations method over gRPC. - - Lists DnsAuthorizations in a given project and - location. - - Returns: - Callable[[~.ListDnsAuthorizationsRequest], - Awaitable[~.ListDnsAuthorizationsResponse]]: - 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_dns_authorizations' not in self._stubs: - self._stubs['list_dns_authorizations'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/ListDnsAuthorizations', - request_serializer=certificate_manager.ListDnsAuthorizationsRequest.serialize, - response_deserializer=certificate_manager.ListDnsAuthorizationsResponse.deserialize, - ) - return self._stubs['list_dns_authorizations'] - - @property - def get_dns_authorization(self) -> Callable[ - [certificate_manager.GetDnsAuthorizationRequest], - Awaitable[certificate_manager.DnsAuthorization]]: - r"""Return a callable for the get dns authorization method over gRPC. - - Gets details of a single DnsAuthorization. - - Returns: - Callable[[~.GetDnsAuthorizationRequest], - Awaitable[~.DnsAuthorization]]: - 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_dns_authorization' not in self._stubs: - self._stubs['get_dns_authorization'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/GetDnsAuthorization', - request_serializer=certificate_manager.GetDnsAuthorizationRequest.serialize, - response_deserializer=certificate_manager.DnsAuthorization.deserialize, - ) - return self._stubs['get_dns_authorization'] - - @property - def create_dns_authorization(self) -> Callable[ - [certificate_manager.CreateDnsAuthorizationRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create dns authorization method over gRPC. - - Creates a new DnsAuthorization in a given project and - location. - - Returns: - Callable[[~.CreateDnsAuthorizationRequest], - 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_dns_authorization' not in self._stubs: - self._stubs['create_dns_authorization'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/CreateDnsAuthorization', - request_serializer=certificate_manager.CreateDnsAuthorizationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_dns_authorization'] - - @property - def update_dns_authorization(self) -> Callable[ - [certificate_manager.UpdateDnsAuthorizationRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update dns authorization method over gRPC. - - Updates a DnsAuthorization. - - Returns: - Callable[[~.UpdateDnsAuthorizationRequest], - 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_dns_authorization' not in self._stubs: - self._stubs['update_dns_authorization'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/UpdateDnsAuthorization', - request_serializer=certificate_manager.UpdateDnsAuthorizationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_dns_authorization'] - - @property - def delete_dns_authorization(self) -> Callable[ - [certificate_manager.DeleteDnsAuthorizationRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete dns authorization method over gRPC. - - Deletes a single DnsAuthorization. - - Returns: - Callable[[~.DeleteDnsAuthorizationRequest], - 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_dns_authorization' not in self._stubs: - self._stubs['delete_dns_authorization'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/DeleteDnsAuthorization', - request_serializer=certificate_manager.DeleteDnsAuthorizationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_dns_authorization'] - - @property - def list_certificate_issuance_configs(self) -> Callable[ - [certificate_issuance_config.ListCertificateIssuanceConfigsRequest], - Awaitable[certificate_issuance_config.ListCertificateIssuanceConfigsResponse]]: - r"""Return a callable for the list certificate issuance - configs method over gRPC. - - Lists CertificateIssuanceConfigs in a given project - and location. - - Returns: - Callable[[~.ListCertificateIssuanceConfigsRequest], - Awaitable[~.ListCertificateIssuanceConfigsResponse]]: - 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_certificate_issuance_configs' not in self._stubs: - self._stubs['list_certificate_issuance_configs'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateIssuanceConfigs', - request_serializer=certificate_issuance_config.ListCertificateIssuanceConfigsRequest.serialize, - response_deserializer=certificate_issuance_config.ListCertificateIssuanceConfigsResponse.deserialize, - ) - return self._stubs['list_certificate_issuance_configs'] - - @property - def get_certificate_issuance_config(self) -> Callable[ - [certificate_issuance_config.GetCertificateIssuanceConfigRequest], - Awaitable[certificate_issuance_config.CertificateIssuanceConfig]]: - r"""Return a callable for the get certificate issuance - config method over gRPC. - - Gets details of a single CertificateIssuanceConfig. - - Returns: - Callable[[~.GetCertificateIssuanceConfigRequest], - Awaitable[~.CertificateIssuanceConfig]]: - 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_certificate_issuance_config' not in self._stubs: - self._stubs['get_certificate_issuance_config'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateIssuanceConfig', - request_serializer=certificate_issuance_config.GetCertificateIssuanceConfigRequest.serialize, - response_deserializer=certificate_issuance_config.CertificateIssuanceConfig.deserialize, - ) - return self._stubs['get_certificate_issuance_config'] - - @property - def create_certificate_issuance_config(self) -> Callable[ - [gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create certificate issuance - config method over gRPC. - - Creates a new CertificateIssuanceConfig in a given - project and location. - - Returns: - Callable[[~.CreateCertificateIssuanceConfigRequest], - 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_certificate_issuance_config' not in self._stubs: - self._stubs['create_certificate_issuance_config'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateIssuanceConfig', - request_serializer=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate_issuance_config'] - - @property - def delete_certificate_issuance_config(self) -> Callable[ - [certificate_issuance_config.DeleteCertificateIssuanceConfigRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete certificate issuance - config method over gRPC. - - Deletes a single CertificateIssuanceConfig. - - Returns: - Callable[[~.DeleteCertificateIssuanceConfigRequest], - 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_certificate_issuance_config' not in self._stubs: - self._stubs['delete_certificate_issuance_config'] = self.grpc_channel.unary_unary( - '/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateIssuanceConfig', - request_serializer=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_certificate_issuance_config'] - - def close(self): - return self.grpc_channel.close() - - @property - def delete_operation( - self, - ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: - r"""Return a callable for the delete_operation method over gRPC. - """ - # 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_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/DeleteOperation", - request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, - response_deserializer=None, - ) - return self._stubs["delete_operation"] - - @property - def cancel_operation( - self, - ) -> Callable[[operations_pb2.CancelOperationRequest], None]: - r"""Return a callable for the cancel_operation method over gRPC. - """ - # 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 "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/CancelOperation", - request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, - response_deserializer=None, - ) - return self._stubs["cancel_operation"] - - @property - def get_operation( - self, - ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: - r"""Return a callable for the get_operation method over gRPC. - """ - # 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_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/GetOperation", - request_serializer=operations_pb2.GetOperationRequest.SerializeToString, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["get_operation"] - - @property - def list_operations( - self, - ) -> Callable[[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse]: - r"""Return a callable for the list_operations method over gRPC. - """ - # 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_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/ListOperations", - request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, - response_deserializer=operations_pb2.ListOperationsResponse.FromString, - ) - return self._stubs["list_operations"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations method over gRPC. - """ - # 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations method over gRPC. - """ - # 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'CertificateManagerGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/__init__.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/__init__.py deleted file mode 100644 index 5a613a2..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/__init__.py +++ /dev/null @@ -1,94 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from .certificate_issuance_config import ( - CertificateIssuanceConfig, - CreateCertificateIssuanceConfigRequest, - DeleteCertificateIssuanceConfigRequest, - GetCertificateIssuanceConfigRequest, - ListCertificateIssuanceConfigsRequest, - ListCertificateIssuanceConfigsResponse, -) -from .certificate_manager import ( - Certificate, - CertificateMap, - CertificateMapEntry, - CreateCertificateMapEntryRequest, - CreateCertificateMapRequest, - CreateCertificateRequest, - CreateDnsAuthorizationRequest, - DeleteCertificateMapEntryRequest, - DeleteCertificateMapRequest, - DeleteCertificateRequest, - DeleteDnsAuthorizationRequest, - DnsAuthorization, - GetCertificateMapEntryRequest, - GetCertificateMapRequest, - GetCertificateRequest, - GetDnsAuthorizationRequest, - ListCertificateMapEntriesRequest, - ListCertificateMapEntriesResponse, - ListCertificateMapsRequest, - ListCertificateMapsResponse, - ListCertificatesRequest, - ListCertificatesResponse, - ListDnsAuthorizationsRequest, - ListDnsAuthorizationsResponse, - OperationMetadata, - UpdateCertificateMapEntryRequest, - UpdateCertificateMapRequest, - UpdateCertificateRequest, - UpdateDnsAuthorizationRequest, - ServingState, -) - -__all__ = ( - 'CertificateIssuanceConfig', - 'CreateCertificateIssuanceConfigRequest', - 'DeleteCertificateIssuanceConfigRequest', - 'GetCertificateIssuanceConfigRequest', - 'ListCertificateIssuanceConfigsRequest', - 'ListCertificateIssuanceConfigsResponse', - 'Certificate', - 'CertificateMap', - 'CertificateMapEntry', - 'CreateCertificateMapEntryRequest', - 'CreateCertificateMapRequest', - 'CreateCertificateRequest', - 'CreateDnsAuthorizationRequest', - 'DeleteCertificateMapEntryRequest', - 'DeleteCertificateMapRequest', - 'DeleteCertificateRequest', - 'DeleteDnsAuthorizationRequest', - 'DnsAuthorization', - 'GetCertificateMapEntryRequest', - 'GetCertificateMapRequest', - 'GetCertificateRequest', - 'GetDnsAuthorizationRequest', - 'ListCertificateMapEntriesRequest', - 'ListCertificateMapEntriesResponse', - 'ListCertificateMapsRequest', - 'ListCertificateMapsResponse', - 'ListCertificatesRequest', - 'ListCertificatesResponse', - 'ListDnsAuthorizationsRequest', - 'ListDnsAuthorizationsResponse', - 'OperationMetadata', - 'UpdateCertificateMapEntryRequest', - 'UpdateCertificateMapRequest', - 'UpdateCertificateRequest', - 'UpdateDnsAuthorizationRequest', - 'ServingState', -) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_issuance_config.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_issuance_config.py deleted file mode 100644 index bdec673..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_issuance_config.py +++ /dev/null @@ -1,318 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.certificatemanager.v1', - manifest={ - 'ListCertificateIssuanceConfigsRequest', - 'ListCertificateIssuanceConfigsResponse', - 'GetCertificateIssuanceConfigRequest', - 'CreateCertificateIssuanceConfigRequest', - 'DeleteCertificateIssuanceConfigRequest', - 'CertificateIssuanceConfig', - }, -) - - -class ListCertificateIssuanceConfigsRequest(proto.Message): - r"""Request for the ``ListCertificateIssuanceConfigs`` method. - - Attributes: - parent (str): - Required. The project and location from which the - certificate should be listed, specified in the format - ``projects/*/locations/*``. - page_size (int): - Maximum number of certificate configs to - return per call. - page_token (str): - The value returned by the last - ``ListCertificateIssuanceConfigsResponse``. Indicates that - this is a continuation of a prior - ``ListCertificateIssuanceConfigs`` call, and that the system - should return the next page of data. - filter (str): - Filter expression to restrict the - Certificates Configs returned. - order_by (str): - A list of Certificate Config field names used - to specify the order of the returned results. - The default sorting order is ascending. To - specify descending order for a field, add a - suffix " desc". - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCertificateIssuanceConfigsResponse(proto.Message): - r"""Response for the ``ListCertificateIssuanceConfigs`` method. - - Attributes: - certificate_issuance_configs (MutableSequence[google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig]): - A list of certificate configs for the parent - resource. - next_page_token (str): - If there might be more results than those appearing in this - response, then ``next_page_token`` is included. To get the - next set of results, call this method again using the value - of ``next_page_token`` as ``page_token``. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - certificate_issuance_configs: MutableSequence['CertificateIssuanceConfig'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='CertificateIssuanceConfig', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetCertificateIssuanceConfigRequest(proto.Message): - r"""Request for the ``GetCertificateIssuanceConfig`` method. - - Attributes: - name (str): - Required. A name of the certificate issuance config to - describe. Must be in the format - ``projects/*/locations/*/certificateIssuanceConfigs/*``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateCertificateIssuanceConfigRequest(proto.Message): - r"""Request for the ``CreateCertificateIssuanceConfig`` method. - - Attributes: - parent (str): - Required. The parent resource of the certificate issuance - config. Must be in the format ``projects/*/locations/*``. - certificate_issuance_config_id (str): - Required. A user-provided name of the - certificate config. - certificate_issuance_config (google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig): - Required. A definition of the certificate - issuance config to create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - certificate_issuance_config_id: str = proto.Field( - proto.STRING, - number=2, - ) - certificate_issuance_config: 'CertificateIssuanceConfig' = proto.Field( - proto.MESSAGE, - number=3, - message='CertificateIssuanceConfig', - ) - - -class DeleteCertificateIssuanceConfigRequest(proto.Message): - r"""Request for the ``DeleteCertificateIssuanceConfig`` method. - - Attributes: - name (str): - Required. A name of the certificate issuance config to - delete. Must be in the format - ``projects/*/locations/*/certificateIssuanceConfigs/*``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CertificateIssuanceConfig(proto.Message): - r"""CertificateIssuanceConfig specifies how to issue and manage a - certificate. - - Attributes: - name (str): - A user-defined name of the certificate issuance config. - CertificateIssuanceConfig names must be unique globally and - match pattern - ``projects/*/locations/*/certificateIssuanceConfigs/*``. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The creation timestamp of a - CertificateIssuanceConfig. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The last update timestamp of a - CertificateIssuanceConfig. - labels (MutableMapping[str, str]): - Set of labels associated with a - CertificateIssuanceConfig. - description (str): - One or more paragraphs of text description of - a CertificateIssuanceConfig. - certificate_authority_config (google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig.CertificateAuthorityConfig): - Required. The CA that issues the workload - certificate. It includes the CA address, type, - authentication to CA service, etc. - lifetime (google.protobuf.duration_pb2.Duration): - Required. Workload certificate lifetime - requested. - rotation_window_percentage (int): - Required. Specifies the percentage of elapsed - time of the certificate lifetime to wait before - renewing the certificate. Must be a number - between 1-99, inclusive. - key_algorithm (google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig.KeyAlgorithm): - Required. The key algorithm to use when - generating the private key. - """ - class KeyAlgorithm(proto.Enum): - r"""The type of keypair to generate. - - Values: - KEY_ALGORITHM_UNSPECIFIED (0): - Unspecified key algorithm. - RSA_2048 (1): - Specifies RSA with a 2048-bit modulus. - ECDSA_P256 (4): - Specifies ECDSA with curve P256. - """ - KEY_ALGORITHM_UNSPECIFIED = 0 - RSA_2048 = 1 - ECDSA_P256 = 4 - - class CertificateAuthorityConfig(proto.Message): - r"""The CA that issues the workload certificate. It includes CA - address, type, authentication to CA service, etc. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - certificate_authority_service_config (google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig.CertificateAuthorityConfig.CertificateAuthorityServiceConfig): - Defines a CertificateAuthorityServiceConfig. - - This field is a member of `oneof`_ ``kind``. - """ - - class CertificateAuthorityServiceConfig(proto.Message): - r"""Contains information required to contact CA service. - - Attributes: - ca_pool (str): - Required. A CA pool resource used to issue a certificate. - The CA pool string has a relative resource path following - the form - "projects/{project}/locations/{location}/caPools/{ca_pool}". - """ - - ca_pool: str = proto.Field( - proto.STRING, - number=1, - ) - - certificate_authority_service_config: 'CertificateIssuanceConfig.CertificateAuthorityConfig.CertificateAuthorityServiceConfig' = proto.Field( - proto.MESSAGE, - number=1, - oneof='kind', - message='CertificateIssuanceConfig.CertificateAuthorityConfig.CertificateAuthorityServiceConfig', - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - description: str = proto.Field( - proto.STRING, - number=5, - ) - certificate_authority_config: CertificateAuthorityConfig = proto.Field( - proto.MESSAGE, - number=6, - message=CertificateAuthorityConfig, - ) - lifetime: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=7, - message=duration_pb2.Duration, - ) - rotation_window_percentage: int = proto.Field( - proto.INT32, - number=8, - ) - key_algorithm: KeyAlgorithm = proto.Field( - proto.ENUM, - number=9, - enum=KeyAlgorithm, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_manager.py b/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_manager.py deleted file mode 100644 index f03dd6f..0000000 --- a/owl-bot-staging/v1/google/cloud/certificate_manager_v1/types/certificate_manager.py +++ /dev/null @@ -1,1514 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import MutableMapping, MutableSequence - -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.certificatemanager.v1', - manifest={ - 'ServingState', - 'ListCertificatesRequest', - 'ListCertificatesResponse', - 'GetCertificateRequest', - 'CreateCertificateRequest', - 'UpdateCertificateRequest', - 'DeleteCertificateRequest', - 'ListCertificateMapsRequest', - 'ListCertificateMapsResponse', - 'GetCertificateMapRequest', - 'CreateCertificateMapRequest', - 'UpdateCertificateMapRequest', - 'DeleteCertificateMapRequest', - 'ListCertificateMapEntriesRequest', - 'ListCertificateMapEntriesResponse', - 'GetCertificateMapEntryRequest', - 'CreateCertificateMapEntryRequest', - 'UpdateCertificateMapEntryRequest', - 'DeleteCertificateMapEntryRequest', - 'ListDnsAuthorizationsRequest', - 'ListDnsAuthorizationsResponse', - 'GetDnsAuthorizationRequest', - 'CreateDnsAuthorizationRequest', - 'UpdateDnsAuthorizationRequest', - 'DeleteDnsAuthorizationRequest', - 'OperationMetadata', - 'Certificate', - 'CertificateMap', - 'CertificateMapEntry', - 'DnsAuthorization', - }, -) - - -class ServingState(proto.Enum): - r"""Defines set of serving states associated with a resource. - - Values: - SERVING_STATE_UNSPECIFIED (0): - The status is undefined. - ACTIVE (1): - The configuration is serving. - PENDING (2): - Update is in progress. Some frontends may - serve this configuration. - """ - SERVING_STATE_UNSPECIFIED = 0 - ACTIVE = 1 - PENDING = 2 - - -class ListCertificatesRequest(proto.Message): - r"""Request for the ``ListCertificates`` method. - - Attributes: - parent (str): - Required. The project and location from which the - certificate should be listed, specified in the format - ``projects/*/locations/*``. - page_size (int): - Maximum number of certificates to return per - call. - page_token (str): - The value returned by the last ``ListCertificatesResponse``. - Indicates that this is a continuation of a prior - ``ListCertificates`` call, and that the system should return - the next page of data. - filter (str): - Filter expression to restrict the - Certificates returned. - order_by (str): - A list of Certificate field names used to - specify the order of the returned results. The - default sorting order is ascending. To specify - descending order for a field, add a suffix " - desc". - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCertificatesResponse(proto.Message): - r"""Response for the ``ListCertificates`` method. - - Attributes: - certificates (MutableSequence[google.cloud.certificate_manager_v1.types.Certificate]): - A list of certificates for the parent - resource. - next_page_token (str): - If there might be more results than those appearing in this - response, then ``next_page_token`` is included. To get the - next set of results, call this method again using the value - of ``next_page_token`` as ``page_token``. - unreachable (MutableSequence[str]): - A list of locations that could not be - reached. - """ - - @property - def raw_page(self): - return self - - certificates: MutableSequence['Certificate'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Certificate', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetCertificateRequest(proto.Message): - r"""Request for the ``GetCertificate`` method. - - Attributes: - name (str): - Required. A name of the certificate to describe. Must be in - the format ``projects/*/locations/*/certificates/*``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateCertificateRequest(proto.Message): - r"""Request for the ``CreateCertificate`` method. - - Attributes: - parent (str): - Required. The parent resource of the certificate. Must be in - the format ``projects/*/locations/*``. - certificate_id (str): - Required. A user-provided name of the - certificate. - certificate (google.cloud.certificate_manager_v1.types.Certificate): - Required. A definition of the certificate to - create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - certificate_id: str = proto.Field( - proto.STRING, - number=2, - ) - certificate: 'Certificate' = proto.Field( - proto.MESSAGE, - number=3, - message='Certificate', - ) - - -class UpdateCertificateRequest(proto.Message): - r"""Request for the ``UpdateCertificate`` method. - - Attributes: - certificate (google.cloud.certificate_manager_v1.types.Certificate): - Required. A definition of the certificate to - update. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - """ - - certificate: 'Certificate' = proto.Field( - proto.MESSAGE, - number=1, - message='Certificate', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteCertificateRequest(proto.Message): - r"""Request for the ``DeleteCertificate`` method. - - Attributes: - name (str): - Required. A name of the certificate to delete. Must be in - the format ``projects/*/locations/*/certificates/*``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListCertificateMapsRequest(proto.Message): - r"""Request for the ``ListCertificateMaps`` method. - - Attributes: - parent (str): - Required. The project and location from which the - certificate maps should be listed, specified in the format - ``projects/*/locations/*``. - page_size (int): - Maximum number of certificate maps to return - per call. - page_token (str): - The value returned by the last - ``ListCertificateMapsResponse``. Indicates that this is a - continuation of a prior ``ListCertificateMaps`` call, and - that the system should return the next page of data. - filter (str): - Filter expression to restrict the - Certificates Maps returned. - order_by (str): - A list of Certificate Map field names used to - specify the order of the returned results. The - default sorting order is ascending. To specify - descending order for a field, add a suffix " - desc". - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCertificateMapsResponse(proto.Message): - r"""Response for the ``ListCertificateMaps`` method. - - Attributes: - certificate_maps (MutableSequence[google.cloud.certificate_manager_v1.types.CertificateMap]): - A list of certificate maps for the parent - resource. - next_page_token (str): - If there might be more results than those appearing in this - response, then ``next_page_token`` is included. To get the - next set of results, call this method again using the value - of ``next_page_token`` as ``page_token``. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - certificate_maps: MutableSequence['CertificateMap'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='CertificateMap', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetCertificateMapRequest(proto.Message): - r"""Request for the ``GetCertificateMap`` method. - - Attributes: - name (str): - Required. A name of the certificate map to describe. Must be - in the format ``projects/*/locations/*/certificateMaps/*``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateCertificateMapRequest(proto.Message): - r"""Request for the ``CreateCertificateMap`` method. - - Attributes: - parent (str): - Required. The parent resource of the certificate map. Must - be in the format ``projects/*/locations/*``. - certificate_map_id (str): - Required. A user-provided name of the - certificate map. - certificate_map (google.cloud.certificate_manager_v1.types.CertificateMap): - Required. A definition of the certificate map - to create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - certificate_map_id: str = proto.Field( - proto.STRING, - number=2, - ) - certificate_map: 'CertificateMap' = proto.Field( - proto.MESSAGE, - number=3, - message='CertificateMap', - ) - - -class UpdateCertificateMapRequest(proto.Message): - r"""Request for the ``UpdateCertificateMap`` method. - - Attributes: - certificate_map (google.cloud.certificate_manager_v1.types.CertificateMap): - Required. A definition of the certificate map - to update. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - """ - - certificate_map: 'CertificateMap' = proto.Field( - proto.MESSAGE, - number=1, - message='CertificateMap', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteCertificateMapRequest(proto.Message): - r"""Request for the ``DeleteCertificateMap`` method. - - Attributes: - name (str): - Required. A name of the certificate map to delete. Must be - in the format ``projects/*/locations/*/certificateMaps/*``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListCertificateMapEntriesRequest(proto.Message): - r"""Request for the ``ListCertificateMapEntries`` method. - - Attributes: - parent (str): - Required. The project, location and certificate map from - which the certificate map entries should be listed, - specified in the format - ``projects/*/locations/*/certificateMaps/*``. - page_size (int): - Maximum number of certificate map entries to - return. The service may return fewer than this - value. If unspecified, at most 50 certificate - map entries will be returned. The maximum value - is 1000; values above 1000 will be coerced to - 1000. - page_token (str): - The value returned by the last - ``ListCertificateMapEntriesResponse``. Indicates that this - is a continuation of a prior ``ListCertificateMapEntries`` - call, and that the system should return the next page of - data. - filter (str): - Filter expression to restrict the returned - Certificate Map Entries. - order_by (str): - A list of Certificate Map Entry field names - used to specify the order of the returned - results. The default sorting order is ascending. - To specify descending order for a field, add a - suffix " desc". - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCertificateMapEntriesResponse(proto.Message): - r"""Response for the ``ListCertificateMapEntries`` method. - - Attributes: - certificate_map_entries (MutableSequence[google.cloud.certificate_manager_v1.types.CertificateMapEntry]): - A list of certificate map entries for the - parent resource. - next_page_token (str): - If there might be more results than those appearing in this - response, then ``next_page_token`` is included. To get the - next set of results, call this method again using the value - of ``next_page_token`` as ``page_token``. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - certificate_map_entries: MutableSequence['CertificateMapEntry'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='CertificateMapEntry', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetCertificateMapEntryRequest(proto.Message): - r"""Request for the ``GetCertificateMapEntry`` method. - - Attributes: - name (str): - Required. A name of the certificate map entry to describe. - Must be in the format - ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateCertificateMapEntryRequest(proto.Message): - r"""Request for the ``CreateCertificateMapEntry`` method. - - Attributes: - parent (str): - Required. The parent resource of the certificate map entry. - Must be in the format - ``projects/*/locations/*/certificateMaps/*``. - certificate_map_entry_id (str): - Required. A user-provided name of the - certificate map entry. - certificate_map_entry (google.cloud.certificate_manager_v1.types.CertificateMapEntry): - Required. A definition of the certificate map - entry to create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - certificate_map_entry_id: str = proto.Field( - proto.STRING, - number=2, - ) - certificate_map_entry: 'CertificateMapEntry' = proto.Field( - proto.MESSAGE, - number=3, - message='CertificateMapEntry', - ) - - -class UpdateCertificateMapEntryRequest(proto.Message): - r"""Request for the ``UpdateCertificateMapEntry`` method. - - Attributes: - certificate_map_entry (google.cloud.certificate_manager_v1.types.CertificateMapEntry): - Required. A definition of the certificate map - entry to create map entry. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - """ - - certificate_map_entry: 'CertificateMapEntry' = proto.Field( - proto.MESSAGE, - number=1, - message='CertificateMapEntry', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteCertificateMapEntryRequest(proto.Message): - r"""Request for the ``DeleteCertificateMapEntry`` method. - - Attributes: - name (str): - Required. A name of the certificate map entry to delete. - Must be in the format - ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListDnsAuthorizationsRequest(proto.Message): - r"""Request for the ``ListDnsAuthorizations`` method. - - Attributes: - parent (str): - Required. The project and location from which the dns - authorizations should be listed, specified in the format - ``projects/*/locations/*``. - page_size (int): - Maximum number of dns authorizations to - return per call. - page_token (str): - The value returned by the last - ``ListDnsAuthorizationsResponse``. Indicates that this is a - continuation of a prior ``ListDnsAuthorizations`` call, and - that the system should return the next page of data. - filter (str): - Filter expression to restrict the Dns - Authorizations returned. - order_by (str): - A list of Dns Authorization field names used - to specify the order of the returned results. - The default sorting order is ascending. To - specify descending order for a field, add a - suffix " desc". - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListDnsAuthorizationsResponse(proto.Message): - r"""Response for the ``ListDnsAuthorizations`` method. - - Attributes: - dns_authorizations (MutableSequence[google.cloud.certificate_manager_v1.types.DnsAuthorization]): - A list of dns authorizations for the parent - resource. - next_page_token (str): - If there might be more results than those appearing in this - response, then ``next_page_token`` is included. To get the - next set of results, call this method again using the value - of ``next_page_token`` as ``page_token``. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - dns_authorizations: MutableSequence['DnsAuthorization'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='DnsAuthorization', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetDnsAuthorizationRequest(proto.Message): - r"""Request for the ``GetDnsAuthorization`` method. - - Attributes: - name (str): - Required. A name of the dns authorization to describe. Must - be in the format - ``projects/*/locations/*/dnsAuthorizations/*``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateDnsAuthorizationRequest(proto.Message): - r"""Request for the ``CreateDnsAuthorization`` method. - - Attributes: - parent (str): - Required. The parent resource of the dns authorization. Must - be in the format ``projects/*/locations/*``. - dns_authorization_id (str): - Required. A user-provided name of the dns - authorization. - dns_authorization (google.cloud.certificate_manager_v1.types.DnsAuthorization): - Required. A definition of the dns - authorization to create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - dns_authorization_id: str = proto.Field( - proto.STRING, - number=2, - ) - dns_authorization: 'DnsAuthorization' = proto.Field( - proto.MESSAGE, - number=3, - message='DnsAuthorization', - ) - - -class UpdateDnsAuthorizationRequest(proto.Message): - r"""Request for the ``UpdateDnsAuthorization`` method. - - Attributes: - dns_authorization (google.cloud.certificate_manager_v1.types.DnsAuthorization): - Required. A definition of the dns - authorization to update. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - """ - - dns_authorization: 'DnsAuthorization' = proto.Field( - proto.MESSAGE, - number=1, - message='DnsAuthorization', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteDnsAuthorizationRequest(proto.Message): - r"""Request for the ``DeleteDnsAuthorization`` method. - - Attributes: - name (str): - Required. A name of the dns authorization to delete. Must be - in the format - ``projects/*/locations/*/dnsAuthorizations/*``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class OperationMetadata(proto.Message): - r"""Represents the metadata of the long-running operation. Output - only. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - The time the operation was created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - The time the operation finished running. - target (str): - Server-defined resource path for the target - of the operation. - verb (str): - Name of the verb executed by the operation. - status_message (str): - Human-readable status of the operation, if - any. - requested_cancellation (bool): - 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): - API version used to start the operation. - """ - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - target: str = proto.Field( - proto.STRING, - number=3, - ) - verb: str = proto.Field( - proto.STRING, - number=4, - ) - status_message: str = proto.Field( - proto.STRING, - number=5, - ) - requested_cancellation: bool = proto.Field( - proto.BOOL, - number=6, - ) - api_version: str = proto.Field( - proto.STRING, - number=7, - ) - - -class Certificate(proto.Message): - r"""Defines TLS certificate. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - name (str): - A user-defined name of the certificate. Certificate names - must be unique globally and match pattern - ``projects/*/locations/*/certificates/*``. - description (str): - One or more paragraphs of text description of - a certificate. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The creation timestamp of a - Certificate. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The last update timestamp of a - Certificate. - labels (MutableMapping[str, str]): - Set of labels associated with a Certificate. - self_managed (google.cloud.certificate_manager_v1.types.Certificate.SelfManagedCertificate): - If set, defines data of a self-managed - certificate. - - This field is a member of `oneof`_ ``type``. - managed (google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate): - If set, contains configuration and state of a - managed certificate. - - This field is a member of `oneof`_ ``type``. - san_dnsnames (MutableSequence[str]): - Output only. The list of Subject Alternative - Names of dnsName type defined in the certificate - (see RFC 5280 4.2.1.6). Managed certificates - that haven't been provisioned yet have this - field populated with a value of the - managed.domains field. - pem_certificate (str): - Output only. The PEM-encoded certificate - chain. - expire_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The expiry timestamp of a - Certificate. - scope (google.cloud.certificate_manager_v1.types.Certificate.Scope): - Immutable. The scope of the certificate. - """ - class Scope(proto.Enum): - r"""Certificate scope. - - Values: - DEFAULT (0): - Certificates with default scope are served - from core Google data centers. If unsure, choose - this option. - EDGE_CACHE (1): - Certificates with scope EDGE_CACHE are special-purposed - certificates, served from non-core Google data centers. - """ - DEFAULT = 0 - EDGE_CACHE = 1 - - class SelfManagedCertificate(proto.Message): - r"""Certificate data for a SelfManaged Certificate. - SelfManaged Certificates are uploaded by the user. Updating such - certificates before they expire remains the user's - responsibility. - - Attributes: - pem_certificate (str): - Input only. The PEM-encoded certificate - chain. Leaf certificate comes first, followed by - intermediate ones if any. - pem_private_key (str): - Input only. The PEM-encoded private key of - the leaf certificate. - """ - - pem_certificate: str = proto.Field( - proto.STRING, - number=1, - ) - pem_private_key: str = proto.Field( - proto.STRING, - number=2, - ) - - class ManagedCertificate(proto.Message): - r"""Configuration and state of a Managed Certificate. - Certificate Manager provisions and renews Managed Certificates - automatically, for as long as it's authorized to do so. - - Attributes: - domains (MutableSequence[str]): - Immutable. The domains for which a managed - SSL certificate will be generated. Wildcard - domains are only supported with DNS challenge - resolution. - dns_authorizations (MutableSequence[str]): - Immutable. Authorizations that will be used - for performing domain authorization. - issuance_config (str): - Immutable. The resource name for a - [CertificateIssuanceConfig][google.cloud.certificatemanager.v1.CertificateIssuanceConfig] - used to configure private PKI certificates in the format - ``projects/*/locations/*/certificateIssuanceConfigs/*``. If - this field is not set, the certificates will instead be - publicly signed as documented at - https://cloud.google.com/load-balancing/docs/ssl-certificates/google-managed-certs#caa. - state (google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate.State): - Output only. State of the managed certificate - resource. - provisioning_issue (google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate.ProvisioningIssue): - Output only. Information about issues with - provisioning a Managed Certificate. - authorization_attempt_info (MutableSequence[google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate.AuthorizationAttemptInfo]): - Output only. Detailed state of the latest - authorization attempt for each domain specified - for managed certificate resource. - """ - class State(proto.Enum): - r"""State of the managed certificate resource. - - Values: - STATE_UNSPECIFIED (0): - State is unspecified. - PROVISIONING (1): - Certificate Manager attempts to provision or renew the - certificate. If the process takes longer than expected, - consult the ``provisioning_issue`` field. - FAILED (2): - Multiple certificate provisioning attempts failed and - Certificate Manager gave up. To try again, delete and create - a new managed Certificate resource. For details see the - ``provisioning_issue`` field. - ACTIVE (3): - The certificate management is working, and a - certificate has been provisioned. - """ - STATE_UNSPECIFIED = 0 - PROVISIONING = 1 - FAILED = 2 - ACTIVE = 3 - - class ProvisioningIssue(proto.Message): - r"""Information about issues with provisioning a Managed - Certificate. - - Attributes: - reason (google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate.ProvisioningIssue.Reason): - Output only. Reason for provisioning - failures. - details (str): - Output only. Human readable explanation about - the issue. Provided to help address the - configuration issues. Not guaranteed to be - stable. For programmatic access use Reason enum. - """ - class Reason(proto.Enum): - r"""Reason for provisioning failures. - - Values: - REASON_UNSPECIFIED (0): - Reason is unspecified. - AUTHORIZATION_ISSUE (1): - Certificate provisioning failed due to an issue with one or - more of the domains on the certificate. For details of which - domains failed, consult the ``authorization_attempt_info`` - field. - RATE_LIMITED (2): - Exceeded Certificate Authority quotas or - internal rate limits of the system. Provisioning - may take longer to complete. - """ - REASON_UNSPECIFIED = 0 - AUTHORIZATION_ISSUE = 1 - RATE_LIMITED = 2 - - reason: 'Certificate.ManagedCertificate.ProvisioningIssue.Reason' = proto.Field( - proto.ENUM, - number=1, - enum='Certificate.ManagedCertificate.ProvisioningIssue.Reason', - ) - details: str = proto.Field( - proto.STRING, - number=2, - ) - - class AuthorizationAttemptInfo(proto.Message): - r"""State of the latest attempt to authorize a domain for - certificate issuance. - - Attributes: - domain (str): - Domain name of the authorization attempt. - state (google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate.AuthorizationAttemptInfo.State): - Output only. State of the domain for managed - certificate issuance. - failure_reason (google.cloud.certificate_manager_v1.types.Certificate.ManagedCertificate.AuthorizationAttemptInfo.FailureReason): - Output only. Reason for failure of the - authorization attempt for the domain. - details (str): - Output only. Human readable explanation for - reaching the state. Provided to help address the - configuration issues. Not guaranteed to be - stable. For programmatic access use - FailureReason enum. - """ - class State(proto.Enum): - r"""State of the domain for managed certificate issuance. - - Values: - STATE_UNSPECIFIED (0): - State is unspecified. - AUTHORIZING (1): - Certificate provisioning for this domain is - under way. GCP will attempt to authorize the - domain. - AUTHORIZED (6): - A managed certificate can be provisioned, no - issues for this domain. - FAILED (7): - Attempt to authorize the domain failed. This prevents the - Managed Certificate from being issued. See - ``failure_reason`` and ``details`` fields for more - information. - """ - STATE_UNSPECIFIED = 0 - AUTHORIZING = 1 - AUTHORIZED = 6 - FAILED = 7 - - class FailureReason(proto.Enum): - r"""Reason for failure of the authorization attempt for the - domain. - - Values: - FAILURE_REASON_UNSPECIFIED (0): - FailureReason is unspecified. - CONFIG (1): - There was a problem with the user's DNS or - load balancer configuration for this domain. - CAA (2): - Certificate issuance forbidden by an explicit - CAA record for the domain or a failure to check - CAA records for the domain. - RATE_LIMITED (3): - Reached a CA or internal rate-limit for the - domain, e.g. for certificates per top-level - private domain. - """ - FAILURE_REASON_UNSPECIFIED = 0 - CONFIG = 1 - CAA = 2 - RATE_LIMITED = 3 - - domain: str = proto.Field( - proto.STRING, - number=1, - ) - state: 'Certificate.ManagedCertificate.AuthorizationAttemptInfo.State' = proto.Field( - proto.ENUM, - number=2, - enum='Certificate.ManagedCertificate.AuthorizationAttemptInfo.State', - ) - failure_reason: 'Certificate.ManagedCertificate.AuthorizationAttemptInfo.FailureReason' = proto.Field( - proto.ENUM, - number=3, - enum='Certificate.ManagedCertificate.AuthorizationAttemptInfo.FailureReason', - ) - details: str = proto.Field( - proto.STRING, - number=4, - ) - - domains: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=1, - ) - dns_authorizations: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=2, - ) - issuance_config: str = proto.Field( - proto.STRING, - number=6, - ) - state: 'Certificate.ManagedCertificate.State' = proto.Field( - proto.ENUM, - number=4, - enum='Certificate.ManagedCertificate.State', - ) - provisioning_issue: 'Certificate.ManagedCertificate.ProvisioningIssue' = proto.Field( - proto.MESSAGE, - number=3, - message='Certificate.ManagedCertificate.ProvisioningIssue', - ) - authorization_attempt_info: MutableSequence['Certificate.ManagedCertificate.AuthorizationAttemptInfo'] = proto.RepeatedField( - proto.MESSAGE, - number=5, - message='Certificate.ManagedCertificate.AuthorizationAttemptInfo', - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - description: str = proto.Field( - proto.STRING, - number=8, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - self_managed: SelfManagedCertificate = proto.Field( - proto.MESSAGE, - number=5, - oneof='type', - message=SelfManagedCertificate, - ) - managed: ManagedCertificate = proto.Field( - proto.MESSAGE, - number=11, - oneof='type', - message=ManagedCertificate, - ) - san_dnsnames: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=6, - ) - pem_certificate: str = proto.Field( - proto.STRING, - number=9, - ) - expire_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - scope: Scope = proto.Field( - proto.ENUM, - number=12, - enum=Scope, - ) - - -class CertificateMap(proto.Message): - r"""Defines a collection of certificate configurations. - - Attributes: - name (str): - A user-defined name of the Certificate Map. Certificate Map - names must be unique globally and match pattern - ``projects/*/locations/*/certificateMaps/*``. - description (str): - One or more paragraphs of text description of - a certificate map. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The creation timestamp of a - Certificate Map. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The update timestamp of a - Certificate Map. - labels (MutableMapping[str, str]): - Set of labels associated with a Certificate - Map. - gclb_targets (MutableSequence[google.cloud.certificate_manager_v1.types.CertificateMap.GclbTarget]): - Output only. A list of GCLB targets that use - this Certificate Map. A Target Proxy is only - present on this list if it's attached to a - Forwarding Rule. - """ - - class GclbTarget(proto.Message): - r"""Describes a Target Proxy that uses this Certificate Map. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - target_https_proxy (str): - Output only. This field returns the resource name in the - following format: - ``//compute.googleapis.com/projects/*/global/targetHttpsProxies/*``. - - This field is a member of `oneof`_ ``target_proxy``. - target_ssl_proxy (str): - Output only. This field returns the resource name in the - following format: - ``//compute.googleapis.com/projects/*/global/targetSslProxies/*``. - - This field is a member of `oneof`_ ``target_proxy``. - ip_configs (MutableSequence[google.cloud.certificate_manager_v1.types.CertificateMap.GclbTarget.IpConfig]): - Output only. IP configurations for this - Target Proxy where the Certificate Map is - serving. - """ - - class IpConfig(proto.Message): - r"""Defines IP configuration where this Certificate Map is - serving. - - Attributes: - ip_address (str): - Output only. An external IP address. - ports (MutableSequence[int]): - Output only. Ports. - """ - - ip_address: str = proto.Field( - proto.STRING, - number=1, - ) - ports: MutableSequence[int] = proto.RepeatedField( - proto.UINT32, - number=3, - ) - - target_https_proxy: str = proto.Field( - proto.STRING, - number=1, - oneof='target_proxy', - ) - target_ssl_proxy: str = proto.Field( - proto.STRING, - number=3, - oneof='target_proxy', - ) - ip_configs: MutableSequence['CertificateMap.GclbTarget.IpConfig'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='CertificateMap.GclbTarget.IpConfig', - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - description: str = proto.Field( - proto.STRING, - number=5, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=3, - ) - gclb_targets: MutableSequence[GclbTarget] = proto.RepeatedField( - proto.MESSAGE, - number=4, - message=GclbTarget, - ) - - -class CertificateMapEntry(proto.Message): - r"""Defines a certificate map entry. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - name (str): - A user-defined name of the Certificate Map Entry. - Certificate Map Entry names must be unique globally and - match pattern - ``projects/*/locations/*/certificateMaps/*/certificateMapEntries/*``. - description (str): - One or more paragraphs of text description of - a certificate map entry. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The creation timestamp of a - Certificate Map Entry. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The update timestamp of a - Certificate Map Entry. - labels (MutableMapping[str, str]): - Set of labels associated with a Certificate - Map Entry. - hostname (str): - A Hostname (FQDN, e.g. ``example.com``) or a wildcard - hostname expression (``*.example.com``) for a set of - hostnames with common suffix. Used as Server Name Indication - (SNI) for selecting a proper certificate. - - This field is a member of `oneof`_ ``match``. - matcher (google.cloud.certificate_manager_v1.types.CertificateMapEntry.Matcher): - A predefined matcher for particular cases, - other than SNI selection. - - This field is a member of `oneof`_ ``match``. - certificates (MutableSequence[str]): - A set of Certificates defines for the given ``hostname``. - There can be defined up to fifteen certificates in each - Certificate Map Entry. Each certificate must match pattern - ``projects/*/locations/*/certificates/*``. - state (google.cloud.certificate_manager_v1.types.ServingState): - Output only. A serving state of this - Certificate Map Entry. - """ - class Matcher(proto.Enum): - r"""Defines predefined cases other than SNI-hostname match when - this configuration should be applied. - - Values: - MATCHER_UNSPECIFIED (0): - A matcher has't been recognized. - PRIMARY (1): - A primary certificate that is served when SNI - wasn't specified in the request or SNI couldn't - be found in the map. - """ - MATCHER_UNSPECIFIED = 0 - PRIMARY = 1 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - description: str = proto.Field( - proto.STRING, - number=9, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - hostname: str = proto.Field( - proto.STRING, - number=5, - oneof='match', - ) - matcher: Matcher = proto.Field( - proto.ENUM, - number=10, - oneof='match', - enum=Matcher, - ) - certificates: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=7, - ) - state: 'ServingState' = proto.Field( - proto.ENUM, - number=8, - enum='ServingState', - ) - - -class DnsAuthorization(proto.Message): - r"""A DnsAuthorization resource describes a way to perform domain - authorization for certificate issuance. - - Attributes: - name (str): - A user-defined name of the dns authorization. - DnsAuthorization names must be unique globally and match - pattern ``projects/*/locations/*/dnsAuthorizations/*``. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The creation timestamp of a - DnsAuthorization. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The last update timestamp of a - DnsAuthorization. - labels (MutableMapping[str, str]): - Set of labels associated with a - DnsAuthorization. - description (str): - One or more paragraphs of text description of - a DnsAuthorization. - domain (str): - Required. Immutable. A domain that is being authorized. A - DnsAuthorization resource covers a single domain and its - wildcard, e.g. authorization for ``example.com`` can be used - to issue certificates for ``example.com`` and - ``*.example.com``. - dns_resource_record (google.cloud.certificate_manager_v1.types.DnsAuthorization.DnsResourceRecord): - Output only. DNS Resource Record that needs - to be added to DNS configuration. - """ - - class DnsResourceRecord(proto.Message): - r"""The structure describing the DNS Resource Record that needs - to be added to DNS configuration for the authorization to be - usable by certificate. - - Attributes: - name (str): - Output only. Fully qualified name of the DNS Resource - Record. e.g. ``_acme-challenge.example.com`` - type_ (str): - Output only. Type of the DNS Resource Record. - Currently always set to "CNAME". - data (str): - Output only. Data of the DNS Resource Record. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - type_: str = proto.Field( - proto.STRING, - number=2, - ) - data: str = proto.Field( - proto.STRING, - number=3, - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - description: str = proto.Field( - proto.STRING, - number=5, - ) - domain: str = proto.Field( - proto.STRING, - number=6, - ) - dns_resource_record: DnsResourceRecord = proto.Field( - proto.MESSAGE, - number=10, - message=DnsResourceRecord, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/mypy.ini b/owl-bot-staging/v1/mypy.ini deleted file mode 100644 index 574c5ae..0000000 --- a/owl-bot-staging/v1/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.7 -namespace_packages = True diff --git a/owl-bot-staging/v1/noxfile.py b/owl-bot-staging/v1/noxfile.py deleted file mode 100644 index 43a96c5..0000000 --- a/owl-bot-staging/v1/noxfile.py +++ /dev/null @@ -1,184 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -ALL_PYTHON = [ - "3.7", - "3.8", - "3.9", - "3.10", - "3.11", -] - -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") - -BLACK_VERSION = "black==22.3.0" -BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"] -DEFAULT_PYTHON_VERSION = "3.11" - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", - "blacken", - "lint", - "lint_setup_py", -] - -@nox.session(python=ALL_PYTHON) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/certificate_manager_v1/', - '--cov=tests/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -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=ALL_PYTHON) -def mypy(session): - """Run the type checker.""" - session.install( - 'mypy', - 'types-requests', - 'types-protobuf' - ) - 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=DEFAULT_PYTHON_VERSION) -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx==4.0.1", "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", ""), - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint(session): - """Run linters. - - Returns a failure if the linters find linting errors or sufficiently - serious code quality issues. - """ - session.install("flake8", BLACK_VERSION) - session.run( - "black", - "--check", - *BLACK_PATHS, - ) - session.run("flake8", "google", "tests", "samples") - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def blacken(session): - """Run black. Format code to uniform standard.""" - session.install(BLACK_VERSION) - session.run( - "black", - *BLACK_PATHS, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint_setup_py(session): - """Verify that setup.py is valid (including RST check).""" - session.install("docutils", "pygments") - session.run("python", "setup.py", "check", "--restructuredtext", "--strict") diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_async.py deleted file mode 100644 index c612eb1..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_async.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateCertificate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_CreateCertificate_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_create_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.CreateCertificateRequest( - parent="parent_value", - certificate_id="certificate_id_value", - ) - - # Make the request - operation = client.create_certificate(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_CreateCertificate_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_async.py deleted file mode 100644 index f1b3371..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_async.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateCertificateIssuanceConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_CreateCertificateIssuanceConfig_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_create_certificate_issuance_config(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - certificate_issuance_config = certificate_manager_v1.CertificateIssuanceConfig() - certificate_issuance_config.certificate_authority_config.certificate_authority_service_config.ca_pool = "ca_pool_value" - certificate_issuance_config.rotation_window_percentage = 2788 - certificate_issuance_config.key_algorithm = "ECDSA_P256" - - request = certificate_manager_v1.CreateCertificateIssuanceConfigRequest( - parent="parent_value", - certificate_issuance_config_id="certificate_issuance_config_id_value", - certificate_issuance_config=certificate_issuance_config, - ) - - # Make the request - operation = client.create_certificate_issuance_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_CreateCertificateIssuanceConfig_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_sync.py deleted file mode 100644 index 76b5165..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_sync.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateCertificateIssuanceConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_CreateCertificateIssuanceConfig_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_create_certificate_issuance_config(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - certificate_issuance_config = certificate_manager_v1.CertificateIssuanceConfig() - certificate_issuance_config.certificate_authority_config.certificate_authority_service_config.ca_pool = "ca_pool_value" - certificate_issuance_config.rotation_window_percentage = 2788 - certificate_issuance_config.key_algorithm = "ECDSA_P256" - - request = certificate_manager_v1.CreateCertificateIssuanceConfigRequest( - parent="parent_value", - certificate_issuance_config_id="certificate_issuance_config_id_value", - certificate_issuance_config=certificate_issuance_config, - ) - - # Make the request - operation = client.create_certificate_issuance_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_CreateCertificateIssuanceConfig_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_async.py deleted file mode 100644 index 87dc105..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_async.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateCertificateMap -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_CreateCertificateMap_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_create_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.CreateCertificateMapRequest( - parent="parent_value", - certificate_map_id="certificate_map_id_value", - ) - - # Make the request - operation = client.create_certificate_map(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_CreateCertificateMap_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_async.py deleted file mode 100644 index bdc6dd7..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_async.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateCertificateMapEntry -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_CreateCertificateMapEntry_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_create_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - certificate_map_entry = certificate_manager_v1.CertificateMapEntry() - certificate_map_entry.hostname = "hostname_value" - - request = certificate_manager_v1.CreateCertificateMapEntryRequest( - parent="parent_value", - certificate_map_entry_id="certificate_map_entry_id_value", - certificate_map_entry=certificate_map_entry, - ) - - # Make the request - operation = client.create_certificate_map_entry(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_CreateCertificateMapEntry_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_sync.py deleted file mode 100644 index de41ed5..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_sync.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateCertificateMapEntry -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_CreateCertificateMapEntry_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_create_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - certificate_map_entry = certificate_manager_v1.CertificateMapEntry() - certificate_map_entry.hostname = "hostname_value" - - request = certificate_manager_v1.CreateCertificateMapEntryRequest( - parent="parent_value", - certificate_map_entry_id="certificate_map_entry_id_value", - certificate_map_entry=certificate_map_entry, - ) - - # Make the request - operation = client.create_certificate_map_entry(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_CreateCertificateMapEntry_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_sync.py deleted file mode 100644 index bb7888e..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_map_sync.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateCertificateMap -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_CreateCertificateMap_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_create_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.CreateCertificateMapRequest( - parent="parent_value", - certificate_map_id="certificate_map_id_value", - ) - - # Make the request - operation = client.create_certificate_map(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_CreateCertificateMap_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_sync.py deleted file mode 100644 index 1250dd6..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_certificate_sync.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateCertificate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_CreateCertificate_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_create_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.CreateCertificateRequest( - parent="parent_value", - certificate_id="certificate_id_value", - ) - - # Make the request - operation = client.create_certificate(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_CreateCertificate_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_async.py deleted file mode 100644 index 8f9d3f1..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_async.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateDnsAuthorization -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_CreateDnsAuthorization_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_create_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - dns_authorization = certificate_manager_v1.DnsAuthorization() - dns_authorization.domain = "domain_value" - - request = certificate_manager_v1.CreateDnsAuthorizationRequest( - parent="parent_value", - dns_authorization_id="dns_authorization_id_value", - dns_authorization=dns_authorization, - ) - - # Make the request - operation = client.create_dns_authorization(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_CreateDnsAuthorization_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_sync.py deleted file mode 100644 index 8bd5da0..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_create_dns_authorization_sync.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateDnsAuthorization -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_CreateDnsAuthorization_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_create_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - dns_authorization = certificate_manager_v1.DnsAuthorization() - dns_authorization.domain = "domain_value" - - request = certificate_manager_v1.CreateDnsAuthorizationRequest( - parent="parent_value", - dns_authorization_id="dns_authorization_id_value", - dns_authorization=dns_authorization, - ) - - # Make the request - operation = client.create_dns_authorization(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_CreateDnsAuthorization_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_async.py deleted file mode 100644 index b839f86..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteCertificate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificate_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_delete_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificate_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_async.py deleted file mode 100644 index ed57ab2..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteCertificateIssuanceConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificateIssuanceConfig_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_delete_certificate_issuance_config(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateIssuanceConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate_issuance_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificateIssuanceConfig_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_sync.py deleted file mode 100644 index 3353075..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteCertificateIssuanceConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificateIssuanceConfig_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_delete_certificate_issuance_config(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateIssuanceConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate_issuance_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificateIssuanceConfig_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_async.py deleted file mode 100644 index 72a92d3..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteCertificateMap -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificateMap_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_delete_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateMapRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate_map(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificateMap_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_async.py deleted file mode 100644 index 7241c67..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteCertificateMapEntry -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificateMapEntry_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_delete_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateMapEntryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate_map_entry(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificateMapEntry_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_sync.py deleted file mode 100644 index 9263aec..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteCertificateMapEntry -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificateMapEntry_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_delete_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateMapEntryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate_map_entry(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificateMapEntry_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_sync.py deleted file mode 100644 index dcfedde..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_map_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteCertificateMap -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificateMap_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_delete_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateMapRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate_map(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificateMap_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_sync.py deleted file mode 100644 index a290457..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_certificate_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteCertificate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_DeleteCertificate_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_delete_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteCertificateRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_certificate(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_DeleteCertificate_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_async.py deleted file mode 100644 index adea72f..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteDnsAuthorization -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_DeleteDnsAuthorization_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_delete_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteDnsAuthorizationRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_dns_authorization(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_DeleteDnsAuthorization_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_sync.py deleted file mode 100644 index 6ca0b46..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteDnsAuthorization -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_DeleteDnsAuthorization_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_delete_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.DeleteDnsAuthorizationRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_dns_authorization(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_DeleteDnsAuthorization_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_async.py deleted file mode 100644 index 04d5915..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetCertificate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_GetCertificate_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_get_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateRequest( - name="name_value", - ) - - # Make the request - response = await client.get_certificate(request=request) - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_GetCertificate_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_async.py deleted file mode 100644 index ac5d338..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetCertificateIssuanceConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_GetCertificateIssuanceConfig_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_get_certificate_issuance_config(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateIssuanceConfigRequest( - name="name_value", - ) - - # Make the request - response = await client.get_certificate_issuance_config(request=request) - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_GetCertificateIssuanceConfig_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_sync.py deleted file mode 100644 index 5cb7f3d..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetCertificateIssuanceConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_GetCertificateIssuanceConfig_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_get_certificate_issuance_config(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateIssuanceConfigRequest( - name="name_value", - ) - - # Make the request - response = client.get_certificate_issuance_config(request=request) - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_GetCertificateIssuanceConfig_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_async.py deleted file mode 100644 index 7e93854..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetCertificateMap -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_GetCertificateMap_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_get_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateMapRequest( - name="name_value", - ) - - # Make the request - response = await client.get_certificate_map(request=request) - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_GetCertificateMap_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_async.py deleted file mode 100644 index 0642b83..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetCertificateMapEntry -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_GetCertificateMapEntry_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_get_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateMapEntryRequest( - name="name_value", - ) - - # Make the request - response = await client.get_certificate_map_entry(request=request) - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_GetCertificateMapEntry_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_sync.py deleted file mode 100644 index 769b4b0..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetCertificateMapEntry -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_GetCertificateMapEntry_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_get_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateMapEntryRequest( - name="name_value", - ) - - # Make the request - response = client.get_certificate_map_entry(request=request) - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_GetCertificateMapEntry_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_sync.py deleted file mode 100644 index 163a307..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_map_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetCertificateMap -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_GetCertificateMap_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_get_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateMapRequest( - name="name_value", - ) - - # Make the request - response = client.get_certificate_map(request=request) - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_GetCertificateMap_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_sync.py deleted file mode 100644 index d472501..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_certificate_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetCertificate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_GetCertificate_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_get_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetCertificateRequest( - name="name_value", - ) - - # Make the request - response = client.get_certificate(request=request) - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_GetCertificate_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_async.py deleted file mode 100644 index f0848b7..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetDnsAuthorization -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_GetDnsAuthorization_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_get_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetDnsAuthorizationRequest( - name="name_value", - ) - - # Make the request - response = await client.get_dns_authorization(request=request) - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_GetDnsAuthorization_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_sync.py deleted file mode 100644 index 4da758c..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_get_dns_authorization_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetDnsAuthorization -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_GetDnsAuthorization_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_get_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.GetDnsAuthorizationRequest( - name="name_value", - ) - - # Make the request - response = client.get_dns_authorization(request=request) - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_GetDnsAuthorization_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_async.py deleted file mode 100644 index 3790495..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListCertificateIssuanceConfigs -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_ListCertificateIssuanceConfigs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_list_certificate_issuance_configs(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificateIssuanceConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificate_issuance_configs(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_ListCertificateIssuanceConfigs_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_sync.py deleted file mode 100644 index a1cdc39..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListCertificateIssuanceConfigs -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_ListCertificateIssuanceConfigs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_list_certificate_issuance_configs(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificateIssuanceConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificate_issuance_configs(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_ListCertificateIssuanceConfigs_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_async.py deleted file mode 100644 index 99f430c..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListCertificateMapEntries -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_ListCertificateMapEntries_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_list_certificate_map_entries(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificateMapEntriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificate_map_entries(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_ListCertificateMapEntries_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_sync.py deleted file mode 100644 index fab24bd..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListCertificateMapEntries -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_ListCertificateMapEntries_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_list_certificate_map_entries(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificateMapEntriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificate_map_entries(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_ListCertificateMapEntries_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_async.py deleted file mode 100644 index 295c19f..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListCertificateMaps -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_ListCertificateMaps_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_list_certificate_maps(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificateMapsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificate_maps(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_ListCertificateMaps_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_sync.py deleted file mode 100644 index 8c87aa3..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificate_maps_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListCertificateMaps -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_ListCertificateMaps_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_list_certificate_maps(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificateMapsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificate_maps(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_ListCertificateMaps_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_async.py deleted file mode 100644 index 8177eba..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListCertificates -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_ListCertificates_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_list_certificates(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificatesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificates(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_ListCertificates_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_sync.py deleted file mode 100644 index 5b913d3..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_certificates_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListCertificates -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_ListCertificates_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_list_certificates(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListCertificatesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_certificates(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_ListCertificates_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_async.py deleted file mode 100644 index ca6d58a..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListDnsAuthorizations -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_ListDnsAuthorizations_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_list_dns_authorizations(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListDnsAuthorizationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_dns_authorizations(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_ListDnsAuthorizations_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_sync.py deleted file mode 100644 index 479ba53..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListDnsAuthorizations -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_ListDnsAuthorizations_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_list_dns_authorizations(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.ListDnsAuthorizationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_dns_authorizations(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_ListDnsAuthorizations_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_async.py deleted file mode 100644 index 1687d61..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateCertificate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_UpdateCertificate_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_update_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.UpdateCertificateRequest( - ) - - # Make the request - operation = client.update_certificate(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_UpdateCertificate_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_async.py deleted file mode 100644 index ee7727c..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateCertificateMap -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_UpdateCertificateMap_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_update_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - request = certificate_manager_v1.UpdateCertificateMapRequest( - ) - - # Make the request - operation = client.update_certificate_map(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_UpdateCertificateMap_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_async.py deleted file mode 100644 index 05f7389..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_async.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateCertificateMapEntry -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_UpdateCertificateMapEntry_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_update_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - certificate_map_entry = certificate_manager_v1.CertificateMapEntry() - certificate_map_entry.hostname = "hostname_value" - - request = certificate_manager_v1.UpdateCertificateMapEntryRequest( - certificate_map_entry=certificate_map_entry, - ) - - # Make the request - operation = client.update_certificate_map_entry(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_UpdateCertificateMapEntry_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_sync.py deleted file mode 100644 index ec7c65f..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_sync.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateCertificateMapEntry -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_UpdateCertificateMapEntry_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_update_certificate_map_entry(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - certificate_map_entry = certificate_manager_v1.CertificateMapEntry() - certificate_map_entry.hostname = "hostname_value" - - request = certificate_manager_v1.UpdateCertificateMapEntryRequest( - certificate_map_entry=certificate_map_entry, - ) - - # Make the request - operation = client.update_certificate_map_entry(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_UpdateCertificateMapEntry_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_sync.py deleted file mode 100644 index 7c89104..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_map_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateCertificateMap -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_UpdateCertificateMap_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_update_certificate_map(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.UpdateCertificateMapRequest( - ) - - # Make the request - operation = client.update_certificate_map(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_UpdateCertificateMap_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_sync.py deleted file mode 100644 index 4d399ba..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_certificate_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateCertificate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_UpdateCertificate_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_update_certificate(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - request = certificate_manager_v1.UpdateCertificateRequest( - ) - - # Make the request - operation = client.update_certificate(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_UpdateCertificate_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_async.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_async.py deleted file mode 100644 index 7764a3b..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_async.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateDnsAuthorization -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_UpdateDnsAuthorization_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -async def sample_update_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerAsyncClient() - - # Initialize request argument(s) - dns_authorization = certificate_manager_v1.DnsAuthorization() - dns_authorization.domain = "domain_value" - - request = certificate_manager_v1.UpdateDnsAuthorizationRequest( - dns_authorization=dns_authorization, - ) - - # Make the request - operation = client.update_dns_authorization(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_UpdateDnsAuthorization_async] diff --git a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_sync.py b/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_sync.py deleted file mode 100644 index d4750c1..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/certificatemanager_v1_generated_certificate_manager_update_dns_authorization_sync.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateDnsAuthorization -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-certificate-manager - - -# [START certificatemanager_v1_generated_CertificateManager_UpdateDnsAuthorization_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import certificate_manager_v1 - - -def sample_update_dns_authorization(): - # Create a client - client = certificate_manager_v1.CertificateManagerClient() - - # Initialize request argument(s) - dns_authorization = certificate_manager_v1.DnsAuthorization() - dns_authorization.domain = "domain_value" - - request = certificate_manager_v1.UpdateDnsAuthorizationRequest( - dns_authorization=dns_authorization, - ) - - # Make the request - operation = client.update_dns_authorization(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END certificatemanager_v1_generated_CertificateManager_UpdateDnsAuthorization_sync] diff --git a/owl-bot-staging/v1/samples/generated_samples/snippet_metadata_google.cloud.certificatemanager.v1.json b/owl-bot-staging/v1/samples/generated_samples/snippet_metadata_google.cloud.certificatemanager.v1.json deleted file mode 100644 index 8721c43..0000000 --- a/owl-bot-staging/v1/samples/generated_samples/snippet_metadata_google.cloud.certificatemanager.v1.json +++ /dev/null @@ -1,3991 +0,0 @@ -{ - "clientLibrary": { - "apis": [ - { - "id": "google.cloud.certificatemanager.v1", - "version": "v1" - } - ], - "language": "PYTHON", - "name": "google-cloud-certificate-manager", - "version": "0.1.0" - }, - "snippets": [ - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.create_certificate_issuance_config", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificateIssuanceConfig", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "CreateCertificateIssuanceConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.CreateCertificateIssuanceConfigRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "certificate_issuance_config", - "type": "google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig" - }, - { - "name": "certificate_issuance_config_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_certificate_issuance_config" - }, - "description": "Sample for CreateCertificateIssuanceConfig", - "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificateIssuanceConfig_async", - "segments": [ - { - "end": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.create_certificate_issuance_config", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificateIssuanceConfig", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "CreateCertificateIssuanceConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.CreateCertificateIssuanceConfigRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "certificate_issuance_config", - "type": "google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig" - }, - { - "name": "certificate_issuance_config_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_certificate_issuance_config" - }, - "description": "Sample for CreateCertificateIssuanceConfig", - "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificateIssuanceConfig_sync", - "segments": [ - { - "end": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_issuance_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.create_certificate_map_entry", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificateMapEntry", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "CreateCertificateMapEntry" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.CreateCertificateMapEntryRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "certificate_map_entry", - "type": "google.cloud.certificate_manager_v1.types.CertificateMapEntry" - }, - { - "name": "certificate_map_entry_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_certificate_map_entry" - }, - "description": "Sample for CreateCertificateMapEntry", - "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificateMapEntry_async", - "segments": [ - { - "end": 60, - "start": 27, - "type": "FULL" - }, - { - "end": 60, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 50, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 57, - "start": 51, - "type": "REQUEST_EXECUTION" - }, - { - "end": 61, - "start": 58, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.create_certificate_map_entry", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificateMapEntry", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "CreateCertificateMapEntry" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.CreateCertificateMapEntryRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "certificate_map_entry", - "type": "google.cloud.certificate_manager_v1.types.CertificateMapEntry" - }, - { - "name": "certificate_map_entry_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_certificate_map_entry" - }, - "description": "Sample for CreateCertificateMapEntry", - "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificateMapEntry_sync", - "segments": [ - { - "end": 60, - "start": 27, - "type": "FULL" - }, - { - "end": 60, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 50, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 57, - "start": 51, - "type": "REQUEST_EXECUTION" - }, - { - "end": 61, - "start": 58, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_entry_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.create_certificate_map", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificateMap", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "CreateCertificateMap" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.CreateCertificateMapRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "certificate_map", - "type": "google.cloud.certificate_manager_v1.types.CertificateMap" - }, - { - "name": "certificate_map_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_certificate_map" - }, - "description": "Sample for CreateCertificateMap", - "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificateMap_async", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.create_certificate_map", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificateMap", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "CreateCertificateMap" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.CreateCertificateMapRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "certificate_map", - "type": "google.cloud.certificate_manager_v1.types.CertificateMap" - }, - { - "name": "certificate_map_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_certificate_map" - }, - "description": "Sample for CreateCertificateMap", - "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificateMap_sync", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_map_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.create_certificate", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificate", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "CreateCertificate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.CreateCertificateRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "certificate", - "type": "google.cloud.certificate_manager_v1.types.Certificate" - }, - { - "name": "certificate_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_certificate" - }, - "description": "Sample for CreateCertificate", - "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificate_async", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.create_certificate", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateCertificate", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "CreateCertificate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.CreateCertificateRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "certificate", - "type": "google.cloud.certificate_manager_v1.types.Certificate" - }, - { - "name": "certificate_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_certificate" - }, - "description": "Sample for CreateCertificate", - "file": "certificatemanager_v1_generated_certificate_manager_create_certificate_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateCertificate_sync", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_create_certificate_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.create_dns_authorization", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateDnsAuthorization", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "CreateDnsAuthorization" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.CreateDnsAuthorizationRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "dns_authorization", - "type": "google.cloud.certificate_manager_v1.types.DnsAuthorization" - }, - { - "name": "dns_authorization_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_dns_authorization" - }, - "description": "Sample for CreateDnsAuthorization", - "file": "certificatemanager_v1_generated_certificate_manager_create_dns_authorization_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateDnsAuthorization_async", - "segments": [ - { - "end": 60, - "start": 27, - "type": "FULL" - }, - { - "end": 60, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 50, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 57, - "start": 51, - "type": "REQUEST_EXECUTION" - }, - { - "end": 61, - "start": 58, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_create_dns_authorization_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.create_dns_authorization", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.CreateDnsAuthorization", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "CreateDnsAuthorization" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.CreateDnsAuthorizationRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "dns_authorization", - "type": "google.cloud.certificate_manager_v1.types.DnsAuthorization" - }, - { - "name": "dns_authorization_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_dns_authorization" - }, - "description": "Sample for CreateDnsAuthorization", - "file": "certificatemanager_v1_generated_certificate_manager_create_dns_authorization_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_CreateDnsAuthorization_sync", - "segments": [ - { - "end": 60, - "start": 27, - "type": "FULL" - }, - { - "end": 60, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 50, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 57, - "start": 51, - "type": "REQUEST_EXECUTION" - }, - { - "end": 61, - "start": 58, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_create_dns_authorization_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.delete_certificate_issuance_config", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificateIssuanceConfig", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "DeleteCertificateIssuanceConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateIssuanceConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_certificate_issuance_config" - }, - "description": "Sample for DeleteCertificateIssuanceConfig", - "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificateIssuanceConfig_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.delete_certificate_issuance_config", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificateIssuanceConfig", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "DeleteCertificateIssuanceConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateIssuanceConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_certificate_issuance_config" - }, - "description": "Sample for DeleteCertificateIssuanceConfig", - "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificateIssuanceConfig_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_issuance_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.delete_certificate_map_entry", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificateMapEntry", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "DeleteCertificateMapEntry" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateMapEntryRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_certificate_map_entry" - }, - "description": "Sample for DeleteCertificateMapEntry", - "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificateMapEntry_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.delete_certificate_map_entry", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificateMapEntry", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "DeleteCertificateMapEntry" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateMapEntryRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_certificate_map_entry" - }, - "description": "Sample for DeleteCertificateMapEntry", - "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificateMapEntry_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_entry_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.delete_certificate_map", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificateMap", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "DeleteCertificateMap" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateMapRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_certificate_map" - }, - "description": "Sample for DeleteCertificateMap", - "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificateMap_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.delete_certificate_map", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificateMap", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "DeleteCertificateMap" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateMapRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_certificate_map" - }, - "description": "Sample for DeleteCertificateMap", - "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificateMap_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_map_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.delete_certificate", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificate", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "DeleteCertificate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_certificate" - }, - "description": "Sample for DeleteCertificate", - "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificate_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.delete_certificate", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteCertificate", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "DeleteCertificate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.DeleteCertificateRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_certificate" - }, - "description": "Sample for DeleteCertificate", - "file": "certificatemanager_v1_generated_certificate_manager_delete_certificate_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteCertificate_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_delete_certificate_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.delete_dns_authorization", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteDnsAuthorization", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "DeleteDnsAuthorization" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.DeleteDnsAuthorizationRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_dns_authorization" - }, - "description": "Sample for DeleteDnsAuthorization", - "file": "certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteDnsAuthorization_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.delete_dns_authorization", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.DeleteDnsAuthorization", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "DeleteDnsAuthorization" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.DeleteDnsAuthorizationRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_dns_authorization" - }, - "description": "Sample for DeleteDnsAuthorization", - "file": "certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_DeleteDnsAuthorization_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_delete_dns_authorization_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.get_certificate_issuance_config", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificateIssuanceConfig", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "GetCertificateIssuanceConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.GetCertificateIssuanceConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig", - "shortName": "get_certificate_issuance_config" - }, - "description": "Sample for GetCertificateIssuanceConfig", - "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificateIssuanceConfig_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.get_certificate_issuance_config", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificateIssuanceConfig", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "GetCertificateIssuanceConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.GetCertificateIssuanceConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig", - "shortName": "get_certificate_issuance_config" - }, - "description": "Sample for GetCertificateIssuanceConfig", - "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificateIssuanceConfig_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_issuance_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.get_certificate_map_entry", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificateMapEntry", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "GetCertificateMapEntry" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.GetCertificateMapEntryRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.types.CertificateMapEntry", - "shortName": "get_certificate_map_entry" - }, - "description": "Sample for GetCertificateMapEntry", - "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificateMapEntry_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.get_certificate_map_entry", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificateMapEntry", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "GetCertificateMapEntry" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.GetCertificateMapEntryRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.types.CertificateMapEntry", - "shortName": "get_certificate_map_entry" - }, - "description": "Sample for GetCertificateMapEntry", - "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificateMapEntry_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_entry_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.get_certificate_map", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificateMap", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "GetCertificateMap" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.GetCertificateMapRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.types.CertificateMap", - "shortName": "get_certificate_map" - }, - "description": "Sample for GetCertificateMap", - "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificateMap_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.get_certificate_map", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificateMap", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "GetCertificateMap" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.GetCertificateMapRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.types.CertificateMap", - "shortName": "get_certificate_map" - }, - "description": "Sample for GetCertificateMap", - "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificateMap_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_map_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.get_certificate", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificate", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "GetCertificate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.GetCertificateRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.types.Certificate", - "shortName": "get_certificate" - }, - "description": "Sample for GetCertificate", - "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificate_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.get_certificate", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetCertificate", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "GetCertificate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.GetCertificateRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.types.Certificate", - "shortName": "get_certificate" - }, - "description": "Sample for GetCertificate", - "file": "certificatemanager_v1_generated_certificate_manager_get_certificate_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_GetCertificate_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_get_certificate_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.get_dns_authorization", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetDnsAuthorization", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "GetDnsAuthorization" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.GetDnsAuthorizationRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.types.DnsAuthorization", - "shortName": "get_dns_authorization" - }, - "description": "Sample for GetDnsAuthorization", - "file": "certificatemanager_v1_generated_certificate_manager_get_dns_authorization_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_GetDnsAuthorization_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_get_dns_authorization_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.get_dns_authorization", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.GetDnsAuthorization", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "GetDnsAuthorization" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.GetDnsAuthorizationRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.types.DnsAuthorization", - "shortName": "get_dns_authorization" - }, - "description": "Sample for GetDnsAuthorization", - "file": "certificatemanager_v1_generated_certificate_manager_get_dns_authorization_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_GetDnsAuthorization_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_get_dns_authorization_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.list_certificate_issuance_configs", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificateIssuanceConfigs", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "ListCertificateIssuanceConfigs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateIssuanceConfigsAsyncPager", - "shortName": "list_certificate_issuance_configs" - }, - "description": "Sample for ListCertificateIssuanceConfigs", - "file": "certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificateIssuanceConfigs_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.list_certificate_issuance_configs", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificateIssuanceConfigs", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "ListCertificateIssuanceConfigs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.ListCertificateIssuanceConfigsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateIssuanceConfigsPager", - "shortName": "list_certificate_issuance_configs" - }, - "description": "Sample for ListCertificateIssuanceConfigs", - "file": "certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificateIssuanceConfigs_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_list_certificate_issuance_configs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.list_certificate_map_entries", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificateMapEntries", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "ListCertificateMapEntries" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapEntriesAsyncPager", - "shortName": "list_certificate_map_entries" - }, - "description": "Sample for ListCertificateMapEntries", - "file": "certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificateMapEntries_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.list_certificate_map_entries", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificateMapEntries", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "ListCertificateMapEntries" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.ListCertificateMapEntriesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapEntriesPager", - "shortName": "list_certificate_map_entries" - }, - "description": "Sample for ListCertificateMapEntries", - "file": "certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificateMapEntries_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_list_certificate_map_entries_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.list_certificate_maps", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificateMaps", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "ListCertificateMaps" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.ListCertificateMapsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapsAsyncPager", - "shortName": "list_certificate_maps" - }, - "description": "Sample for ListCertificateMaps", - "file": "certificatemanager_v1_generated_certificate_manager_list_certificate_maps_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificateMaps_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_list_certificate_maps_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.list_certificate_maps", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificateMaps", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "ListCertificateMaps" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.ListCertificateMapsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapsPager", - "shortName": "list_certificate_maps" - }, - "description": "Sample for ListCertificateMaps", - "file": "certificatemanager_v1_generated_certificate_manager_list_certificate_maps_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificateMaps_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_list_certificate_maps_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.list_certificates", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificates", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "ListCertificates" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.ListCertificatesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificatesAsyncPager", - "shortName": "list_certificates" - }, - "description": "Sample for ListCertificates", - "file": "certificatemanager_v1_generated_certificate_manager_list_certificates_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificates_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_list_certificates_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.list_certificates", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListCertificates", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "ListCertificates" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.ListCertificatesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificatesPager", - "shortName": "list_certificates" - }, - "description": "Sample for ListCertificates", - "file": "certificatemanager_v1_generated_certificate_manager_list_certificates_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_ListCertificates_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_list_certificates_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.list_dns_authorizations", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListDnsAuthorizations", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "ListDnsAuthorizations" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListDnsAuthorizationsAsyncPager", - "shortName": "list_dns_authorizations" - }, - "description": "Sample for ListDnsAuthorizations", - "file": "certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_ListDnsAuthorizations_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.list_dns_authorizations", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.ListDnsAuthorizations", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "ListDnsAuthorizations" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.ListDnsAuthorizationsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListDnsAuthorizationsPager", - "shortName": "list_dns_authorizations" - }, - "description": "Sample for ListDnsAuthorizations", - "file": "certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_ListDnsAuthorizations_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_list_dns_authorizations_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.update_certificate_map_entry", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateCertificateMapEntry", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "UpdateCertificateMapEntry" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.UpdateCertificateMapEntryRequest" - }, - { - "name": "certificate_map_entry", - "type": "google.cloud.certificate_manager_v1.types.CertificateMapEntry" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_certificate_map_entry" - }, - "description": "Sample for UpdateCertificateMapEntry", - "file": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateCertificateMapEntry_async", - "segments": [ - { - "end": 58, - "start": 27, - "type": "FULL" - }, - { - "end": 58, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 55, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 59, - "start": 56, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.update_certificate_map_entry", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateCertificateMapEntry", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "UpdateCertificateMapEntry" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.UpdateCertificateMapEntryRequest" - }, - { - "name": "certificate_map_entry", - "type": "google.cloud.certificate_manager_v1.types.CertificateMapEntry" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_certificate_map_entry" - }, - "description": "Sample for UpdateCertificateMapEntry", - "file": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateCertificateMapEntry_sync", - "segments": [ - { - "end": 58, - "start": 27, - "type": "FULL" - }, - { - "end": 58, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 55, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 59, - "start": 56, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_entry_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.update_certificate_map", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateCertificateMap", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "UpdateCertificateMap" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.UpdateCertificateMapRequest" - }, - { - "name": "certificate_map", - "type": "google.cloud.certificate_manager_v1.types.CertificateMap" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_certificate_map" - }, - "description": "Sample for UpdateCertificateMap", - "file": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateCertificateMap_async", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.update_certificate_map", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateCertificateMap", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "UpdateCertificateMap" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.UpdateCertificateMapRequest" - }, - { - "name": "certificate_map", - "type": "google.cloud.certificate_manager_v1.types.CertificateMap" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_certificate_map" - }, - "description": "Sample for UpdateCertificateMap", - "file": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateCertificateMap_sync", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_update_certificate_map_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.update_certificate", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateCertificate", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "UpdateCertificate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.UpdateCertificateRequest" - }, - { - "name": "certificate", - "type": "google.cloud.certificate_manager_v1.types.Certificate" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_certificate" - }, - "description": "Sample for UpdateCertificate", - "file": "certificatemanager_v1_generated_certificate_manager_update_certificate_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateCertificate_async", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_update_certificate_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.update_certificate", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateCertificate", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "UpdateCertificate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.UpdateCertificateRequest" - }, - { - "name": "certificate", - "type": "google.cloud.certificate_manager_v1.types.Certificate" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_certificate" - }, - "description": "Sample for UpdateCertificate", - "file": "certificatemanager_v1_generated_certificate_manager_update_certificate_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateCertificate_sync", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_update_certificate_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient", - "shortName": "CertificateManagerAsyncClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerAsyncClient.update_dns_authorization", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateDnsAuthorization", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "UpdateDnsAuthorization" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.UpdateDnsAuthorizationRequest" - }, - { - "name": "dns_authorization", - "type": "google.cloud.certificate_manager_v1.types.DnsAuthorization" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_dns_authorization" - }, - "description": "Sample for UpdateDnsAuthorization", - "file": "certificatemanager_v1_generated_certificate_manager_update_dns_authorization_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateDnsAuthorization_async", - "segments": [ - { - "end": 58, - "start": 27, - "type": "FULL" - }, - { - "end": 58, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 55, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 59, - "start": 56, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_update_dns_authorization_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient", - "shortName": "CertificateManagerClient" - }, - "fullName": "google.cloud.certificate_manager_v1.CertificateManagerClient.update_dns_authorization", - "method": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager.UpdateDnsAuthorization", - "service": { - "fullName": "google.cloud.certificatemanager.v1.CertificateManager", - "shortName": "CertificateManager" - }, - "shortName": "UpdateDnsAuthorization" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.certificate_manager_v1.types.UpdateDnsAuthorizationRequest" - }, - { - "name": "dns_authorization", - "type": "google.cloud.certificate_manager_v1.types.DnsAuthorization" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_dns_authorization" - }, - "description": "Sample for UpdateDnsAuthorization", - "file": "certificatemanager_v1_generated_certificate_manager_update_dns_authorization_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "certificatemanager_v1_generated_CertificateManager_UpdateDnsAuthorization_sync", - "segments": [ - { - "end": 58, - "start": 27, - "type": "FULL" - }, - { - "end": 58, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 55, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 59, - "start": 56, - "type": "RESPONSE_HANDLING" - } - ], - "title": "certificatemanager_v1_generated_certificate_manager_update_dns_authorization_sync.py" - } - ] -} diff --git a/owl-bot-staging/v1/scripts/fixup_certificate_manager_v1_keywords.py b/owl-bot-staging/v1/scripts/fixup_certificate_manager_v1_keywords.py deleted file mode 100644 index 6d20e61..0000000 --- a/owl-bot-staging/v1/scripts/fixup_certificate_manager_v1_keywords.py +++ /dev/null @@ -1,199 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -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 certificate_managerCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_certificate': ('parent', 'certificate_id', 'certificate', ), - 'create_certificate_issuance_config': ('parent', 'certificate_issuance_config_id', 'certificate_issuance_config', ), - 'create_certificate_map': ('parent', 'certificate_map_id', 'certificate_map', ), - 'create_certificate_map_entry': ('parent', 'certificate_map_entry_id', 'certificate_map_entry', ), - 'create_dns_authorization': ('parent', 'dns_authorization_id', 'dns_authorization', ), - 'delete_certificate': ('name', ), - 'delete_certificate_issuance_config': ('name', ), - 'delete_certificate_map': ('name', ), - 'delete_certificate_map_entry': ('name', ), - 'delete_dns_authorization': ('name', ), - 'get_certificate': ('name', ), - 'get_certificate_issuance_config': ('name', ), - 'get_certificate_map': ('name', ), - 'get_certificate_map_entry': ('name', ), - 'get_dns_authorization': ('name', ), - 'list_certificate_issuance_configs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificate_map_entries': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificate_maps': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_dns_authorizations': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'update_certificate': ('certificate', 'update_mask', ), - 'update_certificate_map': ('certificate_map', 'update_mask', ), - 'update_certificate_map_entry': ('certificate_map_entry', 'update_mask', ), - 'update_dns_authorization': ('dns_authorization', 'update_mask', ), - } - - 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: a.keyword.value not 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=certificate_managerCallTransformer(), -): - """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 certificate_manager 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 deleted file mode 100644 index d97179b..0000000 --- a/owl-bot-staging/v1/setup.py +++ /dev/null @@ -1,90 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import io -import os - -import setuptools # type: ignore - -package_root = os.path.abspath(os.path.dirname(__file__)) - -name = 'google-cloud-certificate-manager' - - -description = "Google Cloud Certificate Manager API client library" - -version = {} -with open(os.path.join(package_root, 'google/cloud/certificate_manager/gapic_version.py')) as fp: - exec(fp.read(), version) -version = version["__version__"] - -if version[0] == "0": - release_status = "Development Status :: 4 - Beta" -else: - release_status = "Development Status :: 5 - Production/Stable" - -dependencies = [ - "google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", - "proto-plus >= 1.22.0, <2.0.0dev", - "proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'", - "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", -] -url = "https://github.com/googleapis/python-certificate-manager" - -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() - -packages = [ - package - for package in setuptools.PEP420PackageFinder.find() - if package.startswith("google") -] - -namespaces = ["google", "google.cloud"] - -setuptools.setup( - name=name, - version=version, - description=description, - long_description=readme, - author="Google LLC", - author_email="googleapis-packages@google.com", - license="Apache 2.0", - url=url, - classifiers=[ - release_status, - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Operating System :: OS Independent", - "Topic :: Internet", - ], - platforms="Posix; MacOS X; Windows", - packages=packages, - python_requires=">=3.7", - namespace_packages=namespaces, - install_requires=dependencies, - include_package_data=True, - zip_safe=False, -) diff --git a/owl-bot-staging/v1/testing/constraints-3.10.txt b/owl-bot-staging/v1/testing/constraints-3.10.txt deleted file mode 100644 index ed7f9ae..0000000 --- a/owl-bot-staging/v1/testing/constraints-3.10.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/v1/testing/constraints-3.11.txt b/owl-bot-staging/v1/testing/constraints-3.11.txt deleted file mode 100644 index ed7f9ae..0000000 --- a/owl-bot-staging/v1/testing/constraints-3.11.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/v1/testing/constraints-3.12.txt b/owl-bot-staging/v1/testing/constraints-3.12.txt deleted file mode 100644 index ed7f9ae..0000000 --- a/owl-bot-staging/v1/testing/constraints-3.12.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/v1/testing/constraints-3.7.txt b/owl-bot-staging/v1/testing/constraints-3.7.txt deleted file mode 100644 index 6c44adf..0000000 --- a/owl-bot-staging/v1/testing/constraints-3.7.txt +++ /dev/null @@ -1,9 +0,0 @@ -# This constraints file is used to check that lower bounds -# are correct in setup.py -# List all library dependencies and extras in this file. -# Pin the version to the lower bound. -# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", -# Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.34.0 -proto-plus==1.22.0 -protobuf==3.19.5 diff --git a/owl-bot-staging/v1/testing/constraints-3.8.txt b/owl-bot-staging/v1/testing/constraints-3.8.txt deleted file mode 100644 index ed7f9ae..0000000 --- a/owl-bot-staging/v1/testing/constraints-3.8.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/v1/testing/constraints-3.9.txt b/owl-bot-staging/v1/testing/constraints-3.9.txt deleted file mode 100644 index ed7f9ae..0000000 --- a/owl-bot-staging/v1/testing/constraints-3.9.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/v1/tests/__init__.py b/owl-bot-staging/v1/tests/__init__.py deleted file mode 100644 index 231bc12..0000000 --- a/owl-bot-staging/v1/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1/tests/unit/__init__.py b/owl-bot-staging/v1/tests/unit/__init__.py deleted file mode 100644 index 231bc12..0000000 --- a/owl-bot-staging/v1/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/__init__.py deleted file mode 100644 index 231bc12..0000000 --- a/owl-bot-staging/v1/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/__init__.py deleted file mode 100644 index 231bc12..0000000 --- a/owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py b/owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py deleted file mode 100644 index 1816e3e..0000000 --- a/owl-bot-staging/v1/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py +++ /dev/null @@ -1,15180 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -# try/except added for compatibility with python < 3.8 -try: - from unittest import mock - from unittest.mock import AsyncMock # pragma: NO COVER -except ImportError: # pragma: NO COVER - import mock - -import grpc -from grpc.experimental import aio -from collections.abc import Iterable -from google.protobuf import json_format -import json -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule -from proto.marshal.rules import wrappers -from requests import Response -from requests import Request, PreparedRequest -from requests.sessions import Session -from google.protobuf import json_format - -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 -from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.certificate_manager_v1.services.certificate_manager import CertificateManagerAsyncClient -from google.cloud.certificate_manager_v1.services.certificate_manager import CertificateManagerClient -from google.cloud.certificate_manager_v1.services.certificate_manager import pagers -from google.cloud.certificate_manager_v1.services.certificate_manager import transports -from google.cloud.certificate_manager_v1.types import certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_issuance_config as gcc_certificate_issuance_config -from google.cloud.certificate_manager_v1.types import certificate_manager -from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 -from google.oauth2 import service_account -from google.protobuf import duration_pb2 # type: ignore -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 -import google.auth - - -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 CertificateManagerClient._get_default_mtls_endpoint(None) is None - assert CertificateManagerClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert CertificateManagerClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert CertificateManagerClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert CertificateManagerClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert CertificateManagerClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (CertificateManagerClient, "grpc"), - (CertificateManagerAsyncClient, "grpc_asyncio"), - (CertificateManagerClient, "rest"), -]) -def test_certificate_manager_client_from_service_account_info(client_class, transport_name): - 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, transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ( - 'certificatemanager.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://certificatemanager.googleapis.com' - ) - - -@pytest.mark.parametrize("transport_class,transport_name", [ - (transports.CertificateManagerGrpcTransport, "grpc"), - (transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio"), - (transports.CertificateManagerRestTransport, "rest"), -]) -def test_certificate_manager_client_service_account_always_use_jwt(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) - - 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=False) - use_jwt.assert_not_called() - - -@pytest.mark.parametrize("client_class,transport_name", [ - (CertificateManagerClient, "grpc"), - (CertificateManagerAsyncClient, "grpc_asyncio"), - (CertificateManagerClient, "rest"), -]) -def test_certificate_manager_client_from_service_account_file(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: - factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json", transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json", transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ( - 'certificatemanager.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://certificatemanager.googleapis.com' - ) - - -def test_certificate_manager_client_get_transport_class(): - transport = CertificateManagerClient.get_transport_class() - available_transports = [ - transports.CertificateManagerGrpcTransport, - transports.CertificateManagerRestTransport, - ] - assert transport in available_transports - - transport = CertificateManagerClient.get_transport_class("grpc") - assert transport == transports.CertificateManagerGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CertificateManagerClient, transports.CertificateManagerGrpcTransport, "grpc"), - (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio"), - (CertificateManagerClient, transports.CertificateManagerRestTransport, "rest"), -]) -@mock.patch.object(CertificateManagerClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateManagerClient)) -@mock.patch.object(CertificateManagerAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateManagerAsyncClient)) -def test_certificate_manager_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(CertificateManagerClient, '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(CertificateManagerClient, '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(transport=transport_name, 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, - always_use_jwt_access=True, - api_audience=None, - ) - - # 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(transport=transport_name) - 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, - always_use_jwt_access=True, - api_audience=None, - ) - - # 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(transport=transport_name) - 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, - always_use_jwt_access=True, - api_audience=None, - ) - - # 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(transport=transport_name) - - # 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(transport=transport_name) - - # 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, transport=transport_name) - 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, - always_use_jwt_access=True, - api_audience=None, - ) - # Check the case api_endpoint is provided - options = client_options.ClientOptions(api_audience="https://language.googleapis.com") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - 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, - always_use_jwt_access=True, - api_audience="https://language.googleapis.com" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (CertificateManagerClient, transports.CertificateManagerGrpcTransport, "grpc", "true"), - (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (CertificateManagerClient, transports.CertificateManagerGrpcTransport, "grpc", "false"), - (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio", "false"), - (CertificateManagerClient, transports.CertificateManagerRestTransport, "rest", "true"), - (CertificateManagerClient, transports.CertificateManagerRestTransport, "rest", "false"), -]) -@mock.patch.object(CertificateManagerClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateManagerClient)) -@mock.patch.object(CertificateManagerAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateManagerAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_certificate_manager_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, transport=transport_name) - - 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, - always_use_jwt_access=True, - api_audience=None, - ) - - # 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(transport=transport_name) - 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, - always_use_jwt_access=True, - api_audience=None, - ) - - # 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(transport=transport_name) - 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, - always_use_jwt_access=True, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - CertificateManagerClient, CertificateManagerAsyncClient -]) -@mock.patch.object(CertificateManagerClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateManagerClient)) -@mock.patch.object(CertificateManagerAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateManagerAsyncClient)) -def test_certificate_manager_client_get_mtls_endpoint_and_cert_source(client_class): - mock_client_cert_source = mock.Mock() - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - mock_api_endpoint = "foo" - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) - assert api_endpoint == mock_api_endpoint - assert cert_source == mock_client_cert_source - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - mock_client_cert_source = mock.Mock() - mock_api_endpoint = "foo" - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) - assert api_endpoint == mock_api_endpoint - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=False): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - 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=mock_client_cert_source): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source == mock_client_cert_source - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CertificateManagerClient, transports.CertificateManagerGrpcTransport, "grpc"), - (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio"), - (CertificateManagerClient, transports.CertificateManagerRestTransport, "rest"), -]) -def test_certificate_manager_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, transport=transport_name) - 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, - always_use_jwt_access=True, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (CertificateManagerClient, transports.CertificateManagerGrpcTransport, "grpc", grpc_helpers), - (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), - (CertificateManagerClient, transports.CertificateManagerRestTransport, "rest", None), -]) -def test_certificate_manager_client_client_options_credentials_file(client_class, transport_class, transport_name, grpc_helpers): - # 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, transport=transport_name) - 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, - always_use_jwt_access=True, - api_audience=None, - ) - -def test_certificate_manager_client_client_options_from_dict(): - with mock.patch('google.cloud.certificate_manager_v1.services.certificate_manager.transports.CertificateManagerGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = CertificateManagerClient( - 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, - always_use_jwt_access=True, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (CertificateManagerClient, transports.CertificateManagerGrpcTransport, "grpc", grpc_helpers), - (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_certificate_manager_client_create_channel_credentials_file(client_class, transport_class, transport_name, grpc_helpers): - # 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, transport=transport_name) - 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, - always_use_jwt_access=True, - api_audience=None, - ) - - # test that the credentials from file are saved and used as the credentials. - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel" - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - file_creds = ga_credentials.AnonymousCredentials() - load_creds.return_value = (file_creds, None) - adc.return_value = (creds, None) - client = client_class(client_options=options, transport=transport_name) - create_channel.assert_called_with( - "certificatemanager.googleapis.com:443", - credentials=file_creds, - credentials_file=None, - quota_project_id=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - scopes=None, - default_host="certificatemanager.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.ListCertificatesRequest, - dict, -]) -def test_list_certificates(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.ListCertificatesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_certificates(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.ListCertificatesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificatesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificates_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 = CertificateManagerClient( - 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_certificates), - '__call__') as call: - client.list_certificates() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.ListCertificatesRequest() - -@pytest.mark.asyncio -async def test_list_certificates_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.ListCertificatesRequest): - client = CertificateManagerAsyncClient( - 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_certificates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificatesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_certificates(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.ListCertificatesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificatesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_certificates_async_from_dict(): - await test_list_certificates_async(request_type=dict) - - -def test_list_certificates_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.ListCertificatesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificates), - '__call__') as call: - call.return_value = certificate_manager.ListCertificatesResponse() - client.list_certificates(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_certificates_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.ListCertificatesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificates), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificatesResponse()) - await client.list_certificates(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_certificates_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.ListCertificatesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_certificates( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_certificates_flattened_error(): - client = CertificateManagerClient( - 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_certificates( - certificate_manager.ListCertificatesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_certificates_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.ListCertificatesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificatesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_certificates( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_certificates_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificates( - certificate_manager.ListCertificatesRequest(), - parent='parent_value', - ) - - -def test_list_certificates_pager(transport_name: str = "grpc"): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificates), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - certificate_manager.Certificate(), - certificate_manager.Certificate(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - certificate_manager.Certificate(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_certificates(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, certificate_manager.Certificate) - for i in results) -def test_list_certificates_pages(transport_name: str = "grpc"): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificates), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - certificate_manager.Certificate(), - certificate_manager.Certificate(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - certificate_manager.Certificate(), - ], - ), - RuntimeError, - ) - pages = list(client.list_certificates(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_certificates_async_pager(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificates), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - certificate_manager.Certificate(), - certificate_manager.Certificate(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - certificate_manager.Certificate(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_certificates(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, certificate_manager.Certificate) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_certificates_async_pages(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificates), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - certificate_manager.Certificate(), - certificate_manager.Certificate(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - certificate_manager.Certificate(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_certificates(request={})).pages: # pragma: no branch - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - certificate_manager.GetCertificateRequest, - dict, -]) -def test_get_certificate(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.Certificate( - name='name_value', - description='description_value', - san_dnsnames=['san_dnsnames_value'], - pem_certificate='pem_certificate_value', - scope=certificate_manager.Certificate.Scope.EDGE_CACHE, - self_managed=certificate_manager.Certificate.SelfManagedCertificate(pem_certificate='pem_certificate_value'), - ) - response = client.get_certificate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.GetCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_manager.Certificate) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.san_dnsnames == ['san_dnsnames_value'] - assert response.pem_certificate == 'pem_certificate_value' - assert response.scope == certificate_manager.Certificate.Scope.EDGE_CACHE - - -def test_get_certificate_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 = CertificateManagerClient( - 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_certificate), - '__call__') as call: - client.get_certificate() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.GetCertificateRequest() - -@pytest.mark.asyncio -async def test_get_certificate_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.GetCertificateRequest): - client = CertificateManagerAsyncClient( - 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_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.Certificate( - name='name_value', - description='description_value', - san_dnsnames=['san_dnsnames_value'], - pem_certificate='pem_certificate_value', - scope=certificate_manager.Certificate.Scope.EDGE_CACHE, - )) - response = await client.get_certificate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.GetCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_manager.Certificate) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.san_dnsnames == ['san_dnsnames_value'] - assert response.pem_certificate == 'pem_certificate_value' - assert response.scope == certificate_manager.Certificate.Scope.EDGE_CACHE - - -@pytest.mark.asyncio -async def test_get_certificate_async_from_dict(): - await test_get_certificate_async(request_type=dict) - - -def test_get_certificate_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.GetCertificateRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate), - '__call__') as call: - call.return_value = certificate_manager.Certificate() - client.get_certificate(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_certificate_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.GetCertificateRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.Certificate()) - await client.get_certificate(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_certificate_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.Certificate() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_certificate( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_certificate_flattened_error(): - client = CertificateManagerClient( - 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_certificate( - certificate_manager.GetCertificateRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_certificate_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.Certificate() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.Certificate()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_certificate( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_certificate_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate( - certificate_manager.GetCertificateRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.CreateCertificateRequest, - dict, -]) -def test_create_certificate(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_certificate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.CreateCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_certificate_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 = CertificateManagerClient( - 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_certificate), - '__call__') as call: - client.create_certificate() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.CreateCertificateRequest() - -@pytest.mark.asyncio -async def test_create_certificate_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.CreateCertificateRequest): - client = CertificateManagerAsyncClient( - 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_certificate), - '__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_certificate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.CreateCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_certificate_async_from_dict(): - await test_create_certificate_async(request_type=dict) - - -def test_create_certificate_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.CreateCertificateRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_certificate(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_certificate_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.CreateCertificateRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_certificate(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_certificate_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate), - '__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_certificate( - parent='parent_value', - certificate=certificate_manager.Certificate(name='name_value'), - certificate_id='certificate_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].certificate - mock_val = certificate_manager.Certificate(name='name_value') - assert arg == mock_val - arg = args[0].certificate_id - mock_val = 'certificate_id_value' - assert arg == mock_val - - -def test_create_certificate_flattened_error(): - client = CertificateManagerClient( - 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_certificate( - certificate_manager.CreateCertificateRequest(), - parent='parent_value', - certificate=certificate_manager.Certificate(name='name_value'), - certificate_id='certificate_id_value', - ) - -@pytest.mark.asyncio -async def test_create_certificate_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate), - '__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_certificate( - parent='parent_value', - certificate=certificate_manager.Certificate(name='name_value'), - certificate_id='certificate_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].certificate - mock_val = certificate_manager.Certificate(name='name_value') - assert arg == mock_val - arg = args[0].certificate_id - mock_val = 'certificate_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_certificate_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate( - certificate_manager.CreateCertificateRequest(), - parent='parent_value', - certificate=certificate_manager.Certificate(name='name_value'), - certificate_id='certificate_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.UpdateCertificateRequest, - dict, -]) -def test_update_certificate(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_certificate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.UpdateCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_certificate_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 = CertificateManagerClient( - 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_certificate), - '__call__') as call: - client.update_certificate() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.UpdateCertificateRequest() - -@pytest.mark.asyncio -async def test_update_certificate_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.UpdateCertificateRequest): - client = CertificateManagerAsyncClient( - 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_certificate), - '__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_certificate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.UpdateCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_certificate_async_from_dict(): - await test_update_certificate_async(request_type=dict) - - -def test_update_certificate_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.UpdateCertificateRequest() - - request.certificate.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_certificate(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', - 'certificate.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_certificate_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.UpdateCertificateRequest() - - request.certificate.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_certificate(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', - 'certificate.name=name_value', - ) in kw['metadata'] - - -def test_update_certificate_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate), - '__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_certificate( - certificate=certificate_manager.Certificate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].certificate - mock_val = certificate_manager.Certificate(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_certificate_flattened_error(): - client = CertificateManagerClient( - 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_certificate( - certificate_manager.UpdateCertificateRequest(), - certificate=certificate_manager.Certificate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_certificate_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate), - '__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_certificate( - certificate=certificate_manager.Certificate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].certificate - mock_val = certificate_manager.Certificate(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_certificate_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate( - certificate_manager.UpdateCertificateRequest(), - certificate=certificate_manager.Certificate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.DeleteCertificateRequest, - dict, -]) -def test_delete_certificate(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_certificate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.DeleteCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_certificate_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 = CertificateManagerClient( - 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_certificate), - '__call__') as call: - client.delete_certificate() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.DeleteCertificateRequest() - -@pytest.mark.asyncio -async def test_delete_certificate_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.DeleteCertificateRequest): - client = CertificateManagerAsyncClient( - 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_certificate), - '__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_certificate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.DeleteCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_certificate_async_from_dict(): - await test_delete_certificate_async(request_type=dict) - - -def test_delete_certificate_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.DeleteCertificateRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_certificate(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_certificate_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.DeleteCertificateRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_certificate(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_certificate_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate), - '__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_certificate( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_certificate_flattened_error(): - client = CertificateManagerClient( - 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_certificate( - certificate_manager.DeleteCertificateRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_certificate_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate), - '__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_certificate( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_certificate_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate( - certificate_manager.DeleteCertificateRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.ListCertificateMapsRequest, - dict, -]) -def test_list_certificate_maps(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_maps), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.ListCertificateMapsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_certificate_maps(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.ListCertificateMapsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateMapsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificate_maps_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 = CertificateManagerClient( - 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_certificate_maps), - '__call__') as call: - client.list_certificate_maps() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.ListCertificateMapsRequest() - -@pytest.mark.asyncio -async def test_list_certificate_maps_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.ListCertificateMapsRequest): - client = CertificateManagerAsyncClient( - 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_certificate_maps), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificateMapsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_certificate_maps(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.ListCertificateMapsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateMapsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_certificate_maps_async_from_dict(): - await test_list_certificate_maps_async(request_type=dict) - - -def test_list_certificate_maps_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.ListCertificateMapsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_maps), - '__call__') as call: - call.return_value = certificate_manager.ListCertificateMapsResponse() - client.list_certificate_maps(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_certificate_maps_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.ListCertificateMapsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_maps), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificateMapsResponse()) - await client.list_certificate_maps(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_certificate_maps_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_maps), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.ListCertificateMapsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_certificate_maps( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_certificate_maps_flattened_error(): - client = CertificateManagerClient( - 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_certificate_maps( - certificate_manager.ListCertificateMapsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_certificate_maps_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_maps), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.ListCertificateMapsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificateMapsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_certificate_maps( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_certificate_maps_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_maps( - certificate_manager.ListCertificateMapsRequest(), - parent='parent_value', - ) - - -def test_list_certificate_maps_pager(transport_name: str = "grpc"): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_maps), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[], - next_page_token='def', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_certificate_maps(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, certificate_manager.CertificateMap) - for i in results) -def test_list_certificate_maps_pages(transport_name: str = "grpc"): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_maps), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[], - next_page_token='def', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - ], - ), - RuntimeError, - ) - pages = list(client.list_certificate_maps(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_certificate_maps_async_pager(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_maps), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[], - next_page_token='def', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_certificate_maps(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, certificate_manager.CertificateMap) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_certificate_maps_async_pages(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_maps), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[], - next_page_token='def', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_certificate_maps(request={})).pages: # pragma: no branch - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - certificate_manager.GetCertificateMapRequest, - dict, -]) -def test_get_certificate_map(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_map), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.CertificateMap( - name='name_value', - description='description_value', - ) - response = client.get_certificate_map(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.GetCertificateMapRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_manager.CertificateMap) - assert response.name == 'name_value' - assert response.description == 'description_value' - - -def test_get_certificate_map_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 = CertificateManagerClient( - 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_certificate_map), - '__call__') as call: - client.get_certificate_map() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.GetCertificateMapRequest() - -@pytest.mark.asyncio -async def test_get_certificate_map_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.GetCertificateMapRequest): - client = CertificateManagerAsyncClient( - 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_certificate_map), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.CertificateMap( - name='name_value', - description='description_value', - )) - response = await client.get_certificate_map(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.GetCertificateMapRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_manager.CertificateMap) - assert response.name == 'name_value' - assert response.description == 'description_value' - - -@pytest.mark.asyncio -async def test_get_certificate_map_async_from_dict(): - await test_get_certificate_map_async(request_type=dict) - - -def test_get_certificate_map_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.GetCertificateMapRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate_map), - '__call__') as call: - call.return_value = certificate_manager.CertificateMap() - client.get_certificate_map(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_certificate_map_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.GetCertificateMapRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate_map), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.CertificateMap()) - await client.get_certificate_map(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_certificate_map_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate_map), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.CertificateMap() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_certificate_map( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_certificate_map_flattened_error(): - client = CertificateManagerClient( - 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_certificate_map( - certificate_manager.GetCertificateMapRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_certificate_map_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate_map), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.CertificateMap() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.CertificateMap()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_certificate_map( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_certificate_map_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_map( - certificate_manager.GetCertificateMapRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.CreateCertificateMapRequest, - dict, -]) -def test_create_certificate_map(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_map), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_certificate_map(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.CreateCertificateMapRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_certificate_map_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 = CertificateManagerClient( - 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_certificate_map), - '__call__') as call: - client.create_certificate_map() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.CreateCertificateMapRequest() - -@pytest.mark.asyncio -async def test_create_certificate_map_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.CreateCertificateMapRequest): - client = CertificateManagerAsyncClient( - 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_certificate_map), - '__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_certificate_map(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.CreateCertificateMapRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_certificate_map_async_from_dict(): - await test_create_certificate_map_async(request_type=dict) - - -def test_create_certificate_map_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.CreateCertificateMapRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate_map), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_certificate_map(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_certificate_map_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.CreateCertificateMapRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate_map), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_certificate_map(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_certificate_map_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate_map), - '__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_certificate_map( - parent='parent_value', - certificate_map=certificate_manager.CertificateMap(name='name_value'), - certificate_map_id='certificate_map_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].certificate_map - mock_val = certificate_manager.CertificateMap(name='name_value') - assert arg == mock_val - arg = args[0].certificate_map_id - mock_val = 'certificate_map_id_value' - assert arg == mock_val - - -def test_create_certificate_map_flattened_error(): - client = CertificateManagerClient( - 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_certificate_map( - certificate_manager.CreateCertificateMapRequest(), - parent='parent_value', - certificate_map=certificate_manager.CertificateMap(name='name_value'), - certificate_map_id='certificate_map_id_value', - ) - -@pytest.mark.asyncio -async def test_create_certificate_map_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate_map), - '__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_certificate_map( - parent='parent_value', - certificate_map=certificate_manager.CertificateMap(name='name_value'), - certificate_map_id='certificate_map_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].certificate_map - mock_val = certificate_manager.CertificateMap(name='name_value') - assert arg == mock_val - arg = args[0].certificate_map_id - mock_val = 'certificate_map_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_certificate_map_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_map( - certificate_manager.CreateCertificateMapRequest(), - parent='parent_value', - certificate_map=certificate_manager.CertificateMap(name='name_value'), - certificate_map_id='certificate_map_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.UpdateCertificateMapRequest, - dict, -]) -def test_update_certificate_map(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_map), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_certificate_map(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.UpdateCertificateMapRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_certificate_map_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 = CertificateManagerClient( - 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_certificate_map), - '__call__') as call: - client.update_certificate_map() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.UpdateCertificateMapRequest() - -@pytest.mark.asyncio -async def test_update_certificate_map_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.UpdateCertificateMapRequest): - client = CertificateManagerAsyncClient( - 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_certificate_map), - '__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_certificate_map(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.UpdateCertificateMapRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_certificate_map_async_from_dict(): - await test_update_certificate_map_async(request_type=dict) - - -def test_update_certificate_map_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.UpdateCertificateMapRequest() - - request.certificate_map.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_map), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_certificate_map(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', - 'certificate_map.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_certificate_map_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.UpdateCertificateMapRequest() - - request.certificate_map.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_map), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_certificate_map(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', - 'certificate_map.name=name_value', - ) in kw['metadata'] - - -def test_update_certificate_map_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_map), - '__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_certificate_map( - certificate_map=certificate_manager.CertificateMap(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].certificate_map - mock_val = certificate_manager.CertificateMap(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_certificate_map_flattened_error(): - client = CertificateManagerClient( - 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_certificate_map( - certificate_manager.UpdateCertificateMapRequest(), - certificate_map=certificate_manager.CertificateMap(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_certificate_map_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_map), - '__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_certificate_map( - certificate_map=certificate_manager.CertificateMap(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].certificate_map - mock_val = certificate_manager.CertificateMap(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_certificate_map_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_map( - certificate_manager.UpdateCertificateMapRequest(), - certificate_map=certificate_manager.CertificateMap(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.DeleteCertificateMapRequest, - dict, -]) -def test_delete_certificate_map(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_map), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_certificate_map(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.DeleteCertificateMapRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_certificate_map_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 = CertificateManagerClient( - 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_certificate_map), - '__call__') as call: - client.delete_certificate_map() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.DeleteCertificateMapRequest() - -@pytest.mark.asyncio -async def test_delete_certificate_map_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.DeleteCertificateMapRequest): - client = CertificateManagerAsyncClient( - 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_certificate_map), - '__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_certificate_map(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.DeleteCertificateMapRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_certificate_map_async_from_dict(): - await test_delete_certificate_map_async(request_type=dict) - - -def test_delete_certificate_map_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.DeleteCertificateMapRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate_map), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_certificate_map(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_certificate_map_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.DeleteCertificateMapRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate_map), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_certificate_map(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_certificate_map_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate_map), - '__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_certificate_map( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_certificate_map_flattened_error(): - client = CertificateManagerClient( - 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_certificate_map( - certificate_manager.DeleteCertificateMapRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_certificate_map_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate_map), - '__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_certificate_map( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_certificate_map_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_map( - certificate_manager.DeleteCertificateMapRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.ListCertificateMapEntriesRequest, - dict, -]) -def test_list_certificate_map_entries(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_map_entries), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.ListCertificateMapEntriesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_certificate_map_entries(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.ListCertificateMapEntriesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateMapEntriesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificate_map_entries_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 = CertificateManagerClient( - 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_certificate_map_entries), - '__call__') as call: - client.list_certificate_map_entries() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.ListCertificateMapEntriesRequest() - -@pytest.mark.asyncio -async def test_list_certificate_map_entries_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.ListCertificateMapEntriesRequest): - client = CertificateManagerAsyncClient( - 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_certificate_map_entries), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificateMapEntriesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_certificate_map_entries(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.ListCertificateMapEntriesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateMapEntriesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_certificate_map_entries_async_from_dict(): - await test_list_certificate_map_entries_async(request_type=dict) - - -def test_list_certificate_map_entries_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.ListCertificateMapEntriesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_map_entries), - '__call__') as call: - call.return_value = certificate_manager.ListCertificateMapEntriesResponse() - client.list_certificate_map_entries(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_certificate_map_entries_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.ListCertificateMapEntriesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_map_entries), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificateMapEntriesResponse()) - await client.list_certificate_map_entries(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_certificate_map_entries_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_map_entries), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.ListCertificateMapEntriesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_certificate_map_entries( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_certificate_map_entries_flattened_error(): - client = CertificateManagerClient( - 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_certificate_map_entries( - certificate_manager.ListCertificateMapEntriesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_certificate_map_entries_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_map_entries), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.ListCertificateMapEntriesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListCertificateMapEntriesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_certificate_map_entries( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_certificate_map_entries_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_map_entries( - certificate_manager.ListCertificateMapEntriesRequest(), - parent='parent_value', - ) - - -def test_list_certificate_map_entries_pager(transport_name: str = "grpc"): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_map_entries), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[], - next_page_token='def', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_certificate_map_entries(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, certificate_manager.CertificateMapEntry) - for i in results) -def test_list_certificate_map_entries_pages(transport_name: str = "grpc"): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_map_entries), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[], - next_page_token='def', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - ], - ), - RuntimeError, - ) - pages = list(client.list_certificate_map_entries(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_certificate_map_entries_async_pager(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_map_entries), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[], - next_page_token='def', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_certificate_map_entries(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, certificate_manager.CertificateMapEntry) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_certificate_map_entries_async_pages(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_map_entries), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[], - next_page_token='def', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_certificate_map_entries(request={})).pages: # pragma: no branch - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - certificate_manager.GetCertificateMapEntryRequest, - dict, -]) -def test_get_certificate_map_entry(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_map_entry), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.CertificateMapEntry( - name='name_value', - description='description_value', - certificates=['certificates_value'], - state=certificate_manager.ServingState.ACTIVE, - hostname='hostname_value', - ) - response = client.get_certificate_map_entry(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.GetCertificateMapEntryRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_manager.CertificateMapEntry) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.certificates == ['certificates_value'] - assert response.state == certificate_manager.ServingState.ACTIVE - - -def test_get_certificate_map_entry_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 = CertificateManagerClient( - 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_certificate_map_entry), - '__call__') as call: - client.get_certificate_map_entry() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.GetCertificateMapEntryRequest() - -@pytest.mark.asyncio -async def test_get_certificate_map_entry_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.GetCertificateMapEntryRequest): - client = CertificateManagerAsyncClient( - 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_certificate_map_entry), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.CertificateMapEntry( - name='name_value', - description='description_value', - certificates=['certificates_value'], - state=certificate_manager.ServingState.ACTIVE, - )) - response = await client.get_certificate_map_entry(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.GetCertificateMapEntryRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_manager.CertificateMapEntry) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.certificates == ['certificates_value'] - assert response.state == certificate_manager.ServingState.ACTIVE - - -@pytest.mark.asyncio -async def test_get_certificate_map_entry_async_from_dict(): - await test_get_certificate_map_entry_async(request_type=dict) - - -def test_get_certificate_map_entry_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.GetCertificateMapEntryRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate_map_entry), - '__call__') as call: - call.return_value = certificate_manager.CertificateMapEntry() - client.get_certificate_map_entry(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_certificate_map_entry_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.GetCertificateMapEntryRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate_map_entry), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.CertificateMapEntry()) - await client.get_certificate_map_entry(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_certificate_map_entry_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate_map_entry), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.CertificateMapEntry() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_certificate_map_entry( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_certificate_map_entry_flattened_error(): - client = CertificateManagerClient( - 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_certificate_map_entry( - certificate_manager.GetCertificateMapEntryRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_certificate_map_entry_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate_map_entry), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.CertificateMapEntry() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.CertificateMapEntry()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_certificate_map_entry( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_certificate_map_entry_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_map_entry( - certificate_manager.GetCertificateMapEntryRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.CreateCertificateMapEntryRequest, - dict, -]) -def test_create_certificate_map_entry(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_map_entry), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_certificate_map_entry(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.CreateCertificateMapEntryRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_certificate_map_entry_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 = CertificateManagerClient( - 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_certificate_map_entry), - '__call__') as call: - client.create_certificate_map_entry() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.CreateCertificateMapEntryRequest() - -@pytest.mark.asyncio -async def test_create_certificate_map_entry_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.CreateCertificateMapEntryRequest): - client = CertificateManagerAsyncClient( - 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_certificate_map_entry), - '__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_certificate_map_entry(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.CreateCertificateMapEntryRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_certificate_map_entry_async_from_dict(): - await test_create_certificate_map_entry_async(request_type=dict) - - -def test_create_certificate_map_entry_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.CreateCertificateMapEntryRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate_map_entry), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_certificate_map_entry(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_certificate_map_entry_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.CreateCertificateMapEntryRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate_map_entry), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_certificate_map_entry(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_certificate_map_entry_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate_map_entry), - '__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_certificate_map_entry( - parent='parent_value', - certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), - certificate_map_entry_id='certificate_map_entry_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].certificate_map_entry - mock_val = certificate_manager.CertificateMapEntry(name='name_value') - assert arg == mock_val - arg = args[0].certificate_map_entry_id - mock_val = 'certificate_map_entry_id_value' - assert arg == mock_val - - -def test_create_certificate_map_entry_flattened_error(): - client = CertificateManagerClient( - 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_certificate_map_entry( - certificate_manager.CreateCertificateMapEntryRequest(), - parent='parent_value', - certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), - certificate_map_entry_id='certificate_map_entry_id_value', - ) - -@pytest.mark.asyncio -async def test_create_certificate_map_entry_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate_map_entry), - '__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_certificate_map_entry( - parent='parent_value', - certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), - certificate_map_entry_id='certificate_map_entry_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].certificate_map_entry - mock_val = certificate_manager.CertificateMapEntry(name='name_value') - assert arg == mock_val - arg = args[0].certificate_map_entry_id - mock_val = 'certificate_map_entry_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_certificate_map_entry_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_map_entry( - certificate_manager.CreateCertificateMapEntryRequest(), - parent='parent_value', - certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), - certificate_map_entry_id='certificate_map_entry_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.UpdateCertificateMapEntryRequest, - dict, -]) -def test_update_certificate_map_entry(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_map_entry), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_certificate_map_entry(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.UpdateCertificateMapEntryRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_certificate_map_entry_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 = CertificateManagerClient( - 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_certificate_map_entry), - '__call__') as call: - client.update_certificate_map_entry() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.UpdateCertificateMapEntryRequest() - -@pytest.mark.asyncio -async def test_update_certificate_map_entry_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.UpdateCertificateMapEntryRequest): - client = CertificateManagerAsyncClient( - 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_certificate_map_entry), - '__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_certificate_map_entry(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.UpdateCertificateMapEntryRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_certificate_map_entry_async_from_dict(): - await test_update_certificate_map_entry_async(request_type=dict) - - -def test_update_certificate_map_entry_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.UpdateCertificateMapEntryRequest() - - request.certificate_map_entry.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_map_entry), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_certificate_map_entry(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', - 'certificate_map_entry.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_certificate_map_entry_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.UpdateCertificateMapEntryRequest() - - request.certificate_map_entry.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_map_entry), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_certificate_map_entry(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', - 'certificate_map_entry.name=name_value', - ) in kw['metadata'] - - -def test_update_certificate_map_entry_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_map_entry), - '__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_certificate_map_entry( - certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].certificate_map_entry - mock_val = certificate_manager.CertificateMapEntry(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_certificate_map_entry_flattened_error(): - client = CertificateManagerClient( - 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_certificate_map_entry( - certificate_manager.UpdateCertificateMapEntryRequest(), - certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_certificate_map_entry_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_map_entry), - '__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_certificate_map_entry( - certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].certificate_map_entry - mock_val = certificate_manager.CertificateMapEntry(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_certificate_map_entry_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_map_entry( - certificate_manager.UpdateCertificateMapEntryRequest(), - certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.DeleteCertificateMapEntryRequest, - dict, -]) -def test_delete_certificate_map_entry(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_map_entry), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_certificate_map_entry(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.DeleteCertificateMapEntryRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_certificate_map_entry_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 = CertificateManagerClient( - 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_certificate_map_entry), - '__call__') as call: - client.delete_certificate_map_entry() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.DeleteCertificateMapEntryRequest() - -@pytest.mark.asyncio -async def test_delete_certificate_map_entry_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.DeleteCertificateMapEntryRequest): - client = CertificateManagerAsyncClient( - 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_certificate_map_entry), - '__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_certificate_map_entry(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.DeleteCertificateMapEntryRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_certificate_map_entry_async_from_dict(): - await test_delete_certificate_map_entry_async(request_type=dict) - - -def test_delete_certificate_map_entry_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.DeleteCertificateMapEntryRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate_map_entry), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_certificate_map_entry(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_certificate_map_entry_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.DeleteCertificateMapEntryRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate_map_entry), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_certificate_map_entry(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_certificate_map_entry_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate_map_entry), - '__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_certificate_map_entry( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_certificate_map_entry_flattened_error(): - client = CertificateManagerClient( - 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_certificate_map_entry( - certificate_manager.DeleteCertificateMapEntryRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_certificate_map_entry_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate_map_entry), - '__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_certificate_map_entry( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_certificate_map_entry_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_map_entry( - certificate_manager.DeleteCertificateMapEntryRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.ListDnsAuthorizationsRequest, - dict, -]) -def test_list_dns_authorizations(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_dns_authorizations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.ListDnsAuthorizationsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_dns_authorizations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.ListDnsAuthorizationsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDnsAuthorizationsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_dns_authorizations_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 = CertificateManagerClient( - 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_dns_authorizations), - '__call__') as call: - client.list_dns_authorizations() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.ListDnsAuthorizationsRequest() - -@pytest.mark.asyncio -async def test_list_dns_authorizations_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.ListDnsAuthorizationsRequest): - client = CertificateManagerAsyncClient( - 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_dns_authorizations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListDnsAuthorizationsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_dns_authorizations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.ListDnsAuthorizationsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDnsAuthorizationsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_dns_authorizations_async_from_dict(): - await test_list_dns_authorizations_async(request_type=dict) - - -def test_list_dns_authorizations_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.ListDnsAuthorizationsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_dns_authorizations), - '__call__') as call: - call.return_value = certificate_manager.ListDnsAuthorizationsResponse() - client.list_dns_authorizations(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_dns_authorizations_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.ListDnsAuthorizationsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_dns_authorizations), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListDnsAuthorizationsResponse()) - await client.list_dns_authorizations(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_dns_authorizations_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_dns_authorizations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.ListDnsAuthorizationsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_dns_authorizations( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_dns_authorizations_flattened_error(): - client = CertificateManagerClient( - 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_dns_authorizations( - certificate_manager.ListDnsAuthorizationsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_dns_authorizations_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_dns_authorizations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.ListDnsAuthorizationsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.ListDnsAuthorizationsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_dns_authorizations( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_dns_authorizations_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_dns_authorizations( - certificate_manager.ListDnsAuthorizationsRequest(), - parent='parent_value', - ) - - -def test_list_dns_authorizations_pager(transport_name: str = "grpc"): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_dns_authorizations), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - ], - next_page_token='abc', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[], - next_page_token='def', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - ], - next_page_token='ghi', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_dns_authorizations(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, certificate_manager.DnsAuthorization) - for i in results) -def test_list_dns_authorizations_pages(transport_name: str = "grpc"): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_dns_authorizations), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - ], - next_page_token='abc', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[], - next_page_token='def', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - ], - next_page_token='ghi', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - ], - ), - RuntimeError, - ) - pages = list(client.list_dns_authorizations(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_dns_authorizations_async_pager(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_dns_authorizations), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - ], - next_page_token='abc', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[], - next_page_token='def', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - ], - next_page_token='ghi', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_dns_authorizations(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, certificate_manager.DnsAuthorization) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_dns_authorizations_async_pages(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_dns_authorizations), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - ], - next_page_token='abc', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[], - next_page_token='def', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - ], - next_page_token='ghi', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_dns_authorizations(request={})).pages: # pragma: no branch - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - certificate_manager.GetDnsAuthorizationRequest, - dict, -]) -def test_get_dns_authorization(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_dns_authorization), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.DnsAuthorization( - name='name_value', - description='description_value', - domain='domain_value', - ) - response = client.get_dns_authorization(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.GetDnsAuthorizationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_manager.DnsAuthorization) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.domain == 'domain_value' - - -def test_get_dns_authorization_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 = CertificateManagerClient( - 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_dns_authorization), - '__call__') as call: - client.get_dns_authorization() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.GetDnsAuthorizationRequest() - -@pytest.mark.asyncio -async def test_get_dns_authorization_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.GetDnsAuthorizationRequest): - client = CertificateManagerAsyncClient( - 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_dns_authorization), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.DnsAuthorization( - name='name_value', - description='description_value', - domain='domain_value', - )) - response = await client.get_dns_authorization(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.GetDnsAuthorizationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_manager.DnsAuthorization) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.domain == 'domain_value' - - -@pytest.mark.asyncio -async def test_get_dns_authorization_async_from_dict(): - await test_get_dns_authorization_async(request_type=dict) - - -def test_get_dns_authorization_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.GetDnsAuthorizationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_dns_authorization), - '__call__') as call: - call.return_value = certificate_manager.DnsAuthorization() - client.get_dns_authorization(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_dns_authorization_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.GetDnsAuthorizationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_dns_authorization), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.DnsAuthorization()) - await client.get_dns_authorization(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_dns_authorization_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_dns_authorization), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.DnsAuthorization() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_dns_authorization( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_dns_authorization_flattened_error(): - client = CertificateManagerClient( - 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_dns_authorization( - certificate_manager.GetDnsAuthorizationRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_dns_authorization_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_dns_authorization), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_manager.DnsAuthorization() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_manager.DnsAuthorization()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_dns_authorization( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_dns_authorization_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_dns_authorization( - certificate_manager.GetDnsAuthorizationRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.CreateDnsAuthorizationRequest, - dict, -]) -def test_create_dns_authorization(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_dns_authorization), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_dns_authorization(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.CreateDnsAuthorizationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_dns_authorization_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 = CertificateManagerClient( - 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_dns_authorization), - '__call__') as call: - client.create_dns_authorization() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.CreateDnsAuthorizationRequest() - -@pytest.mark.asyncio -async def test_create_dns_authorization_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.CreateDnsAuthorizationRequest): - client = CertificateManagerAsyncClient( - 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_dns_authorization), - '__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_dns_authorization(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.CreateDnsAuthorizationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_dns_authorization_async_from_dict(): - await test_create_dns_authorization_async(request_type=dict) - - -def test_create_dns_authorization_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.CreateDnsAuthorizationRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_dns_authorization), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_dns_authorization(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_dns_authorization_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.CreateDnsAuthorizationRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_dns_authorization), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_dns_authorization(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_dns_authorization_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_dns_authorization), - '__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_dns_authorization( - parent='parent_value', - dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), - dns_authorization_id='dns_authorization_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].dns_authorization - mock_val = certificate_manager.DnsAuthorization(name='name_value') - assert arg == mock_val - arg = args[0].dns_authorization_id - mock_val = 'dns_authorization_id_value' - assert arg == mock_val - - -def test_create_dns_authorization_flattened_error(): - client = CertificateManagerClient( - 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_dns_authorization( - certificate_manager.CreateDnsAuthorizationRequest(), - parent='parent_value', - dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), - dns_authorization_id='dns_authorization_id_value', - ) - -@pytest.mark.asyncio -async def test_create_dns_authorization_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_dns_authorization), - '__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_dns_authorization( - parent='parent_value', - dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), - dns_authorization_id='dns_authorization_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].dns_authorization - mock_val = certificate_manager.DnsAuthorization(name='name_value') - assert arg == mock_val - arg = args[0].dns_authorization_id - mock_val = 'dns_authorization_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_dns_authorization_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_dns_authorization( - certificate_manager.CreateDnsAuthorizationRequest(), - parent='parent_value', - dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), - dns_authorization_id='dns_authorization_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.UpdateDnsAuthorizationRequest, - dict, -]) -def test_update_dns_authorization(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_dns_authorization), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_dns_authorization(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.UpdateDnsAuthorizationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_dns_authorization_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 = CertificateManagerClient( - 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_dns_authorization), - '__call__') as call: - client.update_dns_authorization() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.UpdateDnsAuthorizationRequest() - -@pytest.mark.asyncio -async def test_update_dns_authorization_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.UpdateDnsAuthorizationRequest): - client = CertificateManagerAsyncClient( - 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_dns_authorization), - '__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_dns_authorization(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.UpdateDnsAuthorizationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_dns_authorization_async_from_dict(): - await test_update_dns_authorization_async(request_type=dict) - - -def test_update_dns_authorization_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.UpdateDnsAuthorizationRequest() - - request.dns_authorization.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_dns_authorization), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_dns_authorization(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', - 'dns_authorization.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_dns_authorization_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.UpdateDnsAuthorizationRequest() - - request.dns_authorization.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_dns_authorization), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_dns_authorization(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', - 'dns_authorization.name=name_value', - ) in kw['metadata'] - - -def test_update_dns_authorization_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_dns_authorization), - '__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_dns_authorization( - dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].dns_authorization - mock_val = certificate_manager.DnsAuthorization(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_dns_authorization_flattened_error(): - client = CertificateManagerClient( - 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_dns_authorization( - certificate_manager.UpdateDnsAuthorizationRequest(), - dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_dns_authorization_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_dns_authorization), - '__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_dns_authorization( - dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].dns_authorization - mock_val = certificate_manager.DnsAuthorization(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_dns_authorization_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_dns_authorization( - certificate_manager.UpdateDnsAuthorizationRequest(), - dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.DeleteDnsAuthorizationRequest, - dict, -]) -def test_delete_dns_authorization(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_dns_authorization), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_dns_authorization(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.DeleteDnsAuthorizationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_dns_authorization_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 = CertificateManagerClient( - 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_dns_authorization), - '__call__') as call: - client.delete_dns_authorization() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.DeleteDnsAuthorizationRequest() - -@pytest.mark.asyncio -async def test_delete_dns_authorization_async(transport: str = 'grpc_asyncio', request_type=certificate_manager.DeleteDnsAuthorizationRequest): - client = CertificateManagerAsyncClient( - 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_dns_authorization), - '__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_dns_authorization(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_manager.DeleteDnsAuthorizationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_dns_authorization_async_from_dict(): - await test_delete_dns_authorization_async(request_type=dict) - - -def test_delete_dns_authorization_field_headers(): - client = CertificateManagerClient( - 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 = certificate_manager.DeleteDnsAuthorizationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_dns_authorization), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_dns_authorization(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_dns_authorization_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_manager.DeleteDnsAuthorizationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_dns_authorization), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_dns_authorization(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_dns_authorization_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_dns_authorization), - '__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_dns_authorization( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_dns_authorization_flattened_error(): - client = CertificateManagerClient( - 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_dns_authorization( - certificate_manager.DeleteDnsAuthorizationRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_dns_authorization_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_dns_authorization), - '__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_dns_authorization( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_dns_authorization_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_dns_authorization( - certificate_manager.DeleteDnsAuthorizationRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_issuance_config.ListCertificateIssuanceConfigsRequest, - dict, -]) -def test_list_certificate_issuance_configs(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_issuance_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_certificate_issuance_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_issuance_config.ListCertificateIssuanceConfigsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateIssuanceConfigsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificate_issuance_configs_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 = CertificateManagerClient( - 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_certificate_issuance_configs), - '__call__') as call: - client.list_certificate_issuance_configs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_issuance_config.ListCertificateIssuanceConfigsRequest() - -@pytest.mark.asyncio -async def test_list_certificate_issuance_configs_async(transport: str = 'grpc_asyncio', request_type=certificate_issuance_config.ListCertificateIssuanceConfigsRequest): - client = CertificateManagerAsyncClient( - 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_certificate_issuance_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_certificate_issuance_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_issuance_config.ListCertificateIssuanceConfigsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateIssuanceConfigsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_certificate_issuance_configs_async_from_dict(): - await test_list_certificate_issuance_configs_async(request_type=dict) - - -def test_list_certificate_issuance_configs_field_headers(): - client = CertificateManagerClient( - 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 = certificate_issuance_config.ListCertificateIssuanceConfigsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_issuance_configs), - '__call__') as call: - call.return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() - client.list_certificate_issuance_configs(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_certificate_issuance_configs_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_issuance_config.ListCertificateIssuanceConfigsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_issuance_configs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_issuance_config.ListCertificateIssuanceConfigsResponse()) - await client.list_certificate_issuance_configs(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_certificate_issuance_configs_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_issuance_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_certificate_issuance_configs( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_certificate_issuance_configs_flattened_error(): - client = CertificateManagerClient( - 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_certificate_issuance_configs( - certificate_issuance_config.ListCertificateIssuanceConfigsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_certificate_issuance_configs_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_issuance_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_issuance_config.ListCertificateIssuanceConfigsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_certificate_issuance_configs( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_certificate_issuance_configs_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_issuance_configs( - certificate_issuance_config.ListCertificateIssuanceConfigsRequest(), - parent='parent_value', - ) - - -def test_list_certificate_issuance_configs_pager(transport_name: str = "grpc"): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_issuance_configs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - ], - next_page_token='abc', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[], - next_page_token='def', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - ], - next_page_token='ghi', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_certificate_issuance_configs(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, certificate_issuance_config.CertificateIssuanceConfig) - for i in results) -def test_list_certificate_issuance_configs_pages(transport_name: str = "grpc"): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_issuance_configs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - ], - next_page_token='abc', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[], - next_page_token='def', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - ], - next_page_token='ghi', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - ], - ), - RuntimeError, - ) - pages = list(client.list_certificate_issuance_configs(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_certificate_issuance_configs_async_pager(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_issuance_configs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - ], - next_page_token='abc', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[], - next_page_token='def', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - ], - next_page_token='ghi', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_certificate_issuance_configs(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, certificate_issuance_config.CertificateIssuanceConfig) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_certificate_issuance_configs_async_pages(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_certificate_issuance_configs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - ], - next_page_token='abc', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[], - next_page_token='def', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - ], - next_page_token='ghi', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_certificate_issuance_configs(request={})).pages: # pragma: no branch - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - certificate_issuance_config.GetCertificateIssuanceConfigRequest, - dict, -]) -def test_get_certificate_issuance_config(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_issuance_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_issuance_config.CertificateIssuanceConfig( - name='name_value', - description='description_value', - rotation_window_percentage=2788, - key_algorithm=certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048, - ) - response = client.get_certificate_issuance_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_issuance_config.GetCertificateIssuanceConfigRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_issuance_config.CertificateIssuanceConfig) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.rotation_window_percentage == 2788 - assert response.key_algorithm == certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048 - - -def test_get_certificate_issuance_config_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 = CertificateManagerClient( - 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_certificate_issuance_config), - '__call__') as call: - client.get_certificate_issuance_config() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_issuance_config.GetCertificateIssuanceConfigRequest() - -@pytest.mark.asyncio -async def test_get_certificate_issuance_config_async(transport: str = 'grpc_asyncio', request_type=certificate_issuance_config.GetCertificateIssuanceConfigRequest): - client = CertificateManagerAsyncClient( - 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_certificate_issuance_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(certificate_issuance_config.CertificateIssuanceConfig( - name='name_value', - description='description_value', - rotation_window_percentage=2788, - key_algorithm=certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048, - )) - response = await client.get_certificate_issuance_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_issuance_config.GetCertificateIssuanceConfigRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_issuance_config.CertificateIssuanceConfig) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.rotation_window_percentage == 2788 - assert response.key_algorithm == certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048 - - -@pytest.mark.asyncio -async def test_get_certificate_issuance_config_async_from_dict(): - await test_get_certificate_issuance_config_async(request_type=dict) - - -def test_get_certificate_issuance_config_field_headers(): - client = CertificateManagerClient( - 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 = certificate_issuance_config.GetCertificateIssuanceConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate_issuance_config), - '__call__') as call: - call.return_value = certificate_issuance_config.CertificateIssuanceConfig() - client.get_certificate_issuance_config(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_certificate_issuance_config_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_issuance_config.GetCertificateIssuanceConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate_issuance_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_issuance_config.CertificateIssuanceConfig()) - await client.get_certificate_issuance_config(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_certificate_issuance_config_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate_issuance_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_issuance_config.CertificateIssuanceConfig() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_certificate_issuance_config( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_certificate_issuance_config_flattened_error(): - client = CertificateManagerClient( - 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_certificate_issuance_config( - certificate_issuance_config.GetCertificateIssuanceConfigRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_certificate_issuance_config_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_certificate_issuance_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = certificate_issuance_config.CertificateIssuanceConfig() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(certificate_issuance_config.CertificateIssuanceConfig()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_certificate_issuance_config( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_certificate_issuance_config_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_issuance_config( - certificate_issuance_config.GetCertificateIssuanceConfigRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, - dict, -]) -def test_create_certificate_issuance_config(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_issuance_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_certificate_issuance_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_certificate_issuance_config_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 = CertificateManagerClient( - 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_certificate_issuance_config), - '__call__') as call: - client.create_certificate_issuance_config() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() - -@pytest.mark.asyncio -async def test_create_certificate_issuance_config_async(transport: str = 'grpc_asyncio', request_type=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest): - client = CertificateManagerAsyncClient( - 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_certificate_issuance_config), - '__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_certificate_issuance_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_certificate_issuance_config_async_from_dict(): - await test_create_certificate_issuance_config_async(request_type=dict) - - -def test_create_certificate_issuance_config_field_headers(): - client = CertificateManagerClient( - 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 = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate_issuance_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_certificate_issuance_config(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_certificate_issuance_config_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate_issuance_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_certificate_issuance_config(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_certificate_issuance_config_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate_issuance_config), - '__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_certificate_issuance_config( - parent='parent_value', - certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value'), - certificate_issuance_config_id='certificate_issuance_config_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].certificate_issuance_config - mock_val = gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value') - assert arg == mock_val - arg = args[0].certificate_issuance_config_id - mock_val = 'certificate_issuance_config_id_value' - assert arg == mock_val - - -def test_create_certificate_issuance_config_flattened_error(): - client = CertificateManagerClient( - 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_certificate_issuance_config( - gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest(), - parent='parent_value', - certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value'), - certificate_issuance_config_id='certificate_issuance_config_id_value', - ) - -@pytest.mark.asyncio -async def test_create_certificate_issuance_config_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_certificate_issuance_config), - '__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_certificate_issuance_config( - parent='parent_value', - certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value'), - certificate_issuance_config_id='certificate_issuance_config_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].certificate_issuance_config - mock_val = gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value') - assert arg == mock_val - arg = args[0].certificate_issuance_config_id - mock_val = 'certificate_issuance_config_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_certificate_issuance_config_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_issuance_config( - gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest(), - parent='parent_value', - certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value'), - certificate_issuance_config_id='certificate_issuance_config_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, - dict, -]) -def test_delete_certificate_issuance_config(request_type, transport: str = 'grpc'): - client = CertificateManagerClient( - 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_certificate_issuance_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_certificate_issuance_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_certificate_issuance_config_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 = CertificateManagerClient( - 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_certificate_issuance_config), - '__call__') as call: - client.delete_certificate_issuance_config() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() - -@pytest.mark.asyncio -async def test_delete_certificate_issuance_config_async(transport: str = 'grpc_asyncio', request_type=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest): - client = CertificateManagerAsyncClient( - 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_certificate_issuance_config), - '__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_certificate_issuance_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_certificate_issuance_config_async_from_dict(): - await test_delete_certificate_issuance_config_async(request_type=dict) - - -def test_delete_certificate_issuance_config_field_headers(): - client = CertificateManagerClient( - 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 = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate_issuance_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_certificate_issuance_config(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_certificate_issuance_config_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate_issuance_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_certificate_issuance_config(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_certificate_issuance_config_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate_issuance_config), - '__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_certificate_issuance_config( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_certificate_issuance_config_flattened_error(): - client = CertificateManagerClient( - 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_certificate_issuance_config( - certificate_issuance_config.DeleteCertificateIssuanceConfigRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_certificate_issuance_config_flattened_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_certificate_issuance_config), - '__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_certificate_issuance_config( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_certificate_issuance_config_flattened_error_async(): - client = CertificateManagerAsyncClient( - 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_certificate_issuance_config( - certificate_issuance_config.DeleteCertificateIssuanceConfigRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.ListCertificatesRequest, - dict, -]) -def test_list_certificates_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.ListCertificatesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.ListCertificatesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_certificates(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificatesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificates_rest_required_fields(request_type=certificate_manager.ListCertificatesRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificates._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificates._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = certificate_manager.ListCertificatesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = certificate_manager.ListCertificatesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_certificates(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_certificates_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_certificates._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_certificates_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_list_certificates") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_list_certificates") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.ListCertificatesRequest.pb(certificate_manager.ListCertificatesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = certificate_manager.ListCertificatesResponse.to_json(certificate_manager.ListCertificatesResponse()) - - request = certificate_manager.ListCertificatesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = certificate_manager.ListCertificatesResponse() - - client.list_certificates(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_certificates_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.ListCertificatesRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_certificates(request) - - -def test_list_certificates_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.ListCertificatesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.ListCertificatesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_certificates(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/certificates" % client.transport._host, args[1]) - - -def test_list_certificates_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_certificates( - certificate_manager.ListCertificatesRequest(), - parent='parent_value', - ) - - -def test_list_certificates_rest_pager(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - certificate_manager.Certificate(), - certificate_manager.Certificate(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificatesResponse( - certificates=[ - certificate_manager.Certificate(), - certificate_manager.Certificate(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(certificate_manager.ListCertificatesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_certificates(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, certificate_manager.Certificate) - for i in results) - - pages = list(client.list_certificates(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.GetCertificateRequest, - dict, -]) -def test_get_certificate_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificates/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.Certificate( - name='name_value', - description='description_value', - san_dnsnames=['san_dnsnames_value'], - pem_certificate='pem_certificate_value', - scope=certificate_manager.Certificate.Scope.EDGE_CACHE, - self_managed=certificate_manager.Certificate.SelfManagedCertificate(pem_certificate='pem_certificate_value'), - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.Certificate.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_certificate(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_manager.Certificate) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.san_dnsnames == ['san_dnsnames_value'] - assert response.pem_certificate == 'pem_certificate_value' - assert response.scope == certificate_manager.Certificate.Scope.EDGE_CACHE - - -def test_get_certificate_rest_required_fields(request_type=certificate_manager.GetCertificateRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = certificate_manager.Certificate() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = certificate_manager.Certificate.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_certificate(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_certificate_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_certificate._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_certificate_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_get_certificate") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_get_certificate") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.GetCertificateRequest.pb(certificate_manager.GetCertificateRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = certificate_manager.Certificate.to_json(certificate_manager.Certificate()) - - request = certificate_manager.GetCertificateRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = certificate_manager.Certificate() - - client.get_certificate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_certificate_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.GetCertificateRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificates/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_certificate(request) - - -def test_get_certificate_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.Certificate() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/certificates/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.Certificate.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_certificate(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificates/*}" % client.transport._host, args[1]) - - -def test_get_certificate_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_certificate( - certificate_manager.GetCertificateRequest(), - name='name_value', - ) - - -def test_get_certificate_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.CreateCertificateRequest, - dict, -]) -def test_create_certificate_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["certificate"] = {'name': 'name_value', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'self_managed': {'pem_certificate': 'pem_certificate_value', 'pem_private_key': 'pem_private_key_value'}, 'managed': {'domains': ['domains_value1', 'domains_value2'], 'dns_authorizations': ['dns_authorizations_value1', 'dns_authorizations_value2'], 'issuance_config': 'issuance_config_value', 'state': 1, 'provisioning_issue': {'reason': 1, 'details': 'details_value'}, 'authorization_attempt_info': [{'domain': 'domain_value', 'state': 1, 'failure_reason': 1, 'details': 'details_value'}]}, 'san_dnsnames': ['san_dnsnames_value1', 'san_dnsnames_value2'], 'pem_certificate': 'pem_certificate_value', 'expire_time': {}, 'scope': 1} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_certificate(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_create_certificate_rest_required_fields(request_type=certificate_manager.CreateCertificateRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["certificate_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - assert "certificateId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "certificateId" in jsonified_request - assert jsonified_request["certificateId"] == request_init["certificate_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["certificateId"] = 'certificate_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("certificate_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "certificateId" in jsonified_request - assert jsonified_request["certificateId"] == 'certificate_id_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_certificate(request) - - expected_params = [ - ( - "certificateId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_certificate_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_certificate._get_unset_required_fields({}) - assert set(unset_fields) == (set(("certificateId", )) & set(("parent", "certificateId", "certificate", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_certificate_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_create_certificate") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_create_certificate") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.CreateCertificateRequest.pb(certificate_manager.CreateCertificateRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_manager.CreateCertificateRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.create_certificate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_certificate_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.CreateCertificateRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["certificate"] = {'name': 'name_value', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'self_managed': {'pem_certificate': 'pem_certificate_value', 'pem_private_key': 'pem_private_key_value'}, 'managed': {'domains': ['domains_value1', 'domains_value2'], 'dns_authorizations': ['dns_authorizations_value1', 'dns_authorizations_value2'], 'issuance_config': 'issuance_config_value', 'state': 1, 'provisioning_issue': {'reason': 1, 'details': 'details_value'}, 'authorization_attempt_info': [{'domain': 'domain_value', 'state': 1, 'failure_reason': 1, 'details': 'details_value'}]}, 'san_dnsnames': ['san_dnsnames_value1', 'san_dnsnames_value2'], 'pem_certificate': 'pem_certificate_value', 'expire_time': {}, 'scope': 1} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.create_certificate(request) - - -def test_create_certificate_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - certificate=certificate_manager.Certificate(name='name_value'), - certificate_id='certificate_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_certificate(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/certificates" % client.transport._host, args[1]) - - -def test_create_certificate_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_certificate( - certificate_manager.CreateCertificateRequest(), - parent='parent_value', - certificate=certificate_manager.Certificate(name='name_value'), - certificate_id='certificate_id_value', - ) - - -def test_create_certificate_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.UpdateCertificateRequest, - dict, -]) -def test_update_certificate_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'certificate': {'name': 'projects/sample1/locations/sample2/certificates/sample3'}} - request_init["certificate"] = {'name': 'projects/sample1/locations/sample2/certificates/sample3', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'self_managed': {'pem_certificate': 'pem_certificate_value', 'pem_private_key': 'pem_private_key_value'}, 'managed': {'domains': ['domains_value1', 'domains_value2'], 'dns_authorizations': ['dns_authorizations_value1', 'dns_authorizations_value2'], 'issuance_config': 'issuance_config_value', 'state': 1, 'provisioning_issue': {'reason': 1, 'details': 'details_value'}, 'authorization_attempt_info': [{'domain': 'domain_value', 'state': 1, 'failure_reason': 1, 'details': 'details_value'}]}, 'san_dnsnames': ['san_dnsnames_value1', 'san_dnsnames_value2'], 'pem_certificate': 'pem_certificate_value', 'expire_time': {}, 'scope': 1} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_certificate(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_update_certificate_rest_required_fields(request_type=certificate_manager.UpdateCertificateRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_certificate._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_certificate._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_certificate(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_certificate_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_certificate._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("certificate", "updateMask", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_certificate_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_update_certificate") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_update_certificate") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.UpdateCertificateRequest.pb(certificate_manager.UpdateCertificateRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_manager.UpdateCertificateRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.update_certificate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_certificate_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.UpdateCertificateRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'certificate': {'name': 'projects/sample1/locations/sample2/certificates/sample3'}} - request_init["certificate"] = {'name': 'projects/sample1/locations/sample2/certificates/sample3', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'self_managed': {'pem_certificate': 'pem_certificate_value', 'pem_private_key': 'pem_private_key_value'}, 'managed': {'domains': ['domains_value1', 'domains_value2'], 'dns_authorizations': ['dns_authorizations_value1', 'dns_authorizations_value2'], 'issuance_config': 'issuance_config_value', 'state': 1, 'provisioning_issue': {'reason': 1, 'details': 'details_value'}, 'authorization_attempt_info': [{'domain': 'domain_value', 'state': 1, 'failure_reason': 1, 'details': 'details_value'}]}, 'san_dnsnames': ['san_dnsnames_value1', 'san_dnsnames_value2'], 'pem_certificate': 'pem_certificate_value', 'expire_time': {}, 'scope': 1} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.update_certificate(request) - - -def test_update_certificate_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'certificate': {'name': 'projects/sample1/locations/sample2/certificates/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - certificate=certificate_manager.Certificate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_certificate(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{certificate.name=projects/*/locations/*/certificates/*}" % client.transport._host, args[1]) - - -def test_update_certificate_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_certificate( - certificate_manager.UpdateCertificateRequest(), - certificate=certificate_manager.Certificate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_update_certificate_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.DeleteCertificateRequest, - dict, -]) -def test_delete_certificate_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificates/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_certificate(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_delete_certificate_rest_required_fields(request_type=certificate_manager.DeleteCertificateRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_certificate(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_certificate_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_certificate._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_certificate_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_delete_certificate") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_delete_certificate") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.DeleteCertificateRequest.pb(certificate_manager.DeleteCertificateRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_manager.DeleteCertificateRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_certificate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_certificate_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.DeleteCertificateRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificates/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_certificate(request) - - -def test_delete_certificate_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/certificates/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_certificate(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificates/*}" % client.transport._host, args[1]) - - -def test_delete_certificate_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_certificate( - certificate_manager.DeleteCertificateRequest(), - name='name_value', - ) - - -def test_delete_certificate_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.ListCertificateMapsRequest, - dict, -]) -def test_list_certificate_maps_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.ListCertificateMapsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.ListCertificateMapsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_certificate_maps(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateMapsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificate_maps_rest_required_fields(request_type=certificate_manager.ListCertificateMapsRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificate_maps._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificate_maps._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = certificate_manager.ListCertificateMapsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = certificate_manager.ListCertificateMapsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_certificate_maps(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_certificate_maps_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_certificate_maps._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_certificate_maps_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_list_certificate_maps") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_list_certificate_maps") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.ListCertificateMapsRequest.pb(certificate_manager.ListCertificateMapsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = certificate_manager.ListCertificateMapsResponse.to_json(certificate_manager.ListCertificateMapsResponse()) - - request = certificate_manager.ListCertificateMapsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = certificate_manager.ListCertificateMapsResponse() - - client.list_certificate_maps(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_certificate_maps_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.ListCertificateMapsRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_certificate_maps(request) - - -def test_list_certificate_maps_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.ListCertificateMapsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.ListCertificateMapsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_certificate_maps(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/certificateMaps" % client.transport._host, args[1]) - - -def test_list_certificate_maps_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_certificate_maps( - certificate_manager.ListCertificateMapsRequest(), - parent='parent_value', - ) - - -def test_list_certificate_maps_rest_pager(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[], - next_page_token='def', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificateMapsResponse( - certificate_maps=[ - certificate_manager.CertificateMap(), - certificate_manager.CertificateMap(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(certificate_manager.ListCertificateMapsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_certificate_maps(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, certificate_manager.CertificateMap) - for i in results) - - pages = list(client.list_certificate_maps(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.GetCertificateMapRequest, - dict, -]) -def test_get_certificate_map_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.CertificateMap( - name='name_value', - description='description_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.CertificateMap.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_certificate_map(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_manager.CertificateMap) - assert response.name == 'name_value' - assert response.description == 'description_value' - - -def test_get_certificate_map_rest_required_fields(request_type=certificate_manager.GetCertificateMapRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate_map._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate_map._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = certificate_manager.CertificateMap() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = certificate_manager.CertificateMap.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_certificate_map(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_certificate_map_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_certificate_map._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_certificate_map_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_get_certificate_map") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_get_certificate_map") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.GetCertificateMapRequest.pb(certificate_manager.GetCertificateMapRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = certificate_manager.CertificateMap.to_json(certificate_manager.CertificateMap()) - - request = certificate_manager.GetCertificateMapRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = certificate_manager.CertificateMap() - - client.get_certificate_map(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_certificate_map_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.GetCertificateMapRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_certificate_map(request) - - -def test_get_certificate_map_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.CertificateMap() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.CertificateMap.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_certificate_map(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificateMaps/*}" % client.transport._host, args[1]) - - -def test_get_certificate_map_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_certificate_map( - certificate_manager.GetCertificateMapRequest(), - name='name_value', - ) - - -def test_get_certificate_map_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.CreateCertificateMapRequest, - dict, -]) -def test_create_certificate_map_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["certificate_map"] = {'name': 'name_value', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'gclb_targets': [{'target_https_proxy': 'target_https_proxy_value', 'target_ssl_proxy': 'target_ssl_proxy_value', 'ip_configs': [{'ip_address': 'ip_address_value', 'ports': [569, 570]}]}]} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_certificate_map(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_create_certificate_map_rest_required_fields(request_type=certificate_manager.CreateCertificateMapRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["certificate_map_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - assert "certificateMapId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate_map._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "certificateMapId" in jsonified_request - assert jsonified_request["certificateMapId"] == request_init["certificate_map_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["certificateMapId"] = 'certificate_map_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate_map._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("certificate_map_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "certificateMapId" in jsonified_request - assert jsonified_request["certificateMapId"] == 'certificate_map_id_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_certificate_map(request) - - expected_params = [ - ( - "certificateMapId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_certificate_map_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_certificate_map._get_unset_required_fields({}) - assert set(unset_fields) == (set(("certificateMapId", )) & set(("parent", "certificateMapId", "certificateMap", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_certificate_map_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_create_certificate_map") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_create_certificate_map") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.CreateCertificateMapRequest.pb(certificate_manager.CreateCertificateMapRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_manager.CreateCertificateMapRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.create_certificate_map(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_certificate_map_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.CreateCertificateMapRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["certificate_map"] = {'name': 'name_value', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'gclb_targets': [{'target_https_proxy': 'target_https_proxy_value', 'target_ssl_proxy': 'target_ssl_proxy_value', 'ip_configs': [{'ip_address': 'ip_address_value', 'ports': [569, 570]}]}]} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.create_certificate_map(request) - - -def test_create_certificate_map_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - certificate_map=certificate_manager.CertificateMap(name='name_value'), - certificate_map_id='certificate_map_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_certificate_map(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/certificateMaps" % client.transport._host, args[1]) - - -def test_create_certificate_map_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_certificate_map( - certificate_manager.CreateCertificateMapRequest(), - parent='parent_value', - certificate_map=certificate_manager.CertificateMap(name='name_value'), - certificate_map_id='certificate_map_id_value', - ) - - -def test_create_certificate_map_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.UpdateCertificateMapRequest, - dict, -]) -def test_update_certificate_map_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'certificate_map': {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'}} - request_init["certificate_map"] = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'gclb_targets': [{'target_https_proxy': 'target_https_proxy_value', 'target_ssl_proxy': 'target_ssl_proxy_value', 'ip_configs': [{'ip_address': 'ip_address_value', 'ports': [569, 570]}]}]} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_certificate_map(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_update_certificate_map_rest_required_fields(request_type=certificate_manager.UpdateCertificateMapRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_certificate_map._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_certificate_map._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_certificate_map(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_certificate_map_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_certificate_map._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("certificateMap", "updateMask", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_certificate_map_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_update_certificate_map") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_update_certificate_map") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.UpdateCertificateMapRequest.pb(certificate_manager.UpdateCertificateMapRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_manager.UpdateCertificateMapRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.update_certificate_map(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_certificate_map_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.UpdateCertificateMapRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'certificate_map': {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'}} - request_init["certificate_map"] = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'gclb_targets': [{'target_https_proxy': 'target_https_proxy_value', 'target_ssl_proxy': 'target_ssl_proxy_value', 'ip_configs': [{'ip_address': 'ip_address_value', 'ports': [569, 570]}]}]} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.update_certificate_map(request) - - -def test_update_certificate_map_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'certificate_map': {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - certificate_map=certificate_manager.CertificateMap(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_certificate_map(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{certificate_map.name=projects/*/locations/*/certificateMaps/*}" % client.transport._host, args[1]) - - -def test_update_certificate_map_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_certificate_map( - certificate_manager.UpdateCertificateMapRequest(), - certificate_map=certificate_manager.CertificateMap(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_update_certificate_map_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.DeleteCertificateMapRequest, - dict, -]) -def test_delete_certificate_map_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_certificate_map(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_delete_certificate_map_rest_required_fields(request_type=certificate_manager.DeleteCertificateMapRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate_map._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate_map._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_certificate_map(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_certificate_map_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_certificate_map._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_certificate_map_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_delete_certificate_map") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_delete_certificate_map") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.DeleteCertificateMapRequest.pb(certificate_manager.DeleteCertificateMapRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_manager.DeleteCertificateMapRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_certificate_map(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_certificate_map_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.DeleteCertificateMapRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_certificate_map(request) - - -def test_delete_certificate_map_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_certificate_map(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificateMaps/*}" % client.transport._host, args[1]) - - -def test_delete_certificate_map_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_certificate_map( - certificate_manager.DeleteCertificateMapRequest(), - name='name_value', - ) - - -def test_delete_certificate_map_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.ListCertificateMapEntriesRequest, - dict, -]) -def test_list_certificate_map_entries_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.ListCertificateMapEntriesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.ListCertificateMapEntriesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_certificate_map_entries(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateMapEntriesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificate_map_entries_rest_required_fields(request_type=certificate_manager.ListCertificateMapEntriesRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificate_map_entries._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificate_map_entries._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = certificate_manager.ListCertificateMapEntriesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = certificate_manager.ListCertificateMapEntriesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_certificate_map_entries(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_certificate_map_entries_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_certificate_map_entries._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_certificate_map_entries_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_list_certificate_map_entries") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_list_certificate_map_entries") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.ListCertificateMapEntriesRequest.pb(certificate_manager.ListCertificateMapEntriesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = certificate_manager.ListCertificateMapEntriesResponse.to_json(certificate_manager.ListCertificateMapEntriesResponse()) - - request = certificate_manager.ListCertificateMapEntriesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = certificate_manager.ListCertificateMapEntriesResponse() - - client.list_certificate_map_entries(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_certificate_map_entries_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.ListCertificateMapEntriesRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_certificate_map_entries(request) - - -def test_list_certificate_map_entries_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.ListCertificateMapEntriesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.ListCertificateMapEntriesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_certificate_map_entries(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/certificateMaps/*}/certificateMapEntries" % client.transport._host, args[1]) - - -def test_list_certificate_map_entries_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_certificate_map_entries( - certificate_manager.ListCertificateMapEntriesRequest(), - parent='parent_value', - ) - - -def test_list_certificate_map_entries_rest_pager(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - ], - next_page_token='abc', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[], - next_page_token='def', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - ], - next_page_token='ghi', - ), - certificate_manager.ListCertificateMapEntriesResponse( - certificate_map_entries=[ - certificate_manager.CertificateMapEntry(), - certificate_manager.CertificateMapEntry(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(certificate_manager.ListCertificateMapEntriesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - - pager = client.list_certificate_map_entries(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, certificate_manager.CertificateMapEntry) - for i in results) - - pages = list(client.list_certificate_map_entries(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.GetCertificateMapEntryRequest, - dict, -]) -def test_get_certificate_map_entry_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.CertificateMapEntry( - name='name_value', - description='description_value', - certificates=['certificates_value'], - state=certificate_manager.ServingState.ACTIVE, - hostname='hostname_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.CertificateMapEntry.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_certificate_map_entry(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_manager.CertificateMapEntry) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.certificates == ['certificates_value'] - assert response.state == certificate_manager.ServingState.ACTIVE - - -def test_get_certificate_map_entry_rest_required_fields(request_type=certificate_manager.GetCertificateMapEntryRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate_map_entry._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate_map_entry._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = certificate_manager.CertificateMapEntry() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = certificate_manager.CertificateMapEntry.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_certificate_map_entry(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_certificate_map_entry_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_certificate_map_entry._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_certificate_map_entry_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_get_certificate_map_entry") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_get_certificate_map_entry") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.GetCertificateMapEntryRequest.pb(certificate_manager.GetCertificateMapEntryRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = certificate_manager.CertificateMapEntry.to_json(certificate_manager.CertificateMapEntry()) - - request = certificate_manager.GetCertificateMapEntryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = certificate_manager.CertificateMapEntry() - - client.get_certificate_map_entry(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_certificate_map_entry_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.GetCertificateMapEntryRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_certificate_map_entry(request) - - -def test_get_certificate_map_entry_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.CertificateMapEntry() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.CertificateMapEntry.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_certificate_map_entry(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}" % client.transport._host, args[1]) - - -def test_get_certificate_map_entry_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_certificate_map_entry( - certificate_manager.GetCertificateMapEntryRequest(), - name='name_value', - ) - - -def test_get_certificate_map_entry_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.CreateCertificateMapEntryRequest, - dict, -]) -def test_create_certificate_map_entry_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - request_init["certificate_map_entry"] = {'name': 'name_value', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'hostname': 'hostname_value', 'matcher': 1, 'certificates': ['certificates_value1', 'certificates_value2'], 'state': 1} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_certificate_map_entry(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_create_certificate_map_entry_rest_required_fields(request_type=certificate_manager.CreateCertificateMapEntryRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["certificate_map_entry_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - assert "certificateMapEntryId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate_map_entry._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "certificateMapEntryId" in jsonified_request - assert jsonified_request["certificateMapEntryId"] == request_init["certificate_map_entry_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["certificateMapEntryId"] = 'certificate_map_entry_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate_map_entry._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("certificate_map_entry_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "certificateMapEntryId" in jsonified_request - assert jsonified_request["certificateMapEntryId"] == 'certificate_map_entry_id_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_certificate_map_entry(request) - - expected_params = [ - ( - "certificateMapEntryId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_certificate_map_entry_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_certificate_map_entry._get_unset_required_fields({}) - assert set(unset_fields) == (set(("certificateMapEntryId", )) & set(("parent", "certificateMapEntryId", "certificateMapEntry", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_certificate_map_entry_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_create_certificate_map_entry") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_create_certificate_map_entry") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.CreateCertificateMapEntryRequest.pb(certificate_manager.CreateCertificateMapEntryRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_manager.CreateCertificateMapEntryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.create_certificate_map_entry(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_certificate_map_entry_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.CreateCertificateMapEntryRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - request_init["certificate_map_entry"] = {'name': 'name_value', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'hostname': 'hostname_value', 'matcher': 1, 'certificates': ['certificates_value1', 'certificates_value2'], 'state': 1} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.create_certificate_map_entry(request) - - -def test_create_certificate_map_entry_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/certificateMaps/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), - certificate_map_entry_id='certificate_map_entry_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_certificate_map_entry(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/certificateMaps/*}/certificateMapEntries" % client.transport._host, args[1]) - - -def test_create_certificate_map_entry_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_certificate_map_entry( - certificate_manager.CreateCertificateMapEntryRequest(), - parent='parent_value', - certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), - certificate_map_entry_id='certificate_map_entry_id_value', - ) - - -def test_create_certificate_map_entry_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.UpdateCertificateMapEntryRequest, - dict, -]) -def test_update_certificate_map_entry_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'certificate_map_entry': {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'}} - request_init["certificate_map_entry"] = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'hostname': 'hostname_value', 'matcher': 1, 'certificates': ['certificates_value1', 'certificates_value2'], 'state': 1} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_certificate_map_entry(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_update_certificate_map_entry_rest_required_fields(request_type=certificate_manager.UpdateCertificateMapEntryRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_certificate_map_entry._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_certificate_map_entry._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_certificate_map_entry(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_certificate_map_entry_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_certificate_map_entry._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("certificateMapEntry", "updateMask", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_certificate_map_entry_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_update_certificate_map_entry") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_update_certificate_map_entry") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.UpdateCertificateMapEntryRequest.pb(certificate_manager.UpdateCertificateMapEntryRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_manager.UpdateCertificateMapEntryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.update_certificate_map_entry(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_certificate_map_entry_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.UpdateCertificateMapEntryRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'certificate_map_entry': {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'}} - request_init["certificate_map_entry"] = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'hostname': 'hostname_value', 'matcher': 1, 'certificates': ['certificates_value1', 'certificates_value2'], 'state': 1} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.update_certificate_map_entry(request) - - -def test_update_certificate_map_entry_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'certificate_map_entry': {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'}} - - # get truthy value for each flattened field - mock_args = dict( - certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_certificate_map_entry(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{certificate_map_entry.name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}" % client.transport._host, args[1]) - - -def test_update_certificate_map_entry_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_certificate_map_entry( - certificate_manager.UpdateCertificateMapEntryRequest(), - certificate_map_entry=certificate_manager.CertificateMapEntry(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_update_certificate_map_entry_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.DeleteCertificateMapEntryRequest, - dict, -]) -def test_delete_certificate_map_entry_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_certificate_map_entry(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_delete_certificate_map_entry_rest_required_fields(request_type=certificate_manager.DeleteCertificateMapEntryRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate_map_entry._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate_map_entry._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_certificate_map_entry(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_certificate_map_entry_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_certificate_map_entry._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_certificate_map_entry_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_delete_certificate_map_entry") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_delete_certificate_map_entry") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.DeleteCertificateMapEntryRequest.pb(certificate_manager.DeleteCertificateMapEntryRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_manager.DeleteCertificateMapEntryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_certificate_map_entry(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_certificate_map_entry_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.DeleteCertificateMapEntryRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_certificate_map_entry(request) - - -def test_delete_certificate_map_entry_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_certificate_map_entry(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}" % client.transport._host, args[1]) - - -def test_delete_certificate_map_entry_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_certificate_map_entry( - certificate_manager.DeleteCertificateMapEntryRequest(), - name='name_value', - ) - - -def test_delete_certificate_map_entry_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.ListDnsAuthorizationsRequest, - dict, -]) -def test_list_dns_authorizations_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.ListDnsAuthorizationsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.ListDnsAuthorizationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_dns_authorizations(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDnsAuthorizationsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_dns_authorizations_rest_required_fields(request_type=certificate_manager.ListDnsAuthorizationsRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_dns_authorizations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_dns_authorizations._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = certificate_manager.ListDnsAuthorizationsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = certificate_manager.ListDnsAuthorizationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_dns_authorizations(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_dns_authorizations_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_dns_authorizations._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_dns_authorizations_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_list_dns_authorizations") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_list_dns_authorizations") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.ListDnsAuthorizationsRequest.pb(certificate_manager.ListDnsAuthorizationsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = certificate_manager.ListDnsAuthorizationsResponse.to_json(certificate_manager.ListDnsAuthorizationsResponse()) - - request = certificate_manager.ListDnsAuthorizationsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = certificate_manager.ListDnsAuthorizationsResponse() - - client.list_dns_authorizations(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_dns_authorizations_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.ListDnsAuthorizationsRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_dns_authorizations(request) - - -def test_list_dns_authorizations_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.ListDnsAuthorizationsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.ListDnsAuthorizationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_dns_authorizations(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/dnsAuthorizations" % client.transport._host, args[1]) - - -def test_list_dns_authorizations_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_dns_authorizations( - certificate_manager.ListDnsAuthorizationsRequest(), - parent='parent_value', - ) - - -def test_list_dns_authorizations_rest_pager(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - ], - next_page_token='abc', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[], - next_page_token='def', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - ], - next_page_token='ghi', - ), - certificate_manager.ListDnsAuthorizationsResponse( - dns_authorizations=[ - certificate_manager.DnsAuthorization(), - certificate_manager.DnsAuthorization(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(certificate_manager.ListDnsAuthorizationsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_dns_authorizations(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, certificate_manager.DnsAuthorization) - for i in results) - - pages = list(client.list_dns_authorizations(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.GetDnsAuthorizationRequest, - dict, -]) -def test_get_dns_authorization_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.DnsAuthorization( - name='name_value', - description='description_value', - domain='domain_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.DnsAuthorization.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_dns_authorization(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_manager.DnsAuthorization) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.domain == 'domain_value' - - -def test_get_dns_authorization_rest_required_fields(request_type=certificate_manager.GetDnsAuthorizationRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_dns_authorization._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_dns_authorization._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = certificate_manager.DnsAuthorization() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = certificate_manager.DnsAuthorization.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_dns_authorization(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_dns_authorization_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_dns_authorization._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_dns_authorization_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_get_dns_authorization") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_get_dns_authorization") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.GetDnsAuthorizationRequest.pb(certificate_manager.GetDnsAuthorizationRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = certificate_manager.DnsAuthorization.to_json(certificate_manager.DnsAuthorization()) - - request = certificate_manager.GetDnsAuthorizationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = certificate_manager.DnsAuthorization() - - client.get_dns_authorization(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_dns_authorization_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.GetDnsAuthorizationRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_dns_authorization(request) - - -def test_get_dns_authorization_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_manager.DnsAuthorization() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_manager.DnsAuthorization.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_dns_authorization(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/dnsAuthorizations/*}" % client.transport._host, args[1]) - - -def test_get_dns_authorization_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_dns_authorization( - certificate_manager.GetDnsAuthorizationRequest(), - name='name_value', - ) - - -def test_get_dns_authorization_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.CreateDnsAuthorizationRequest, - dict, -]) -def test_create_dns_authorization_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["dns_authorization"] = {'name': 'name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'description': 'description_value', 'domain': 'domain_value', 'dns_resource_record': {'name': 'name_value', 'type_': 'type__value', 'data': 'data_value'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_dns_authorization(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_create_dns_authorization_rest_required_fields(request_type=certificate_manager.CreateDnsAuthorizationRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["dns_authorization_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - assert "dnsAuthorizationId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_dns_authorization._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "dnsAuthorizationId" in jsonified_request - assert jsonified_request["dnsAuthorizationId"] == request_init["dns_authorization_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["dnsAuthorizationId"] = 'dns_authorization_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_dns_authorization._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("dns_authorization_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "dnsAuthorizationId" in jsonified_request - assert jsonified_request["dnsAuthorizationId"] == 'dns_authorization_id_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_dns_authorization(request) - - expected_params = [ - ( - "dnsAuthorizationId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_dns_authorization_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_dns_authorization._get_unset_required_fields({}) - assert set(unset_fields) == (set(("dnsAuthorizationId", )) & set(("parent", "dnsAuthorizationId", "dnsAuthorization", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_dns_authorization_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_create_dns_authorization") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_create_dns_authorization") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.CreateDnsAuthorizationRequest.pb(certificate_manager.CreateDnsAuthorizationRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_manager.CreateDnsAuthorizationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.create_dns_authorization(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_dns_authorization_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.CreateDnsAuthorizationRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["dns_authorization"] = {'name': 'name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'description': 'description_value', 'domain': 'domain_value', 'dns_resource_record': {'name': 'name_value', 'type_': 'type__value', 'data': 'data_value'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.create_dns_authorization(request) - - -def test_create_dns_authorization_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), - dns_authorization_id='dns_authorization_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_dns_authorization(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/dnsAuthorizations" % client.transport._host, args[1]) - - -def test_create_dns_authorization_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_dns_authorization( - certificate_manager.CreateDnsAuthorizationRequest(), - parent='parent_value', - dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), - dns_authorization_id='dns_authorization_id_value', - ) - - -def test_create_dns_authorization_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.UpdateDnsAuthorizationRequest, - dict, -]) -def test_update_dns_authorization_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'dns_authorization': {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'}} - request_init["dns_authorization"] = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'description': 'description_value', 'domain': 'domain_value', 'dns_resource_record': {'name': 'name_value', 'type_': 'type__value', 'data': 'data_value'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_dns_authorization(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_update_dns_authorization_rest_required_fields(request_type=certificate_manager.UpdateDnsAuthorizationRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_dns_authorization._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_dns_authorization._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_dns_authorization(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_dns_authorization_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_dns_authorization._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("dnsAuthorization", "updateMask", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_dns_authorization_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_update_dns_authorization") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_update_dns_authorization") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.UpdateDnsAuthorizationRequest.pb(certificate_manager.UpdateDnsAuthorizationRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_manager.UpdateDnsAuthorizationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.update_dns_authorization(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_dns_authorization_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.UpdateDnsAuthorizationRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'dns_authorization': {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'}} - request_init["dns_authorization"] = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'description': 'description_value', 'domain': 'domain_value', 'dns_resource_record': {'name': 'name_value', 'type_': 'type__value', 'data': 'data_value'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.update_dns_authorization(request) - - -def test_update_dns_authorization_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'dns_authorization': {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_dns_authorization(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{dns_authorization.name=projects/*/locations/*/dnsAuthorizations/*}" % client.transport._host, args[1]) - - -def test_update_dns_authorization_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_dns_authorization( - certificate_manager.UpdateDnsAuthorizationRequest(), - dns_authorization=certificate_manager.DnsAuthorization(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_update_dns_authorization_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_manager.DeleteDnsAuthorizationRequest, - dict, -]) -def test_delete_dns_authorization_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_dns_authorization(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_delete_dns_authorization_rest_required_fields(request_type=certificate_manager.DeleteDnsAuthorizationRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_dns_authorization._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_dns_authorization._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_dns_authorization(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_dns_authorization_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_dns_authorization._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_dns_authorization_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_delete_dns_authorization") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_delete_dns_authorization") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_manager.DeleteDnsAuthorizationRequest.pb(certificate_manager.DeleteDnsAuthorizationRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_manager.DeleteDnsAuthorizationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_dns_authorization(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_dns_authorization_rest_bad_request(transport: str = 'rest', request_type=certificate_manager.DeleteDnsAuthorizationRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_dns_authorization(request) - - -def test_delete_dns_authorization_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/dnsAuthorizations/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_dns_authorization(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/dnsAuthorizations/*}" % client.transport._host, args[1]) - - -def test_delete_dns_authorization_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_dns_authorization( - certificate_manager.DeleteDnsAuthorizationRequest(), - name='name_value', - ) - - -def test_delete_dns_authorization_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_issuance_config.ListCertificateIssuanceConfigsRequest, - dict, -]) -def test_list_certificate_issuance_configs_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_certificate_issuance_configs(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateIssuanceConfigsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificate_issuance_configs_rest_required_fields(request_type=certificate_issuance_config.ListCertificateIssuanceConfigsRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificate_issuance_configs._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_certificate_issuance_configs._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_certificate_issuance_configs(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_certificate_issuance_configs_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_certificate_issuance_configs._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_certificate_issuance_configs_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_list_certificate_issuance_configs") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_list_certificate_issuance_configs") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_issuance_config.ListCertificateIssuanceConfigsRequest.pb(certificate_issuance_config.ListCertificateIssuanceConfigsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = certificate_issuance_config.ListCertificateIssuanceConfigsResponse.to_json(certificate_issuance_config.ListCertificateIssuanceConfigsResponse()) - - request = certificate_issuance_config.ListCertificateIssuanceConfigsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() - - client.list_certificate_issuance_configs(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_certificate_issuance_configs_rest_bad_request(transport: str = 'rest', request_type=certificate_issuance_config.ListCertificateIssuanceConfigsRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_certificate_issuance_configs(request) - - -def test_list_certificate_issuance_configs_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_certificate_issuance_configs(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/certificateIssuanceConfigs" % client.transport._host, args[1]) - - -def test_list_certificate_issuance_configs_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_certificate_issuance_configs( - certificate_issuance_config.ListCertificateIssuanceConfigsRequest(), - parent='parent_value', - ) - - -def test_list_certificate_issuance_configs_rest_pager(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - ], - next_page_token='abc', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[], - next_page_token='def', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - ], - next_page_token='ghi', - ), - certificate_issuance_config.ListCertificateIssuanceConfigsResponse( - certificate_issuance_configs=[ - certificate_issuance_config.CertificateIssuanceConfig(), - certificate_issuance_config.CertificateIssuanceConfig(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(certificate_issuance_config.ListCertificateIssuanceConfigsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_certificate_issuance_configs(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, certificate_issuance_config.CertificateIssuanceConfig) - for i in results) - - pages = list(client.list_certificate_issuance_configs(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - certificate_issuance_config.GetCertificateIssuanceConfigRequest, - dict, -]) -def test_get_certificate_issuance_config_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_issuance_config.CertificateIssuanceConfig( - name='name_value', - description='description_value', - rotation_window_percentage=2788, - key_algorithm=certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048, - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_issuance_config.CertificateIssuanceConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_certificate_issuance_config(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, certificate_issuance_config.CertificateIssuanceConfig) - assert response.name == 'name_value' - assert response.description == 'description_value' - assert response.rotation_window_percentage == 2788 - assert response.key_algorithm == certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048 - - -def test_get_certificate_issuance_config_rest_required_fields(request_type=certificate_issuance_config.GetCertificateIssuanceConfigRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate_issuance_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_certificate_issuance_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = certificate_issuance_config.CertificateIssuanceConfig() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = certificate_issuance_config.CertificateIssuanceConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_certificate_issuance_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_certificate_issuance_config_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_certificate_issuance_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_certificate_issuance_config_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_get_certificate_issuance_config") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_get_certificate_issuance_config") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_issuance_config.GetCertificateIssuanceConfigRequest.pb(certificate_issuance_config.GetCertificateIssuanceConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = certificate_issuance_config.CertificateIssuanceConfig.to_json(certificate_issuance_config.CertificateIssuanceConfig()) - - request = certificate_issuance_config.GetCertificateIssuanceConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = certificate_issuance_config.CertificateIssuanceConfig() - - client.get_certificate_issuance_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_certificate_issuance_config_rest_bad_request(transport: str = 'rest', request_type=certificate_issuance_config.GetCertificateIssuanceConfigRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_certificate_issuance_config(request) - - -def test_get_certificate_issuance_config_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = certificate_issuance_config.CertificateIssuanceConfig() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = certificate_issuance_config.CertificateIssuanceConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_certificate_issuance_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificateIssuanceConfigs/*}" % client.transport._host, args[1]) - - -def test_get_certificate_issuance_config_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_certificate_issuance_config( - certificate_issuance_config.GetCertificateIssuanceConfigRequest(), - name='name_value', - ) - - -def test_get_certificate_issuance_config_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, - dict, -]) -def test_create_certificate_issuance_config_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["certificate_issuance_config"] = {'name': 'name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'description': 'description_value', 'certificate_authority_config': {'certificate_authority_service_config': {'ca_pool': 'ca_pool_value'}}, 'lifetime': {'seconds': 751, 'nanos': 543}, 'rotation_window_percentage': 2788, 'key_algorithm': 1} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_certificate_issuance_config(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_create_certificate_issuance_config_rest_required_fields(request_type=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["certificate_issuance_config_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - assert "certificateIssuanceConfigId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate_issuance_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "certificateIssuanceConfigId" in jsonified_request - assert jsonified_request["certificateIssuanceConfigId"] == request_init["certificate_issuance_config_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["certificateIssuanceConfigId"] = 'certificate_issuance_config_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_certificate_issuance_config._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("certificate_issuance_config_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "certificateIssuanceConfigId" in jsonified_request - assert jsonified_request["certificateIssuanceConfigId"] == 'certificate_issuance_config_id_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_certificate_issuance_config(request) - - expected_params = [ - ( - "certificateIssuanceConfigId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_certificate_issuance_config_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_certificate_issuance_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(("certificateIssuanceConfigId", )) & set(("parent", "certificateIssuanceConfigId", "certificateIssuanceConfig", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_certificate_issuance_config_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_create_certificate_issuance_config") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_create_certificate_issuance_config") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest.pb(gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.create_certificate_issuance_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_certificate_issuance_config_rest_bad_request(transport: str = 'rest', request_type=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["certificate_issuance_config"] = {'name': 'name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'labels': {}, 'description': 'description_value', 'certificate_authority_config': {'certificate_authority_service_config': {'ca_pool': 'ca_pool_value'}}, 'lifetime': {'seconds': 751, 'nanos': 543}, 'rotation_window_percentage': 2788, 'key_algorithm': 1} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.create_certificate_issuance_config(request) - - -def test_create_certificate_issuance_config_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value'), - certificate_issuance_config_id='certificate_issuance_config_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_certificate_issuance_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/certificateIssuanceConfigs" % client.transport._host, args[1]) - - -def test_create_certificate_issuance_config_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_certificate_issuance_config( - gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest(), - parent='parent_value', - certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig(name='name_value'), - certificate_issuance_config_id='certificate_issuance_config_id_value', - ) - - -def test_create_certificate_issuance_config_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, - dict, -]) -def test_delete_certificate_issuance_config_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_certificate_issuance_config(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_delete_certificate_issuance_config_rest_required_fields(request_type=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest): - transport_class = transports.CertificateManagerRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate_issuance_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_certificate_issuance_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_certificate_issuance_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_certificate_issuance_config_rest_unset_required_fields(): - transport = transports.CertificateManagerRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_certificate_issuance_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_certificate_issuance_config_rest_interceptors(null_interceptor): - transport = transports.CertificateManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.CertificateManagerRestInterceptor(), - ) - client = CertificateManagerClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "post_delete_certificate_issuance_config") as post, \ - mock.patch.object(transports.CertificateManagerRestInterceptor, "pre_delete_certificate_issuance_config") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest.pb(certificate_issuance_config.DeleteCertificateIssuanceConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_certificate_issuance_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_certificate_issuance_config_rest_bad_request(transport: str = 'rest', request_type=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_certificate_issuance_config(request) - - -def test_delete_certificate_issuance_config_rest_flattened(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_certificate_issuance_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/certificateIssuanceConfigs/*}" % client.transport._host, args[1]) - - -def test_delete_certificate_issuance_config_rest_flattened_error(transport: str = 'rest'): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_certificate_issuance_config( - certificate_issuance_config.DeleteCertificateIssuanceConfigRequest(), - name='name_value', - ) - - -def test_delete_certificate_issuance_config_rest_error(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.CertificateManagerGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.CertificateManagerGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CertificateManagerClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.CertificateManagerGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = CertificateManagerClient( - client_options=options, - transport=transport, - ) - - # It is an error to provide an api_key and a credential. - options = mock.Mock() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = CertificateManagerClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.CertificateManagerGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CertificateManagerClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.CertificateManagerGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = CertificateManagerClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.CertificateManagerGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.CertificateManagerGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.CertificateManagerGrpcTransport, - transports.CertificateManagerGrpcAsyncIOTransport, - transports.CertificateManagerRestTransport, -]) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "rest", -]) -def test_transport_kind(transport_name): - transport = CertificateManagerClient.get_transport_class(transport_name)( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert transport.kind == transport_name - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.CertificateManagerGrpcTransport, - ) - -def test_certificate_manager_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.CertificateManagerTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_certificate_manager_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.certificate_manager_v1.services.certificate_manager.transports.CertificateManagerTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.CertificateManagerTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'list_certificates', - 'get_certificate', - 'create_certificate', - 'update_certificate', - 'delete_certificate', - 'list_certificate_maps', - 'get_certificate_map', - 'create_certificate_map', - 'update_certificate_map', - 'delete_certificate_map', - 'list_certificate_map_entries', - 'get_certificate_map_entry', - 'create_certificate_map_entry', - 'update_certificate_map_entry', - 'delete_certificate_map_entry', - 'list_dns_authorizations', - 'get_dns_authorization', - 'create_dns_authorization', - 'update_dns_authorization', - 'delete_dns_authorization', - 'list_certificate_issuance_configs', - 'get_certificate_issuance_config', - 'create_certificate_issuance_config', - 'delete_certificate_issuance_config', - 'get_location', - 'list_locations', - 'get_operation', - 'cancel_operation', - 'delete_operation', - 'list_operations', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - with pytest.raises(NotImplementedError): - transport.close() - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - # Catch all for all remaining methods and properties - remainder = [ - 'kind', - ] - for r in remainder: - with pytest.raises(NotImplementedError): - getattr(transport, r)() - - -def test_certificate_manager_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.certificate_manager_v1.services.certificate_manager.transports.CertificateManagerTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CertificateManagerTransport( - 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", - ) - - -def test_certificate_manager_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.certificate_manager_v1.services.certificate_manager.transports.CertificateManagerTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CertificateManagerTransport() - adc.assert_called_once() - - -def test_certificate_manager_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) - CertificateManagerClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.CertificateManagerGrpcTransport, - transports.CertificateManagerGrpcAsyncIOTransport, - ], -) -def test_certificate_manager_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.CertificateManagerGrpcTransport, - transports.CertificateManagerGrpcAsyncIOTransport, - transports.CertificateManagerRestTransport, - ], -) -def test_certificate_manager_transport_auth_gdch_credentials(transport_class): - host = 'https://language.com' - api_audience_tests = [None, 'https://language2.com'] - api_audience_expect = [host, 'https://language2.com'] - for t, e in zip(api_audience_tests, api_audience_expect): - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - gdch_mock = mock.MagicMock() - type(gdch_mock).with_gdch_audience = mock.PropertyMock(return_value=gdch_mock) - adc.return_value = (gdch_mock, None) - transport_class(host=host, api_audience=t) - gdch_mock.with_gdch_audience.assert_called_once_with( - e - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.CertificateManagerGrpcTransport, grpc_helpers), - (transports.CertificateManagerGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_certificate_manager_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( - "certificatemanager.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="certificatemanager.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.CertificateManagerGrpcTransport, transports.CertificateManagerGrpcAsyncIOTransport]) -def test_certificate_manager_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_certificate_manager_http_transport_client_cert_source_for_mtls(): - cred = ga_credentials.AnonymousCredentials() - with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel") as mock_configure_mtls_channel: - transports.CertificateManagerRestTransport ( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) - - -def test_certificate_manager_rest_lro_client(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.AbstractOperationsClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_certificate_manager_host_no_port(transport_name): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='certificatemanager.googleapis.com'), - transport=transport_name, - ) - assert client.transport._host == ( - 'certificatemanager.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://certificatemanager.googleapis.com' - ) - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_certificate_manager_host_with_port(transport_name): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='certificatemanager.googleapis.com:8000'), - transport=transport_name, - ) - assert client.transport._host == ( - 'certificatemanager.googleapis.com:8000' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://certificatemanager.googleapis.com:8000' - ) - -@pytest.mark.parametrize("transport_name", [ - "rest", -]) -def test_certificate_manager_client_transport_session_collision(transport_name): - creds1 = ga_credentials.AnonymousCredentials() - creds2 = ga_credentials.AnonymousCredentials() - client1 = CertificateManagerClient( - credentials=creds1, - transport=transport_name, - ) - client2 = CertificateManagerClient( - credentials=creds2, - transport=transport_name, - ) - session1 = client1.transport.list_certificates._session - session2 = client2.transport.list_certificates._session - assert session1 != session2 - session1 = client1.transport.get_certificate._session - session2 = client2.transport.get_certificate._session - assert session1 != session2 - session1 = client1.transport.create_certificate._session - session2 = client2.transport.create_certificate._session - assert session1 != session2 - session1 = client1.transport.update_certificate._session - session2 = client2.transport.update_certificate._session - assert session1 != session2 - session1 = client1.transport.delete_certificate._session - session2 = client2.transport.delete_certificate._session - assert session1 != session2 - session1 = client1.transport.list_certificate_maps._session - session2 = client2.transport.list_certificate_maps._session - assert session1 != session2 - session1 = client1.transport.get_certificate_map._session - session2 = client2.transport.get_certificate_map._session - assert session1 != session2 - session1 = client1.transport.create_certificate_map._session - session2 = client2.transport.create_certificate_map._session - assert session1 != session2 - session1 = client1.transport.update_certificate_map._session - session2 = client2.transport.update_certificate_map._session - assert session1 != session2 - session1 = client1.transport.delete_certificate_map._session - session2 = client2.transport.delete_certificate_map._session - assert session1 != session2 - session1 = client1.transport.list_certificate_map_entries._session - session2 = client2.transport.list_certificate_map_entries._session - assert session1 != session2 - session1 = client1.transport.get_certificate_map_entry._session - session2 = client2.transport.get_certificate_map_entry._session - assert session1 != session2 - session1 = client1.transport.create_certificate_map_entry._session - session2 = client2.transport.create_certificate_map_entry._session - assert session1 != session2 - session1 = client1.transport.update_certificate_map_entry._session - session2 = client2.transport.update_certificate_map_entry._session - assert session1 != session2 - session1 = client1.transport.delete_certificate_map_entry._session - session2 = client2.transport.delete_certificate_map_entry._session - assert session1 != session2 - session1 = client1.transport.list_dns_authorizations._session - session2 = client2.transport.list_dns_authorizations._session - assert session1 != session2 - session1 = client1.transport.get_dns_authorization._session - session2 = client2.transport.get_dns_authorization._session - assert session1 != session2 - session1 = client1.transport.create_dns_authorization._session - session2 = client2.transport.create_dns_authorization._session - assert session1 != session2 - session1 = client1.transport.update_dns_authorization._session - session2 = client2.transport.update_dns_authorization._session - assert session1 != session2 - session1 = client1.transport.delete_dns_authorization._session - session2 = client2.transport.delete_dns_authorization._session - assert session1 != session2 - session1 = client1.transport.list_certificate_issuance_configs._session - session2 = client2.transport.list_certificate_issuance_configs._session - assert session1 != session2 - session1 = client1.transport.get_certificate_issuance_config._session - session2 = client2.transport.get_certificate_issuance_config._session - assert session1 != session2 - session1 = client1.transport.create_certificate_issuance_config._session - session2 = client2.transport.create_certificate_issuance_config._session - assert session1 != session2 - session1 = client1.transport.delete_certificate_issuance_config._session - session2 = client2.transport.delete_certificate_issuance_config._session - assert session1 != session2 -def test_certificate_manager_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CertificateManagerGrpcTransport( - 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_certificate_manager_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CertificateManagerGrpcAsyncIOTransport( - 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.CertificateManagerGrpcTransport, transports.CertificateManagerGrpcAsyncIOTransport]) -def test_certificate_manager_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.CertificateManagerGrpcTransport, transports.CertificateManagerGrpcAsyncIOTransport]) -def test_certificate_manager_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_certificate_manager_grpc_lro_client(): - client = CertificateManagerClient( - 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_certificate_manager_grpc_lro_async_client(): - client = CertificateManagerAsyncClient( - 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_ca_pool_path(): - project = "squid" - location = "clam" - ca_pool = "whelk" - expected = "projects/{project}/locations/{location}/caPools/{ca_pool}".format(project=project, location=location, ca_pool=ca_pool, ) - actual = CertificateManagerClient.ca_pool_path(project, location, ca_pool) - assert expected == actual - - -def test_parse_ca_pool_path(): - expected = { - "project": "octopus", - "location": "oyster", - "ca_pool": "nudibranch", - } - path = CertificateManagerClient.ca_pool_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateManagerClient.parse_ca_pool_path(path) - assert expected == actual - -def test_certificate_path(): - project = "cuttlefish" - location = "mussel" - certificate = "winkle" - expected = "projects/{project}/locations/{location}/certificates/{certificate}".format(project=project, location=location, certificate=certificate, ) - actual = CertificateManagerClient.certificate_path(project, location, certificate) - assert expected == actual - - -def test_parse_certificate_path(): - expected = { - "project": "nautilus", - "location": "scallop", - "certificate": "abalone", - } - path = CertificateManagerClient.certificate_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateManagerClient.parse_certificate_path(path) - assert expected == actual - -def test_certificate_issuance_config_path(): - project = "squid" - location = "clam" - certificate_issuance_config = "whelk" - expected = "projects/{project}/locations/{location}/certificateIssuanceConfigs/{certificate_issuance_config}".format(project=project, location=location, certificate_issuance_config=certificate_issuance_config, ) - actual = CertificateManagerClient.certificate_issuance_config_path(project, location, certificate_issuance_config) - assert expected == actual - - -def test_parse_certificate_issuance_config_path(): - expected = { - "project": "octopus", - "location": "oyster", - "certificate_issuance_config": "nudibranch", - } - path = CertificateManagerClient.certificate_issuance_config_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateManagerClient.parse_certificate_issuance_config_path(path) - assert expected == actual - -def test_certificate_map_path(): - project = "cuttlefish" - location = "mussel" - certificate_map = "winkle" - expected = "projects/{project}/locations/{location}/certificateMaps/{certificate_map}".format(project=project, location=location, certificate_map=certificate_map, ) - actual = CertificateManagerClient.certificate_map_path(project, location, certificate_map) - assert expected == actual - - -def test_parse_certificate_map_path(): - expected = { - "project": "nautilus", - "location": "scallop", - "certificate_map": "abalone", - } - path = CertificateManagerClient.certificate_map_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateManagerClient.parse_certificate_map_path(path) - assert expected == actual - -def test_certificate_map_entry_path(): - project = "squid" - location = "clam" - certificate_map = "whelk" - certificate_map_entry = "octopus" - expected = "projects/{project}/locations/{location}/certificateMaps/{certificate_map}/certificateMapEntries/{certificate_map_entry}".format(project=project, location=location, certificate_map=certificate_map, certificate_map_entry=certificate_map_entry, ) - actual = CertificateManagerClient.certificate_map_entry_path(project, location, certificate_map, certificate_map_entry) - assert expected == actual - - -def test_parse_certificate_map_entry_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - "certificate_map": "cuttlefish", - "certificate_map_entry": "mussel", - } - path = CertificateManagerClient.certificate_map_entry_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateManagerClient.parse_certificate_map_entry_path(path) - assert expected == actual - -def test_dns_authorization_path(): - project = "winkle" - location = "nautilus" - dns_authorization = "scallop" - expected = "projects/{project}/locations/{location}/dnsAuthorizations/{dns_authorization}".format(project=project, location=location, dns_authorization=dns_authorization, ) - actual = CertificateManagerClient.dns_authorization_path(project, location, dns_authorization) - assert expected == actual - - -def test_parse_dns_authorization_path(): - expected = { - "project": "abalone", - "location": "squid", - "dns_authorization": "clam", - } - path = CertificateManagerClient.dns_authorization_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateManagerClient.parse_dns_authorization_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "whelk" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = CertificateManagerClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "octopus", - } - path = CertificateManagerClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateManagerClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "oyster" - expected = "folders/{folder}".format(folder=folder, ) - actual = CertificateManagerClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nudibranch", - } - path = CertificateManagerClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateManagerClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization, ) - actual = CertificateManagerClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "mussel", - } - path = CertificateManagerClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateManagerClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "winkle" - expected = "projects/{project}".format(project=project, ) - actual = CertificateManagerClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "nautilus", - } - path = CertificateManagerClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateManagerClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "scallop" - location = "abalone" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = CertificateManagerClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "squid", - "location": "clam", - } - path = CertificateManagerClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateManagerClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_with_default_client_info(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object(transports.CertificateManagerTransport, '_prep_wrapped_messages') as prep: - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.CertificateManagerTransport, '_prep_wrapped_messages') as prep: - transport_class = CertificateManagerClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - -@pytest.mark.asyncio -async def test_transport_close_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc_asyncio", - ) - with mock.patch.object(type(getattr(client.transport, "grpc_channel")), "close") as close: - async with client: - close.assert_not_called() - close.assert_called_once() - - -def test_get_location_rest_bad_request(transport: str = 'rest', request_type=locations_pb2.GetLocationRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_location(request) - -@pytest.mark.parametrize("request_type", [ - locations_pb2.GetLocationRequest, - dict, -]) -def test_get_location_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request_init = {'name': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = locations_pb2.Location() - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_location(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, locations_pb2.Location) - -def test_list_locations_rest_bad_request(transport: str = 'rest', request_type=locations_pb2.ListLocationsRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_locations(request) - -@pytest.mark.parametrize("request_type", [ - locations_pb2.ListLocationsRequest, - dict, -]) -def test_list_locations_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request_init = {'name': 'projects/sample1'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = locations_pb2.ListLocationsResponse() - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_locations(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, locations_pb2.ListLocationsResponse) - -def test_cancel_operation_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.CancelOperationRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.cancel_operation(request) - -@pytest.mark.parametrize("request_type", [ - operations_pb2.CancelOperationRequest, - dict, -]) -def test_cancel_operation_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '{}' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.cancel_operation(request) - - # Establish that the response is the type that we expect. - assert response is None - -def test_delete_operation_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.DeleteOperationRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_operation(request) - -@pytest.mark.parametrize("request_type", [ - operations_pb2.DeleteOperationRequest, - dict, -]) -def test_delete_operation_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '{}' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_operation(request) - - # Establish that the response is the type that we expect. - assert response is None - -def test_get_operation_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.GetOperationRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_operation(request) - -@pytest.mark.parametrize("request_type", [ - operations_pb2.GetOperationRequest, - dict, -]) -def test_get_operation_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation() - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_operation(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) - -def test_list_operations_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.ListOperationsRequest): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_operations(request) - -@pytest.mark.parametrize("request_type", [ - operations_pb2.ListOperationsRequest, - dict, -]) -def test_list_operations_rest(request_type): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request_init = {'name': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.ListOperationsResponse() - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_operations(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.ListOperationsResponse) - - -def test_delete_operation(transport: str = "grpc"): - client = CertificateManagerClient( - 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 = operations_pb2.DeleteOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_operation(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 response is the type that we expect. - assert response is None -@pytest.mark.asyncio -async def test_delete_operation_async(transport: str = "grpc"): - client = CertificateManagerAsyncClient( - 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 = operations_pb2.DeleteOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.delete_operation(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 response is the type that we expect. - assert response is None - -def test_delete_operation_field_headers(): - client = CertificateManagerClient( - 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 = operations_pb2.DeleteOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - call.return_value = None - - client.delete_operation(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=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_delete_operation_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = operations_pb2.DeleteOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - await client.delete_operation(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=locations",) in kw["metadata"] - -def test_delete_operation_from_dict(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.delete_operation( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_delete_operation_from_dict_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.delete_operation( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_cancel_operation(transport: str = "grpc"): - client = CertificateManagerClient( - 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 = operations_pb2.CancelOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.cancel_operation(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 response is the type that we expect. - assert response is None -@pytest.mark.asyncio -async def test_cancel_operation_async(transport: str = "grpc"): - client = CertificateManagerAsyncClient( - 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 = operations_pb2.CancelOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.cancel_operation(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 response is the type that we expect. - assert response is None - -def test_cancel_operation_field_headers(): - client = CertificateManagerClient( - 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 = operations_pb2.CancelOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - call.return_value = None - - client.cancel_operation(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=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_cancel_operation_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = operations_pb2.CancelOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - await client.cancel_operation(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=locations",) in kw["metadata"] - -def test_cancel_operation_from_dict(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.cancel_operation( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_cancel_operation_from_dict_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.cancel_operation( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_get_operation(transport: str = "grpc"): - client = CertificateManagerClient( - 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 = operations_pb2.GetOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation() - response = client.get_operation(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 response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) -@pytest.mark.asyncio -async def test_get_operation_async(transport: str = "grpc"): - client = CertificateManagerAsyncClient( - 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 = operations_pb2.GetOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation() - ) - response = await client.get_operation(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 response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) - -def test_get_operation_field_headers(): - client = CertificateManagerClient( - 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 = operations_pb2.GetOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - call.return_value = operations_pb2.Operation() - - client.get_operation(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=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_get_operation_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = operations_pb2.GetOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation() - ) - await client.get_operation(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=locations",) in kw["metadata"] - -def test_get_operation_from_dict(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation() - - response = client.get_operation( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_get_operation_from_dict_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation() - ) - response = await client.get_operation( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_list_operations(transport: str = "grpc"): - client = CertificateManagerClient( - 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 = operations_pb2.ListOperationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.ListOperationsResponse() - response = client.list_operations(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 response is the type that we expect. - assert isinstance(response, operations_pb2.ListOperationsResponse) -@pytest.mark.asyncio -async def test_list_operations_async(transport: str = "grpc"): - client = CertificateManagerAsyncClient( - 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 = operations_pb2.ListOperationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.ListOperationsResponse() - ) - response = await client.list_operations(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 response is the type that we expect. - assert isinstance(response, operations_pb2.ListOperationsResponse) - -def test_list_operations_field_headers(): - client = CertificateManagerClient( - 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 = operations_pb2.ListOperationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - call.return_value = operations_pb2.ListOperationsResponse() - - client.list_operations(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=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_list_operations_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = operations_pb2.ListOperationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.ListOperationsResponse() - ) - await client.list_operations(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=locations",) in kw["metadata"] - -def test_list_operations_from_dict(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.ListOperationsResponse() - - response = client.list_operations( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_list_operations_from_dict_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.ListOperationsResponse() - ) - response = await client.list_operations( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_list_locations(transport: str = "grpc"): - client = CertificateManagerClient( - 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 = locations_pb2.ListLocationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.ListLocationsResponse() - response = client.list_locations(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 response is the type that we expect. - assert isinstance(response, locations_pb2.ListLocationsResponse) -@pytest.mark.asyncio -async def test_list_locations_async(transport: str = "grpc"): - client = CertificateManagerAsyncClient( - 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 = locations_pb2.ListLocationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.ListLocationsResponse() - ) - response = await client.list_locations(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 response is the type that we expect. - assert isinstance(response, locations_pb2.ListLocationsResponse) - -def test_list_locations_field_headers(): - client = CertificateManagerClient( - 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 = locations_pb2.ListLocationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - call.return_value = locations_pb2.ListLocationsResponse() - - client.list_locations(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=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_list_locations_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = locations_pb2.ListLocationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.ListLocationsResponse() - ) - await client.list_locations(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=locations",) in kw["metadata"] - -def test_list_locations_from_dict(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.ListLocationsResponse() - - response = client.list_locations( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_list_locations_from_dict_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.ListLocationsResponse() - ) - response = await client.list_locations( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_get_location(transport: str = "grpc"): - client = CertificateManagerClient( - 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 = locations_pb2.GetLocationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.Location() - response = client.get_location(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 response is the type that we expect. - assert isinstance(response, locations_pb2.Location) -@pytest.mark.asyncio -async def test_get_location_async(transport: str = "grpc_asyncio"): - client = CertificateManagerAsyncClient( - 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 = locations_pb2.GetLocationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.Location() - ) - response = await client.get_location(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 response is the type that we expect. - assert isinstance(response, locations_pb2.Location) - -def test_get_location_field_headers(): - client = CertificateManagerClient( - 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 = locations_pb2.GetLocationRequest() - request.name = "locations/abc" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - call.return_value = locations_pb2.Location() - - client.get_location(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=locations/abc",) in kw["metadata"] -@pytest.mark.asyncio -async def test_get_location_field_headers_async(): - client = CertificateManagerAsyncClient( - 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 = locations_pb2.GetLocationRequest() - request.name = "locations/abc" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.Location() - ) - await client.get_location(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=locations/abc",) in kw["metadata"] - -def test_get_location_from_dict(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.Location() - - response = client.get_location( - request={ - "name": "locations/abc", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_get_location_from_dict_async(): - client = CertificateManagerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.Location() - ) - response = await client.get_location( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_transport_close(): - transports = { - "rest": "_session", - "grpc": "_grpc_channel", - } - - for transport, close_name in transports.items(): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport - ) - with mock.patch.object(type(getattr(client.transport, close_name)), "close") as close: - with client: - close.assert_not_called() - close.assert_called_once() - -def test_client_ctx(): - transports = [ - 'rest', - 'grpc', - ] - for transport in transports: - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport - ) - # Test client calls underlying transport. - with mock.patch.object(type(client.transport), "close") as close: - close.assert_not_called() - with client: - pass - close.assert_called() - -@pytest.mark.parametrize("client_class,transport_class", [ - (CertificateManagerClient, transports.CertificateManagerGrpcTransport), - (CertificateManagerAsyncClient, transports.CertificateManagerGrpcAsyncIOTransport), -]) -def test_api_key_credentials(client_class, transport_class): - with mock.patch.object( - google.auth._default, "get_api_key_credentials", create=True - ) as get_api_key_credentials: - mock_cred = mock.Mock() - get_api_key_credentials.return_value = mock_cred - options = client_options.ClientOptions() - options.api_key = "api_key" - 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=mock_cred, - 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, - always_use_jwt_access=True, - api_audience=None, - ) diff --git a/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py b/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py index fe2270b..c0f1ad0 100644 --- a/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py +++ b/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py @@ -22,6 +22,8 @@ except ImportError: # pragma: NO COVER import mock +from collections.abc import Iterable +import json import math from google.api_core import ( @@ -45,12 +47,15 @@ from google.protobuf import duration_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import json_format from google.protobuf import timestamp_pb2 # type: ignore import grpc from grpc.experimental import aio from proto.marshal.rules import wrappers from proto.marshal.rules.dates import DurationRule, TimestampRule import pytest +from requests import PreparedRequest, Request, Response +from requests.sessions import Session from google.cloud.certificate_manager_v1.services.certificate_manager import ( CertificateManagerAsyncClient, @@ -115,6 +120,7 @@ def test__get_default_mtls_endpoint(): [ (CertificateManagerClient, "grpc"), (CertificateManagerAsyncClient, "grpc_asyncio"), + (CertificateManagerClient, "rest"), ], ) def test_certificate_manager_client_from_service_account_info( @@ -130,7 +136,11 @@ def test_certificate_manager_client_from_service_account_info( assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == ("certificatemanager.googleapis.com:443") + assert client.transport._host == ( + "certificatemanager.googleapis.com:443" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://certificatemanager.googleapis.com" + ) @pytest.mark.parametrize( @@ -138,6 +148,7 @@ def test_certificate_manager_client_from_service_account_info( [ (transports.CertificateManagerGrpcTransport, "grpc"), (transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio"), + (transports.CertificateManagerRestTransport, "rest"), ], ) def test_certificate_manager_client_service_account_always_use_jwt( @@ -163,6 +174,7 @@ def test_certificate_manager_client_service_account_always_use_jwt( [ (CertificateManagerClient, "grpc"), (CertificateManagerAsyncClient, "grpc_asyncio"), + (CertificateManagerClient, "rest"), ], ) def test_certificate_manager_client_from_service_account_file( @@ -185,13 +197,18 @@ def test_certificate_manager_client_from_service_account_file( assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == ("certificatemanager.googleapis.com:443") + assert client.transport._host == ( + "certificatemanager.googleapis.com:443" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://certificatemanager.googleapis.com" + ) def test_certificate_manager_client_get_transport_class(): transport = CertificateManagerClient.get_transport_class() available_transports = [ transports.CertificateManagerGrpcTransport, + transports.CertificateManagerRestTransport, ] assert transport in available_transports @@ -208,6 +225,7 @@ def test_certificate_manager_client_get_transport_class(): transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio", ), + (CertificateManagerClient, transports.CertificateManagerRestTransport, "rest"), ], ) @mock.patch.object( @@ -363,6 +381,18 @@ def test_certificate_manager_client_client_options( "grpc_asyncio", "false", ), + ( + CertificateManagerClient, + transports.CertificateManagerRestTransport, + "rest", + "true", + ), + ( + CertificateManagerClient, + transports.CertificateManagerRestTransport, + "rest", + "false", + ), ], ) @mock.patch.object( @@ -562,6 +592,7 @@ def test_certificate_manager_client_get_mtls_endpoint_and_cert_source(client_cla transports.CertificateManagerGrpcAsyncIOTransport, "grpc_asyncio", ), + (CertificateManagerClient, transports.CertificateManagerRestTransport, "rest"), ], ) def test_certificate_manager_client_client_options_scopes( @@ -602,6 +633,12 @@ def test_certificate_manager_client_client_options_scopes( "grpc_asyncio", grpc_helpers_async, ), + ( + CertificateManagerClient, + transports.CertificateManagerRestTransport, + "rest", + None, + ), ], ) def test_certificate_manager_client_client_options_credentials_file( @@ -7827,141 +7864,7674 @@ async def test_delete_certificate_issuance_config_flattened_error_async(): ) -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.CertificateManagerGrpcTransport( +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.ListCertificatesRequest, + dict, + ], +) +def test_list_certificates_rest(request_type): + client = CertificateManagerClient( credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - with pytest.raises(ValueError): - client = CertificateManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificatesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) - # It is an error to provide a credentials file and a transport instance. - transport = transports.CertificateManagerGrpcTransport( + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListCertificatesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_certificates(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificatesPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +def test_list_certificates_rest_required_fields( + request_type=certificate_manager.ListCertificatesRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_certificates._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_certificates._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = CertificateManagerClient( credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificatesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.ListCertificatesResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_certificates(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_certificates_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - with pytest.raises(ValueError): - client = CertificateManagerClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, + + unset_fields = transport.list_certificates._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) ) + & set(("parent",)) + ) - # It is an error to provide an api_key and a transport instance. - transport = transports.CertificateManagerGrpcTransport( + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_certificates_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = CertificateManagerClient( - client_options=options, - transport=transport, + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_list_certificates" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_list_certificates" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.ListCertificatesRequest.pb( + certificate_manager.ListCertificatesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = ( + certificate_manager.ListCertificatesResponse.to_json( + certificate_manager.ListCertificatesResponse() + ) ) - # It is an error to provide an api_key and a credential. - options = mock.Mock() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = CertificateManagerClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() + request = certificate_manager.ListCertificatesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.ListCertificatesResponse() + + client.list_certificates( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - # It is an error to provide scopes and a transport instance. - transport = transports.CertificateManagerGrpcTransport( + pre.assert_called_once() + post.assert_called_once() + + +def test_list_certificates_rest_bad_request( + transport: str = "rest", request_type=certificate_manager.ListCertificatesRequest +): + client = CertificateManagerClient( credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - with pytest.raises(ValueError): - client = CertificateManagerClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.CertificateManagerGrpcTransport( + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_certificates(request) + + +def test_list_certificates_rest_flattened(): + client = CertificateManagerClient( credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - client = CertificateManagerClient(transport=transport) - assert client.transport is transport + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificatesResponse() -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.CertificateManagerGrpcTransport( + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListCertificatesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_certificates(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/certificates" + % client.transport._host, + args[1], + ) + + +def test_list_certificates_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - channel = transport.grpc_channel - assert channel - transport = transports.CertificateManagerGrpcAsyncIOTransport( + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_certificates( + certificate_manager.ListCertificatesRequest(), + parent="parent_value", + ) + + +def test_list_certificates_rest_pager(transport: str = "rest"): + client = CertificateManagerClient( credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - channel = transport.grpc_channel - assert channel + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + certificate_manager.Certificate(), + certificate_manager.Certificate(), + ], + next_page_token="abc", + ), + certificate_manager.ListCertificatesResponse( + certificates=[], + next_page_token="def", + ), + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + ], + next_page_token="ghi", + ), + certificate_manager.ListCertificatesResponse( + certificates=[ + certificate_manager.Certificate(), + certificate_manager.Certificate(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + certificate_manager.ListCertificatesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values -@pytest.mark.parametrize( - "transport_class", - [ - transports.CertificateManagerGrpcTransport, - transports.CertificateManagerGrpcAsyncIOTransport, - ], -) -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() + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_certificates(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_manager.Certificate) for i in results) + + pages = list(client.list_certificates(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.parametrize( - "transport_name", + "request_type", [ - "grpc", + certificate_manager.GetCertificateRequest, + dict, ], ) -def test_transport_kind(transport_name): - transport = CertificateManagerClient.get_transport_class(transport_name)( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert transport.kind == transport_name - - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. +def test_get_certificate_rest(request_type): client = CertificateManagerClient( credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.CertificateManagerGrpcTransport, + transport="rest", ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/certificates/sample3"} + request = request_type(**request_init) -def test_certificate_manager_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.CertificateManagerTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json", + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.Certificate( + name="name_value", + description="description_value", + san_dnsnames=["san_dnsnames_value"], + pem_certificate="pem_certificate_value", + scope=certificate_manager.Certificate.Scope.EDGE_CACHE, + self_managed=certificate_manager.Certificate.SelfManagedCertificate( + pem_certificate="pem_certificate_value" + ), ) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.Certificate.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) -def test_certificate_manager_base_transport(): - # Instantiate the base transport. - with mock.patch( - "google.cloud.certificate_manager_v1.services.certificate_manager.transports.CertificateManagerTransport.__init__" - ) as Transport: - Transport.return_value = None - transport = transports.CertificateManagerTransport( - credentials=ga_credentials.AnonymousCredentials(), + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_certificate(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.Certificate) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.san_dnsnames == ["san_dnsnames_value"] + assert response.pem_certificate == "pem_certificate_value" + assert response.scope == certificate_manager.Certificate.Scope.EDGE_CACHE + + +def test_get_certificate_rest_required_fields( + request_type=certificate_manager.GetCertificateRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, ) + ) - # Every method on the transport should just blindly + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_certificate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_certificate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.Certificate() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.Certificate.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_certificate(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_certificate_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_certificate._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_certificate_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_get_certificate" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_get_certificate" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.GetCertificateRequest.pb( + certificate_manager.GetCertificateRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_manager.Certificate.to_json( + certificate_manager.Certificate() + ) + + request = certificate_manager.GetCertificateRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.Certificate() + + client.get_certificate( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_certificate_rest_bad_request( + transport: str = "rest", request_type=certificate_manager.GetCertificateRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/certificates/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_certificate(request) + + +def test_get_certificate_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.Certificate() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/certificates/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.Certificate.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_certificate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/certificates/*}" + % client.transport._host, + args[1], + ) + + +def test_get_certificate_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_certificate( + certificate_manager.GetCertificateRequest(), + name="name_value", + ) + + +def test_get_certificate_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.CreateCertificateRequest, + dict, + ], +) +def test_create_certificate_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["certificate"] = { + "name": "name_value", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "self_managed": { + "pem_certificate": "pem_certificate_value", + "pem_private_key": "pem_private_key_value", + }, + "managed": { + "domains": ["domains_value1", "domains_value2"], + "dns_authorizations": [ + "dns_authorizations_value1", + "dns_authorizations_value2", + ], + "issuance_config": "issuance_config_value", + "state": 1, + "provisioning_issue": {"reason": 1, "details": "details_value"}, + "authorization_attempt_info": [ + { + "domain": "domain_value", + "state": 1, + "failure_reason": 1, + "details": "details_value", + } + ], + }, + "san_dnsnames": ["san_dnsnames_value1", "san_dnsnames_value2"], + "pem_certificate": "pem_certificate_value", + "expire_time": {}, + "scope": 1, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.create_certificate(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_create_certificate_rest_required_fields( + request_type=certificate_manager.CreateCertificateRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["certificate_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + assert "certificateId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_certificate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "certificateId" in jsonified_request + assert jsonified_request["certificateId"] == request_init["certificate_id"] + + jsonified_request["parent"] = "parent_value" + jsonified_request["certificateId"] = "certificate_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_certificate._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("certificate_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "certificateId" in jsonified_request + assert jsonified_request["certificateId"] == "certificate_id_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_certificate(request) + + expected_params = [ + ( + "certificateId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_certificate_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_certificate._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("certificateId",)) + & set( + ( + "parent", + "certificateId", + "certificate", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_certificate_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_create_certificate" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_create_certificate" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.CreateCertificateRequest.pb( + certificate_manager.CreateCertificateRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_manager.CreateCertificateRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_certificate( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_certificate_rest_bad_request( + transport: str = "rest", request_type=certificate_manager.CreateCertificateRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["certificate"] = { + "name": "name_value", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "self_managed": { + "pem_certificate": "pem_certificate_value", + "pem_private_key": "pem_private_key_value", + }, + "managed": { + "domains": ["domains_value1", "domains_value2"], + "dns_authorizations": [ + "dns_authorizations_value1", + "dns_authorizations_value2", + ], + "issuance_config": "issuance_config_value", + "state": 1, + "provisioning_issue": {"reason": 1, "details": "details_value"}, + "authorization_attempt_info": [ + { + "domain": "domain_value", + "state": 1, + "failure_reason": 1, + "details": "details_value", + } + ], + }, + "san_dnsnames": ["san_dnsnames_value1", "san_dnsnames_value2"], + "pem_certificate": "pem_certificate_value", + "expire_time": {}, + "scope": 1, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_certificate(request) + + +def test_create_certificate_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + certificate=certificate_manager.Certificate(name="name_value"), + certificate_id="certificate_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_certificate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/certificates" + % client.transport._host, + args[1], + ) + + +def test_create_certificate_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_certificate( + certificate_manager.CreateCertificateRequest(), + parent="parent_value", + certificate=certificate_manager.Certificate(name="name_value"), + certificate_id="certificate_id_value", + ) + + +def test_create_certificate_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.UpdateCertificateRequest, + dict, + ], +) +def test_update_certificate_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "certificate": { + "name": "projects/sample1/locations/sample2/certificates/sample3" + } + } + request_init["certificate"] = { + "name": "projects/sample1/locations/sample2/certificates/sample3", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "self_managed": { + "pem_certificate": "pem_certificate_value", + "pem_private_key": "pem_private_key_value", + }, + "managed": { + "domains": ["domains_value1", "domains_value2"], + "dns_authorizations": [ + "dns_authorizations_value1", + "dns_authorizations_value2", + ], + "issuance_config": "issuance_config_value", + "state": 1, + "provisioning_issue": {"reason": 1, "details": "details_value"}, + "authorization_attempt_info": [ + { + "domain": "domain_value", + "state": 1, + "failure_reason": 1, + "details": "details_value", + } + ], + }, + "san_dnsnames": ["san_dnsnames_value1", "san_dnsnames_value2"], + "pem_certificate": "pem_certificate_value", + "expire_time": {}, + "scope": 1, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_certificate(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_update_certificate_rest_required_fields( + request_type=certificate_manager.UpdateCertificateRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_certificate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_certificate._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_certificate(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_certificate_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_certificate._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "certificate", + "updateMask", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_certificate_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_update_certificate" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_update_certificate" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.UpdateCertificateRequest.pb( + certificate_manager.UpdateCertificateRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_manager.UpdateCertificateRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.update_certificate( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_certificate_rest_bad_request( + transport: str = "rest", request_type=certificate_manager.UpdateCertificateRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "certificate": { + "name": "projects/sample1/locations/sample2/certificates/sample3" + } + } + request_init["certificate"] = { + "name": "projects/sample1/locations/sample2/certificates/sample3", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "self_managed": { + "pem_certificate": "pem_certificate_value", + "pem_private_key": "pem_private_key_value", + }, + "managed": { + "domains": ["domains_value1", "domains_value2"], + "dns_authorizations": [ + "dns_authorizations_value1", + "dns_authorizations_value2", + ], + "issuance_config": "issuance_config_value", + "state": 1, + "provisioning_issue": {"reason": 1, "details": "details_value"}, + "authorization_attempt_info": [ + { + "domain": "domain_value", + "state": 1, + "failure_reason": 1, + "details": "details_value", + } + ], + }, + "san_dnsnames": ["san_dnsnames_value1", "san_dnsnames_value2"], + "pem_certificate": "pem_certificate_value", + "expire_time": {}, + "scope": 1, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_certificate(request) + + +def test_update_certificate_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "certificate": { + "name": "projects/sample1/locations/sample2/certificates/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + certificate=certificate_manager.Certificate(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_certificate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{certificate.name=projects/*/locations/*/certificates/*}" + % client.transport._host, + args[1], + ) + + +def test_update_certificate_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_certificate( + certificate_manager.UpdateCertificateRequest(), + certificate=certificate_manager.Certificate(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_update_certificate_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.DeleteCertificateRequest, + dict, + ], +) +def test_delete_certificate_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/certificates/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_certificate(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_delete_certificate_rest_required_fields( + request_type=certificate_manager.DeleteCertificateRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_certificate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_certificate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_certificate(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_certificate_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_certificate._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_certificate_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_delete_certificate" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_delete_certificate" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.DeleteCertificateRequest.pb( + certificate_manager.DeleteCertificateRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_manager.DeleteCertificateRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.delete_certificate( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_certificate_rest_bad_request( + transport: str = "rest", request_type=certificate_manager.DeleteCertificateRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/certificates/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_certificate(request) + + +def test_delete_certificate_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/certificates/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_certificate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/certificates/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_certificate_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_certificate( + certificate_manager.DeleteCertificateRequest(), + name="name_value", + ) + + +def test_delete_certificate_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.ListCertificateMapsRequest, + dict, + ], +) +def test_list_certificate_maps_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificateMapsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListCertificateMapsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_certificate_maps(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateMapsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +def test_list_certificate_maps_rest_required_fields( + request_type=certificate_manager.ListCertificateMapsRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_certificate_maps._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_certificate_maps._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificateMapsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.ListCertificateMapsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_certificate_maps(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_certificate_maps_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_certificate_maps._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_certificate_maps_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_list_certificate_maps" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_list_certificate_maps" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.ListCertificateMapsRequest.pb( + certificate_manager.ListCertificateMapsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = ( + certificate_manager.ListCertificateMapsResponse.to_json( + certificate_manager.ListCertificateMapsResponse() + ) + ) + + request = certificate_manager.ListCertificateMapsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.ListCertificateMapsResponse() + + client.list_certificate_maps( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_certificate_maps_rest_bad_request( + transport: str = "rest", request_type=certificate_manager.ListCertificateMapsRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_certificate_maps(request) + + +def test_list_certificate_maps_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificateMapsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListCertificateMapsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_certificate_maps(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/certificateMaps" + % client.transport._host, + args[1], + ) + + +def test_list_certificate_maps_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_certificate_maps( + certificate_manager.ListCertificateMapsRequest(), + parent="parent_value", + ) + + +def test_list_certificate_maps_rest_pager(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + ], + next_page_token="abc", + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[], + next_page_token="def", + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + ], + next_page_token="ghi", + ), + certificate_manager.ListCertificateMapsResponse( + certificate_maps=[ + certificate_manager.CertificateMap(), + certificate_manager.CertificateMap(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + certificate_manager.ListCertificateMapsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_certificate_maps(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_manager.CertificateMap) for i in results) + + pages = list(client.list_certificate_maps(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.GetCertificateMapRequest, + dict, + ], +) +def test_get_certificate_map_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.CertificateMap( + name="name_value", + description="description_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.CertificateMap.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_certificate_map(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.CertificateMap) + assert response.name == "name_value" + assert response.description == "description_value" + + +def test_get_certificate_map_rest_required_fields( + request_type=certificate_manager.GetCertificateMapRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_certificate_map._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_certificate_map._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.CertificateMap() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.CertificateMap.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_certificate_map(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_certificate_map_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_certificate_map._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_certificate_map_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_get_certificate_map" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_get_certificate_map" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.GetCertificateMapRequest.pb( + certificate_manager.GetCertificateMapRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_manager.CertificateMap.to_json( + certificate_manager.CertificateMap() + ) + + request = certificate_manager.GetCertificateMapRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.CertificateMap() + + client.get_certificate_map( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_certificate_map_rest_bad_request( + transport: str = "rest", request_type=certificate_manager.GetCertificateMapRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_certificate_map(request) + + +def test_get_certificate_map_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.CertificateMap() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.CertificateMap.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_certificate_map(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/certificateMaps/*}" + % client.transport._host, + args[1], + ) + + +def test_get_certificate_map_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_certificate_map( + certificate_manager.GetCertificateMapRequest(), + name="name_value", + ) + + +def test_get_certificate_map_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.CreateCertificateMapRequest, + dict, + ], +) +def test_create_certificate_map_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["certificate_map"] = { + "name": "name_value", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "gclb_targets": [ + { + "target_https_proxy": "target_https_proxy_value", + "target_ssl_proxy": "target_ssl_proxy_value", + "ip_configs": [{"ip_address": "ip_address_value", "ports": [569, 570]}], + } + ], + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.create_certificate_map(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_create_certificate_map_rest_required_fields( + request_type=certificate_manager.CreateCertificateMapRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["certificate_map_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + assert "certificateMapId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_certificate_map._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "certificateMapId" in jsonified_request + assert jsonified_request["certificateMapId"] == request_init["certificate_map_id"] + + jsonified_request["parent"] = "parent_value" + jsonified_request["certificateMapId"] = "certificate_map_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_certificate_map._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("certificate_map_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "certificateMapId" in jsonified_request + assert jsonified_request["certificateMapId"] == "certificate_map_id_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_certificate_map(request) + + expected_params = [ + ( + "certificateMapId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_certificate_map_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_certificate_map._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("certificateMapId",)) + & set( + ( + "parent", + "certificateMapId", + "certificateMap", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_certificate_map_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_create_certificate_map" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_create_certificate_map" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.CreateCertificateMapRequest.pb( + certificate_manager.CreateCertificateMapRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_manager.CreateCertificateMapRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_certificate_map( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_certificate_map_rest_bad_request( + transport: str = "rest", + request_type=certificate_manager.CreateCertificateMapRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["certificate_map"] = { + "name": "name_value", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "gclb_targets": [ + { + "target_https_proxy": "target_https_proxy_value", + "target_ssl_proxy": "target_ssl_proxy_value", + "ip_configs": [{"ip_address": "ip_address_value", "ports": [569, 570]}], + } + ], + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_certificate_map(request) + + +def test_create_certificate_map_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + certificate_map=certificate_manager.CertificateMap(name="name_value"), + certificate_map_id="certificate_map_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_certificate_map(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/certificateMaps" + % client.transport._host, + args[1], + ) + + +def test_create_certificate_map_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_certificate_map( + certificate_manager.CreateCertificateMapRequest(), + parent="parent_value", + certificate_map=certificate_manager.CertificateMap(name="name_value"), + certificate_map_id="certificate_map_id_value", + ) + + +def test_create_certificate_map_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.UpdateCertificateMapRequest, + dict, + ], +) +def test_update_certificate_map_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "certificate_map": { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + } + request_init["certificate_map"] = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "gclb_targets": [ + { + "target_https_proxy": "target_https_proxy_value", + "target_ssl_proxy": "target_ssl_proxy_value", + "ip_configs": [{"ip_address": "ip_address_value", "ports": [569, 570]}], + } + ], + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_certificate_map(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_update_certificate_map_rest_required_fields( + request_type=certificate_manager.UpdateCertificateMapRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_certificate_map._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_certificate_map._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_certificate_map(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_certificate_map_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_certificate_map._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "certificateMap", + "updateMask", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_certificate_map_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_update_certificate_map" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_update_certificate_map" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.UpdateCertificateMapRequest.pb( + certificate_manager.UpdateCertificateMapRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_manager.UpdateCertificateMapRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.update_certificate_map( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_certificate_map_rest_bad_request( + transport: str = "rest", + request_type=certificate_manager.UpdateCertificateMapRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "certificate_map": { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + } + request_init["certificate_map"] = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "gclb_targets": [ + { + "target_https_proxy": "target_https_proxy_value", + "target_ssl_proxy": "target_ssl_proxy_value", + "ip_configs": [{"ip_address": "ip_address_value", "ports": [569, 570]}], + } + ], + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_certificate_map(request) + + +def test_update_certificate_map_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "certificate_map": { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + certificate_map=certificate_manager.CertificateMap(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_certificate_map(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{certificate_map.name=projects/*/locations/*/certificateMaps/*}" + % client.transport._host, + args[1], + ) + + +def test_update_certificate_map_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_certificate_map( + certificate_manager.UpdateCertificateMapRequest(), + certificate_map=certificate_manager.CertificateMap(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_update_certificate_map_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.DeleteCertificateMapRequest, + dict, + ], +) +def test_delete_certificate_map_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_certificate_map(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_delete_certificate_map_rest_required_fields( + request_type=certificate_manager.DeleteCertificateMapRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_certificate_map._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_certificate_map._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_certificate_map(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_certificate_map_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_certificate_map._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_certificate_map_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_delete_certificate_map" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_delete_certificate_map" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.DeleteCertificateMapRequest.pb( + certificate_manager.DeleteCertificateMapRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_manager.DeleteCertificateMapRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.delete_certificate_map( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_certificate_map_rest_bad_request( + transport: str = "rest", + request_type=certificate_manager.DeleteCertificateMapRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_certificate_map(request) + + +def test_delete_certificate_map_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_certificate_map(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/certificateMaps/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_certificate_map_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_certificate_map( + certificate_manager.DeleteCertificateMapRequest(), + name="name_value", + ) + + +def test_delete_certificate_map_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.ListCertificateMapEntriesRequest, + dict, + ], +) +def test_list_certificate_map_entries_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificateMapEntriesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListCertificateMapEntriesResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_certificate_map_entries(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateMapEntriesPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +def test_list_certificate_map_entries_rest_required_fields( + request_type=certificate_manager.ListCertificateMapEntriesRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_certificate_map_entries._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_certificate_map_entries._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificateMapEntriesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.ListCertificateMapEntriesResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_certificate_map_entries(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_certificate_map_entries_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_certificate_map_entries._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_certificate_map_entries_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.CertificateManagerRestInterceptor, + "post_list_certificate_map_entries", + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_list_certificate_map_entries" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.ListCertificateMapEntriesRequest.pb( + certificate_manager.ListCertificateMapEntriesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = ( + certificate_manager.ListCertificateMapEntriesResponse.to_json( + certificate_manager.ListCertificateMapEntriesResponse() + ) + ) + + request = certificate_manager.ListCertificateMapEntriesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.ListCertificateMapEntriesResponse() + + client.list_certificate_map_entries( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_certificate_map_entries_rest_bad_request( + transport: str = "rest", + request_type=certificate_manager.ListCertificateMapEntriesRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_certificate_map_entries(request) + + +def test_list_certificate_map_entries_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListCertificateMapEntriesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListCertificateMapEntriesResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_certificate_map_entries(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/certificateMaps/*}/certificateMapEntries" + % client.transport._host, + args[1], + ) + + +def test_list_certificate_map_entries_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_certificate_map_entries( + certificate_manager.ListCertificateMapEntriesRequest(), + parent="parent_value", + ) + + +def test_list_certificate_map_entries_rest_pager(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + ], + next_page_token="abc", + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[], + next_page_token="def", + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + ], + next_page_token="ghi", + ), + certificate_manager.ListCertificateMapEntriesResponse( + certificate_map_entries=[ + certificate_manager.CertificateMapEntry(), + certificate_manager.CertificateMapEntry(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + certificate_manager.ListCertificateMapEntriesResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + + pager = client.list_certificate_map_entries(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all( + isinstance(i, certificate_manager.CertificateMapEntry) for i in results + ) + + pages = list(client.list_certificate_map_entries(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.GetCertificateMapEntryRequest, + dict, + ], +) +def test_get_certificate_map_entry_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.CertificateMapEntry( + name="name_value", + description="description_value", + certificates=["certificates_value"], + state=certificate_manager.ServingState.ACTIVE, + hostname="hostname_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.CertificateMapEntry.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_certificate_map_entry(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.CertificateMapEntry) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.certificates == ["certificates_value"] + assert response.state == certificate_manager.ServingState.ACTIVE + + +def test_get_certificate_map_entry_rest_required_fields( + request_type=certificate_manager.GetCertificateMapEntryRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_certificate_map_entry._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_certificate_map_entry._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.CertificateMapEntry() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.CertificateMapEntry.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_certificate_map_entry(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_certificate_map_entry_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_certificate_map_entry._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_certificate_map_entry_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_get_certificate_map_entry" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_get_certificate_map_entry" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.GetCertificateMapEntryRequest.pb( + certificate_manager.GetCertificateMapEntryRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_manager.CertificateMapEntry.to_json( + certificate_manager.CertificateMapEntry() + ) + + request = certificate_manager.GetCertificateMapEntryRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.CertificateMapEntry() + + client.get_certificate_map_entry( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_certificate_map_entry_rest_bad_request( + transport: str = "rest", + request_type=certificate_manager.GetCertificateMapEntryRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_certificate_map_entry(request) + + +def test_get_certificate_map_entry_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.CertificateMapEntry() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.CertificateMapEntry.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_certificate_map_entry(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}" + % client.transport._host, + args[1], + ) + + +def test_get_certificate_map_entry_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_certificate_map_entry( + certificate_manager.GetCertificateMapEntryRequest(), + name="name_value", + ) + + +def test_get_certificate_map_entry_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.CreateCertificateMapEntryRequest, + dict, + ], +) +def test_create_certificate_map_entry_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + request_init["certificate_map_entry"] = { + "name": "name_value", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "hostname": "hostname_value", + "matcher": 1, + "certificates": ["certificates_value1", "certificates_value2"], + "state": 1, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.create_certificate_map_entry(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_create_certificate_map_entry_rest_required_fields( + request_type=certificate_manager.CreateCertificateMapEntryRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["certificate_map_entry_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + assert "certificateMapEntryId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_certificate_map_entry._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "certificateMapEntryId" in jsonified_request + assert ( + jsonified_request["certificateMapEntryId"] + == request_init["certificate_map_entry_id"] + ) + + jsonified_request["parent"] = "parent_value" + jsonified_request["certificateMapEntryId"] = "certificate_map_entry_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_certificate_map_entry._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("certificate_map_entry_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "certificateMapEntryId" in jsonified_request + assert ( + jsonified_request["certificateMapEntryId"] == "certificate_map_entry_id_value" + ) + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_certificate_map_entry(request) + + expected_params = [ + ( + "certificateMapEntryId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_certificate_map_entry_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_certificate_map_entry._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("certificateMapEntryId",)) + & set( + ( + "parent", + "certificateMapEntryId", + "certificateMapEntry", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_certificate_map_entry_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, + "post_create_certificate_map_entry", + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_create_certificate_map_entry" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.CreateCertificateMapEntryRequest.pb( + certificate_manager.CreateCertificateMapEntryRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_manager.CreateCertificateMapEntryRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_certificate_map_entry( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_certificate_map_entry_rest_bad_request( + transport: str = "rest", + request_type=certificate_manager.CreateCertificateMapEntryRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + request_init["certificate_map_entry"] = { + "name": "name_value", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "hostname": "hostname_value", + "matcher": 1, + "certificates": ["certificates_value1", "certificates_value2"], + "state": 1, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_certificate_map_entry(request) + + +def test_create_certificate_map_entry_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/certificateMaps/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + certificate_map_entry=certificate_manager.CertificateMapEntry( + name="name_value" + ), + certificate_map_entry_id="certificate_map_entry_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_certificate_map_entry(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/certificateMaps/*}/certificateMapEntries" + % client.transport._host, + args[1], + ) + + +def test_create_certificate_map_entry_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_certificate_map_entry( + certificate_manager.CreateCertificateMapEntryRequest(), + parent="parent_value", + certificate_map_entry=certificate_manager.CertificateMapEntry( + name="name_value" + ), + certificate_map_entry_id="certificate_map_entry_id_value", + ) + + +def test_create_certificate_map_entry_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.UpdateCertificateMapEntryRequest, + dict, + ], +) +def test_update_certificate_map_entry_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "certificate_map_entry": { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4" + } + } + request_init["certificate_map_entry"] = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "hostname": "hostname_value", + "matcher": 1, + "certificates": ["certificates_value1", "certificates_value2"], + "state": 1, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_certificate_map_entry(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_update_certificate_map_entry_rest_required_fields( + request_type=certificate_manager.UpdateCertificateMapEntryRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_certificate_map_entry._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_certificate_map_entry._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_certificate_map_entry(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_certificate_map_entry_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_certificate_map_entry._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "certificateMapEntry", + "updateMask", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_certificate_map_entry_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, + "post_update_certificate_map_entry", + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_update_certificate_map_entry" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.UpdateCertificateMapEntryRequest.pb( + certificate_manager.UpdateCertificateMapEntryRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_manager.UpdateCertificateMapEntryRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.update_certificate_map_entry( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_certificate_map_entry_rest_bad_request( + transport: str = "rest", + request_type=certificate_manager.UpdateCertificateMapEntryRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "certificate_map_entry": { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4" + } + } + request_init["certificate_map_entry"] = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4", + "description": "description_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "hostname": "hostname_value", + "matcher": 1, + "certificates": ["certificates_value1", "certificates_value2"], + "state": 1, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_certificate_map_entry(request) + + +def test_update_certificate_map_entry_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "certificate_map_entry": { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4" + } + } + + # get truthy value for each flattened field + mock_args = dict( + certificate_map_entry=certificate_manager.CertificateMapEntry( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_certificate_map_entry(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{certificate_map_entry.name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}" + % client.transport._host, + args[1], + ) + + +def test_update_certificate_map_entry_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_certificate_map_entry( + certificate_manager.UpdateCertificateMapEntryRequest(), + certificate_map_entry=certificate_manager.CertificateMapEntry( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_update_certificate_map_entry_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.DeleteCertificateMapEntryRequest, + dict, + ], +) +def test_delete_certificate_map_entry_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_certificate_map_entry(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_delete_certificate_map_entry_rest_required_fields( + request_type=certificate_manager.DeleteCertificateMapEntryRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_certificate_map_entry._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_certificate_map_entry._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_certificate_map_entry(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_certificate_map_entry_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_certificate_map_entry._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_certificate_map_entry_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, + "post_delete_certificate_map_entry", + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_delete_certificate_map_entry" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.DeleteCertificateMapEntryRequest.pb( + certificate_manager.DeleteCertificateMapEntryRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_manager.DeleteCertificateMapEntryRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.delete_certificate_map_entry( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_certificate_map_entry_rest_bad_request( + transport: str = "rest", + request_type=certificate_manager.DeleteCertificateMapEntryRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_certificate_map_entry(request) + + +def test_delete_certificate_map_entry_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/certificateMaps/sample3/certificateMapEntries/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_certificate_map_entry(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/certificateMaps/*/certificateMapEntries/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_certificate_map_entry_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_certificate_map_entry( + certificate_manager.DeleteCertificateMapEntryRequest(), + name="name_value", + ) + + +def test_delete_certificate_map_entry_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.ListDnsAuthorizationsRequest, + dict, + ], +) +def test_list_dns_authorizations_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListDnsAuthorizationsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListDnsAuthorizationsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_dns_authorizations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDnsAuthorizationsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +def test_list_dns_authorizations_rest_required_fields( + request_type=certificate_manager.ListDnsAuthorizationsRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_dns_authorizations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_dns_authorizations._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListDnsAuthorizationsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.ListDnsAuthorizationsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_dns_authorizations(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_dns_authorizations_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_dns_authorizations._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_dns_authorizations_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_list_dns_authorizations" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_list_dns_authorizations" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.ListDnsAuthorizationsRequest.pb( + certificate_manager.ListDnsAuthorizationsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = ( + certificate_manager.ListDnsAuthorizationsResponse.to_json( + certificate_manager.ListDnsAuthorizationsResponse() + ) + ) + + request = certificate_manager.ListDnsAuthorizationsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.ListDnsAuthorizationsResponse() + + client.list_dns_authorizations( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_dns_authorizations_rest_bad_request( + transport: str = "rest", + request_type=certificate_manager.ListDnsAuthorizationsRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_dns_authorizations(request) + + +def test_list_dns_authorizations_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.ListDnsAuthorizationsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.ListDnsAuthorizationsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_dns_authorizations(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/dnsAuthorizations" + % client.transport._host, + args[1], + ) + + +def test_list_dns_authorizations_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_dns_authorizations( + certificate_manager.ListDnsAuthorizationsRequest(), + parent="parent_value", + ) + + +def test_list_dns_authorizations_rest_pager(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + ], + next_page_token="abc", + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[], + next_page_token="def", + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + ], + next_page_token="ghi", + ), + certificate_manager.ListDnsAuthorizationsResponse( + dns_authorizations=[ + certificate_manager.DnsAuthorization(), + certificate_manager.DnsAuthorization(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + certificate_manager.ListDnsAuthorizationsResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_dns_authorizations(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, certificate_manager.DnsAuthorization) for i in results) + + pages = list(client.list_dns_authorizations(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.GetDnsAuthorizationRequest, + dict, + ], +) +def test_get_dns_authorization_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/dnsAuthorizations/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.DnsAuthorization( + name="name_value", + description="description_value", + domain="domain_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.DnsAuthorization.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_dns_authorization(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_manager.DnsAuthorization) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.domain == "domain_value" + + +def test_get_dns_authorization_rest_required_fields( + request_type=certificate_manager.GetDnsAuthorizationRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_dns_authorization._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_dns_authorization._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_manager.DnsAuthorization() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_manager.DnsAuthorization.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_dns_authorization(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_dns_authorization_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_dns_authorization._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_dns_authorization_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_get_dns_authorization" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_get_dns_authorization" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.GetDnsAuthorizationRequest.pb( + certificate_manager.GetDnsAuthorizationRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = certificate_manager.DnsAuthorization.to_json( + certificate_manager.DnsAuthorization() + ) + + request = certificate_manager.GetDnsAuthorizationRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_manager.DnsAuthorization() + + client.get_dns_authorization( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_dns_authorization_rest_bad_request( + transport: str = "rest", request_type=certificate_manager.GetDnsAuthorizationRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/dnsAuthorizations/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_dns_authorization(request) + + +def test_get_dns_authorization_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_manager.DnsAuthorization() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/dnsAuthorizations/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_manager.DnsAuthorization.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_dns_authorization(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/dnsAuthorizations/*}" + % client.transport._host, + args[1], + ) + + +def test_get_dns_authorization_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_dns_authorization( + certificate_manager.GetDnsAuthorizationRequest(), + name="name_value", + ) + + +def test_get_dns_authorization_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.CreateDnsAuthorizationRequest, + dict, + ], +) +def test_create_dns_authorization_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["dns_authorization"] = { + "name": "name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "description": "description_value", + "domain": "domain_value", + "dns_resource_record": { + "name": "name_value", + "type_": "type__value", + "data": "data_value", + }, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.create_dns_authorization(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_create_dns_authorization_rest_required_fields( + request_type=certificate_manager.CreateDnsAuthorizationRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["dns_authorization_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + assert "dnsAuthorizationId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_dns_authorization._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "dnsAuthorizationId" in jsonified_request + assert ( + jsonified_request["dnsAuthorizationId"] == request_init["dns_authorization_id"] + ) + + jsonified_request["parent"] = "parent_value" + jsonified_request["dnsAuthorizationId"] = "dns_authorization_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_dns_authorization._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("dns_authorization_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "dnsAuthorizationId" in jsonified_request + assert jsonified_request["dnsAuthorizationId"] == "dns_authorization_id_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_dns_authorization(request) + + expected_params = [ + ( + "dnsAuthorizationId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_dns_authorization_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_dns_authorization._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("dnsAuthorizationId",)) + & set( + ( + "parent", + "dnsAuthorizationId", + "dnsAuthorization", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_dns_authorization_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_create_dns_authorization" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_create_dns_authorization" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.CreateDnsAuthorizationRequest.pb( + certificate_manager.CreateDnsAuthorizationRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_manager.CreateDnsAuthorizationRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_dns_authorization( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_dns_authorization_rest_bad_request( + transport: str = "rest", + request_type=certificate_manager.CreateDnsAuthorizationRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["dns_authorization"] = { + "name": "name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "description": "description_value", + "domain": "domain_value", + "dns_resource_record": { + "name": "name_value", + "type_": "type__value", + "data": "data_value", + }, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_dns_authorization(request) + + +def test_create_dns_authorization_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + dns_authorization=certificate_manager.DnsAuthorization(name="name_value"), + dns_authorization_id="dns_authorization_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_dns_authorization(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/dnsAuthorizations" + % client.transport._host, + args[1], + ) + + +def test_create_dns_authorization_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_dns_authorization( + certificate_manager.CreateDnsAuthorizationRequest(), + parent="parent_value", + dns_authorization=certificate_manager.DnsAuthorization(name="name_value"), + dns_authorization_id="dns_authorization_id_value", + ) + + +def test_create_dns_authorization_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.UpdateDnsAuthorizationRequest, + dict, + ], +) +def test_update_dns_authorization_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "dns_authorization": { + "name": "projects/sample1/locations/sample2/dnsAuthorizations/sample3" + } + } + request_init["dns_authorization"] = { + "name": "projects/sample1/locations/sample2/dnsAuthorizations/sample3", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "description": "description_value", + "domain": "domain_value", + "dns_resource_record": { + "name": "name_value", + "type_": "type__value", + "data": "data_value", + }, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_dns_authorization(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_update_dns_authorization_rest_required_fields( + request_type=certificate_manager.UpdateDnsAuthorizationRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_dns_authorization._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_dns_authorization._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_dns_authorization(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_dns_authorization_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_dns_authorization._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "dnsAuthorization", + "updateMask", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_dns_authorization_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_update_dns_authorization" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_update_dns_authorization" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.UpdateDnsAuthorizationRequest.pb( + certificate_manager.UpdateDnsAuthorizationRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_manager.UpdateDnsAuthorizationRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.update_dns_authorization( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_dns_authorization_rest_bad_request( + transport: str = "rest", + request_type=certificate_manager.UpdateDnsAuthorizationRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "dns_authorization": { + "name": "projects/sample1/locations/sample2/dnsAuthorizations/sample3" + } + } + request_init["dns_authorization"] = { + "name": "projects/sample1/locations/sample2/dnsAuthorizations/sample3", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "description": "description_value", + "domain": "domain_value", + "dns_resource_record": { + "name": "name_value", + "type_": "type__value", + "data": "data_value", + }, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_dns_authorization(request) + + +def test_update_dns_authorization_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "dns_authorization": { + "name": "projects/sample1/locations/sample2/dnsAuthorizations/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + dns_authorization=certificate_manager.DnsAuthorization(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_dns_authorization(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{dns_authorization.name=projects/*/locations/*/dnsAuthorizations/*}" + % client.transport._host, + args[1], + ) + + +def test_update_dns_authorization_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_dns_authorization( + certificate_manager.UpdateDnsAuthorizationRequest(), + dns_authorization=certificate_manager.DnsAuthorization(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_update_dns_authorization_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_manager.DeleteDnsAuthorizationRequest, + dict, + ], +) +def test_delete_dns_authorization_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/dnsAuthorizations/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_dns_authorization(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_delete_dns_authorization_rest_required_fields( + request_type=certificate_manager.DeleteDnsAuthorizationRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_dns_authorization._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_dns_authorization._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_dns_authorization(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_dns_authorization_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_dns_authorization._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_dns_authorization_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, "post_delete_dns_authorization" + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, "pre_delete_dns_authorization" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_manager.DeleteDnsAuthorizationRequest.pb( + certificate_manager.DeleteDnsAuthorizationRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_manager.DeleteDnsAuthorizationRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.delete_dns_authorization( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_dns_authorization_rest_bad_request( + transport: str = "rest", + request_type=certificate_manager.DeleteDnsAuthorizationRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/dnsAuthorizations/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_dns_authorization(request) + + +def test_delete_dns_authorization_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/dnsAuthorizations/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_dns_authorization(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/dnsAuthorizations/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_dns_authorization_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_dns_authorization( + certificate_manager.DeleteDnsAuthorizationRequest(), + name="name_value", + ) + + +def test_delete_dns_authorization_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_issuance_config.ListCertificateIssuanceConfigsRequest, + dict, + ], +) +def test_list_certificate_issuance_configs_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse.pb( + return_value + ) + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_certificate_issuance_configs(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateIssuanceConfigsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +def test_list_certificate_issuance_configs_rest_required_fields( + request_type=certificate_issuance_config.ListCertificateIssuanceConfigsRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_certificate_issuance_configs._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_certificate_issuance_configs._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_issuance_config.ListCertificateIssuanceConfigsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse.pb( + return_value + ) + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_certificate_issuance_configs(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_certificate_issuance_configs_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = ( + transport.list_certificate_issuance_configs._get_unset_required_fields({}) + ) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_certificate_issuance_configs_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.CertificateManagerRestInterceptor, + "post_list_certificate_issuance_configs", + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, + "pre_list_certificate_issuance_configs", + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = ( + certificate_issuance_config.ListCertificateIssuanceConfigsRequest.pb( + certificate_issuance_config.ListCertificateIssuanceConfigsRequest() + ) + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse.to_json( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse() + ) + ) + + request = certificate_issuance_config.ListCertificateIssuanceConfigsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse() + ) + + client.list_certificate_issuance_configs( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_certificate_issuance_configs_rest_bad_request( + transport: str = "rest", + request_type=certificate_issuance_config.ListCertificateIssuanceConfigsRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_certificate_issuance_configs(request) + + +def test_list_certificate_issuance_configs_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse() + ) + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse.pb( + return_value + ) + ) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_certificate_issuance_configs(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/certificateIssuanceConfigs" + % client.transport._host, + args[1], + ) + + +def test_list_certificate_issuance_configs_rest_flattened_error( + transport: str = "rest", +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_certificate_issuance_configs( + certificate_issuance_config.ListCertificateIssuanceConfigsRequest(), + parent="parent_value", + ) + + +def test_list_certificate_issuance_configs_rest_pager(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + ], + next_page_token="abc", + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[], + next_page_token="def", + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + ], + next_page_token="ghi", + ), + certificate_issuance_config.ListCertificateIssuanceConfigsResponse( + certificate_issuance_configs=[ + certificate_issuance_config.CertificateIssuanceConfig(), + certificate_issuance_config.CertificateIssuanceConfig(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + certificate_issuance_config.ListCertificateIssuanceConfigsResponse.to_json( + x + ) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_certificate_issuance_configs(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all( + isinstance(i, certificate_issuance_config.CertificateIssuanceConfig) + for i in results + ) + + pages = list( + client.list_certificate_issuance_configs(request=sample_request).pages + ) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_issuance_config.GetCertificateIssuanceConfigRequest, + dict, + ], +) +def test_get_certificate_issuance_config_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_issuance_config.CertificateIssuanceConfig( + name="name_value", + description="description_value", + rotation_window_percentage=2788, + key_algorithm=certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048, + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_issuance_config.CertificateIssuanceConfig.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_certificate_issuance_config(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, certificate_issuance_config.CertificateIssuanceConfig) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.rotation_window_percentage == 2788 + assert ( + response.key_algorithm + == certificate_issuance_config.CertificateIssuanceConfig.KeyAlgorithm.RSA_2048 + ) + + +def test_get_certificate_issuance_config_rest_required_fields( + request_type=certificate_issuance_config.GetCertificateIssuanceConfigRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_certificate_issuance_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_certificate_issuance_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = certificate_issuance_config.CertificateIssuanceConfig() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = certificate_issuance_config.CertificateIssuanceConfig.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_certificate_issuance_config(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_certificate_issuance_config_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_certificate_issuance_config._get_unset_required_fields( + {} + ) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_certificate_issuance_config_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.CertificateManagerRestInterceptor, + "post_get_certificate_issuance_config", + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, + "pre_get_certificate_issuance_config", + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = certificate_issuance_config.GetCertificateIssuanceConfigRequest.pb( + certificate_issuance_config.GetCertificateIssuanceConfigRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = ( + certificate_issuance_config.CertificateIssuanceConfig.to_json( + certificate_issuance_config.CertificateIssuanceConfig() + ) + ) + + request = certificate_issuance_config.GetCertificateIssuanceConfigRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = certificate_issuance_config.CertificateIssuanceConfig() + + client.get_certificate_issuance_config( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_certificate_issuance_config_rest_bad_request( + transport: str = "rest", + request_type=certificate_issuance_config.GetCertificateIssuanceConfigRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_certificate_issuance_config(request) + + +def test_get_certificate_issuance_config_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = certificate_issuance_config.CertificateIssuanceConfig() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = certificate_issuance_config.CertificateIssuanceConfig.pb( + return_value + ) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_certificate_issuance_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/certificateIssuanceConfigs/*}" + % client.transport._host, + args[1], + ) + + +def test_get_certificate_issuance_config_rest_flattened_error(transport: str = "rest"): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_certificate_issuance_config( + certificate_issuance_config.GetCertificateIssuanceConfigRequest(), + name="name_value", + ) + + +def test_get_certificate_issuance_config_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, + dict, + ], +) +def test_create_certificate_issuance_config_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["certificate_issuance_config"] = { + "name": "name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "description": "description_value", + "certificate_authority_config": { + "certificate_authority_service_config": {"ca_pool": "ca_pool_value"} + }, + "lifetime": {"seconds": 751, "nanos": 543}, + "rotation_window_percentage": 2788, + "key_algorithm": 1, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.create_certificate_issuance_config(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_create_certificate_issuance_config_rest_required_fields( + request_type=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["certificate_issuance_config_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + assert "certificateIssuanceConfigId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_certificate_issuance_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "certificateIssuanceConfigId" in jsonified_request + assert ( + jsonified_request["certificateIssuanceConfigId"] + == request_init["certificate_issuance_config_id"] + ) + + jsonified_request["parent"] = "parent_value" + jsonified_request[ + "certificateIssuanceConfigId" + ] = "certificate_issuance_config_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_certificate_issuance_config._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("certificate_issuance_config_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "certificateIssuanceConfigId" in jsonified_request + assert ( + jsonified_request["certificateIssuanceConfigId"] + == "certificate_issuance_config_id_value" + ) + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_certificate_issuance_config(request) + + expected_params = [ + ( + "certificateIssuanceConfigId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_certificate_issuance_config_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = ( + transport.create_certificate_issuance_config._get_unset_required_fields({}) + ) + assert set(unset_fields) == ( + set(("certificateIssuanceConfigId",)) + & set( + ( + "parent", + "certificateIssuanceConfigId", + "certificateIssuanceConfig", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_certificate_issuance_config_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, + "post_create_certificate_issuance_config", + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, + "pre_create_certificate_issuance_config", + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = ( + gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest.pb( + gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() + ) + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = ( + gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest() + ) + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_certificate_issuance_config( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_certificate_issuance_config_rest_bad_request( + transport: str = "rest", + request_type=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["certificate_issuance_config"] = { + "name": "name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "description": "description_value", + "certificate_authority_config": { + "certificate_authority_service_config": {"ca_pool": "ca_pool_value"} + }, + "lifetime": {"seconds": 751, "nanos": 543}, + "rotation_window_percentage": 2788, + "key_algorithm": 1, + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_certificate_issuance_config(request) + + +def test_create_certificate_issuance_config_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig( + name="name_value" + ), + certificate_issuance_config_id="certificate_issuance_config_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_certificate_issuance_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/certificateIssuanceConfigs" + % client.transport._host, + args[1], + ) + + +def test_create_certificate_issuance_config_rest_flattened_error( + transport: str = "rest", +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_certificate_issuance_config( + gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest(), + parent="parent_value", + certificate_issuance_config=gcc_certificate_issuance_config.CertificateIssuanceConfig( + name="name_value" + ), + certificate_issuance_config_id="certificate_issuance_config_id_value", + ) + + +def test_create_certificate_issuance_config_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, + dict, + ], +) +def test_delete_certificate_issuance_config_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_certificate_issuance_config(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_delete_certificate_issuance_config_rest_required_fields( + request_type=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, +): + transport_class = transports.CertificateManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_certificate_issuance_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_certificate_issuance_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_certificate_issuance_config(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_certificate_issuance_config_rest_unset_required_fields(): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = ( + transport.delete_certificate_issuance_config._get_unset_required_fields({}) + ) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_certificate_issuance_config_rest_interceptors(null_interceptor): + transport = transports.CertificateManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.CertificateManagerRestInterceptor(), + ) + client = CertificateManagerClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.CertificateManagerRestInterceptor, + "post_delete_certificate_issuance_config", + ) as post, mock.patch.object( + transports.CertificateManagerRestInterceptor, + "pre_delete_certificate_issuance_config", + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = ( + certificate_issuance_config.DeleteCertificateIssuanceConfigRequest.pb( + certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() + ) + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson( + operations_pb2.Operation() + ) + + request = certificate_issuance_config.DeleteCertificateIssuanceConfigRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.delete_certificate_issuance_config( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_certificate_issuance_config_rest_bad_request( + transport: str = "rest", + request_type=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_certificate_issuance_config(request) + + +def test_delete_certificate_issuance_config_rest_flattened(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/certificateIssuanceConfigs/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_certificate_issuance_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/certificateIssuanceConfigs/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_certificate_issuance_config_rest_flattened_error( + transport: str = "rest", +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_certificate_issuance_config( + certificate_issuance_config.DeleteCertificateIssuanceConfigRequest(), + name="name_value", + ) + + +def test_delete_certificate_issuance_config_rest_error(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.CertificateManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.CertificateManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CertificateManagerClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.CertificateManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CertificateManagerClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CertificateManagerClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.CertificateManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CertificateManagerClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.CertificateManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = CertificateManagerClient(transport=transport) + assert client.transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.CertificateManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.CertificateManagerGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.CertificateManagerGrpcTransport, + transports.CertificateManagerGrpcAsyncIOTransport, + transports.CertificateManagerRestTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "rest", + ], +) +def test_transport_kind(transport_name): + transport = CertificateManagerClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CertificateManagerGrpcTransport, + ) + + +def test_certificate_manager_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.CertificateManagerTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json", + ) + + +def test_certificate_manager_base_transport(): + # Instantiate the base transport. + with mock.patch( + "google.cloud.certificate_manager_v1.services.certificate_manager.transports.CertificateManagerTransport.__init__" + ) as Transport: + Transport.return_value = None + transport = transports.CertificateManagerTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly # raise NotImplementedError. methods = ( "list_certificates", @@ -8085,6 +15655,7 @@ def test_certificate_manager_transport_auth_adc(transport_class): [ transports.CertificateManagerGrpcTransport, transports.CertificateManagerGrpcAsyncIOTransport, + transports.CertificateManagerRestTransport, ], ) def test_certificate_manager_transport_auth_gdch_credentials(transport_class): @@ -8184,11 +15755,40 @@ def test_certificate_manager_grpc_transport_client_cert_source_for_mtls( ) +def test_certificate_manager_http_transport_client_cert_source_for_mtls(): + cred = ga_credentials.AnonymousCredentials() + with mock.patch( + "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel" + ) as mock_configure_mtls_channel: + transports.CertificateManagerRestTransport( + credentials=cred, client_cert_source_for_mtls=client_cert_source_callback + ) + mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) + + +def test_certificate_manager_rest_lro_client(): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.AbstractOperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + @pytest.mark.parametrize( "transport_name", [ "grpc", "grpc_asyncio", + "rest", ], ) def test_certificate_manager_host_no_port(transport_name): @@ -8199,7 +15799,11 @@ def test_certificate_manager_host_no_port(transport_name): ), transport=transport_name, ) - assert client.transport._host == ("certificatemanager.googleapis.com:443") + assert client.transport._host == ( + "certificatemanager.googleapis.com:443" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://certificatemanager.googleapis.com" + ) @pytest.mark.parametrize( @@ -8207,6 +15811,7 @@ def test_certificate_manager_host_no_port(transport_name): [ "grpc", "grpc_asyncio", + "rest", ], ) def test_certificate_manager_host_with_port(transport_name): @@ -8217,7 +15822,102 @@ def test_certificate_manager_host_with_port(transport_name): ), transport=transport_name, ) - assert client.transport._host == ("certificatemanager.googleapis.com:8000") + assert client.transport._host == ( + "certificatemanager.googleapis.com:8000" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://certificatemanager.googleapis.com:8000" + ) + + +@pytest.mark.parametrize( + "transport_name", + [ + "rest", + ], +) +def test_certificate_manager_client_transport_session_collision(transport_name): + creds1 = ga_credentials.AnonymousCredentials() + creds2 = ga_credentials.AnonymousCredentials() + client1 = CertificateManagerClient( + credentials=creds1, + transport=transport_name, + ) + client2 = CertificateManagerClient( + credentials=creds2, + transport=transport_name, + ) + session1 = client1.transport.list_certificates._session + session2 = client2.transport.list_certificates._session + assert session1 != session2 + session1 = client1.transport.get_certificate._session + session2 = client2.transport.get_certificate._session + assert session1 != session2 + session1 = client1.transport.create_certificate._session + session2 = client2.transport.create_certificate._session + assert session1 != session2 + session1 = client1.transport.update_certificate._session + session2 = client2.transport.update_certificate._session + assert session1 != session2 + session1 = client1.transport.delete_certificate._session + session2 = client2.transport.delete_certificate._session + assert session1 != session2 + session1 = client1.transport.list_certificate_maps._session + session2 = client2.transport.list_certificate_maps._session + assert session1 != session2 + session1 = client1.transport.get_certificate_map._session + session2 = client2.transport.get_certificate_map._session + assert session1 != session2 + session1 = client1.transport.create_certificate_map._session + session2 = client2.transport.create_certificate_map._session + assert session1 != session2 + session1 = client1.transport.update_certificate_map._session + session2 = client2.transport.update_certificate_map._session + assert session1 != session2 + session1 = client1.transport.delete_certificate_map._session + session2 = client2.transport.delete_certificate_map._session + assert session1 != session2 + session1 = client1.transport.list_certificate_map_entries._session + session2 = client2.transport.list_certificate_map_entries._session + assert session1 != session2 + session1 = client1.transport.get_certificate_map_entry._session + session2 = client2.transport.get_certificate_map_entry._session + assert session1 != session2 + session1 = client1.transport.create_certificate_map_entry._session + session2 = client2.transport.create_certificate_map_entry._session + assert session1 != session2 + session1 = client1.transport.update_certificate_map_entry._session + session2 = client2.transport.update_certificate_map_entry._session + assert session1 != session2 + session1 = client1.transport.delete_certificate_map_entry._session + session2 = client2.transport.delete_certificate_map_entry._session + assert session1 != session2 + session1 = client1.transport.list_dns_authorizations._session + session2 = client2.transport.list_dns_authorizations._session + assert session1 != session2 + session1 = client1.transport.get_dns_authorization._session + session2 = client2.transport.get_dns_authorization._session + assert session1 != session2 + session1 = client1.transport.create_dns_authorization._session + session2 = client2.transport.create_dns_authorization._session + assert session1 != session2 + session1 = client1.transport.update_dns_authorization._session + session2 = client2.transport.update_dns_authorization._session + assert session1 != session2 + session1 = client1.transport.delete_dns_authorization._session + session2 = client2.transport.delete_dns_authorization._session + assert session1 != session2 + session1 = client1.transport.list_certificate_issuance_configs._session + session2 = client2.transport.list_certificate_issuance_configs._session + assert session1 != session2 + session1 = client1.transport.get_certificate_issuance_config._session + session2 = client2.transport.get_certificate_issuance_config._session + assert session1 != session2 + session1 = client1.transport.create_certificate_issuance_config._session + session2 = client2.transport.create_certificate_issuance_config._session + assert session1 != session2 + session1 = client1.transport.delete_certificate_issuance_config._session + session2 = client2.transport.delete_certificate_issuance_config._session + assert session1 != session2 def test_certificate_manager_grpc_transport_channel(): @@ -8689,6 +16389,352 @@ async def test_transport_close_async(): close.assert_called_once() +def test_get_location_rest_bad_request( + transport: str = "rest", request_type=locations_pb2.GetLocationRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2"}, request + ) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_location(request) + + +@pytest.mark.parametrize( + "request_type", + [ + locations_pb2.GetLocationRequest, + dict, + ], +) +def test_get_location_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {"name": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = locations_pb2.Location() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_location(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, locations_pb2.Location) + + +def test_list_locations_rest_bad_request( + transport: str = "rest", request_type=locations_pb2.ListLocationsRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict({"name": "projects/sample1"}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_locations(request) + + +@pytest.mark.parametrize( + "request_type", + [ + locations_pb2.ListLocationsRequest, + dict, + ], +) +def test_list_locations_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {"name": "projects/sample1"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = locations_pb2.ListLocationsResponse() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_locations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, locations_pb2.ListLocationsResponse) + + +def test_cancel_operation_rest_bad_request( + transport: str = "rest", request_type=operations_pb2.CancelOperationRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2/operations/sample3"}, request + ) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.cancel_operation(request) + + +@pytest.mark.parametrize( + "request_type", + [ + operations_pb2.CancelOperationRequest, + dict, + ], +) +def test_cancel_operation_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "{}" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.cancel_operation(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_operation_rest_bad_request( + transport: str = "rest", request_type=operations_pb2.DeleteOperationRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2/operations/sample3"}, request + ) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_operation(request) + + +@pytest.mark.parametrize( + "request_type", + [ + operations_pb2.DeleteOperationRequest, + dict, + ], +) +def test_delete_operation_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "{}" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_operation(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_get_operation_rest_bad_request( + transport: str = "rest", request_type=operations_pb2.GetOperationRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2/operations/sample3"}, request + ) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_operation(request) + + +@pytest.mark.parametrize( + "request_type", + [ + operations_pb2.GetOperationRequest, + dict, + ], +) +def test_get_operation_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_operation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +def test_list_operations_rest_bad_request( + transport: str = "rest", request_type=operations_pb2.ListOperationsRequest +): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2"}, request + ) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_operations(request) + + +@pytest.mark.parametrize( + "request_type", + [ + operations_pb2.ListOperationsRequest, + dict, + ], +) +def test_list_operations_rest(request_type): + client = CertificateManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {"name": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.ListOperationsResponse() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_operations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) + + def test_delete_operation(transport: str = "grpc"): client = CertificateManagerClient( credentials=ga_credentials.AnonymousCredentials(), @@ -9547,6 +17593,7 @@ async def test_get_location_from_dict_async(): def test_transport_close(): transports = { + "rest": "_session", "grpc": "_grpc_channel", } @@ -9564,6 +17611,7 @@ def test_transport_close(): def test_client_ctx(): transports = [ + "rest", "grpc", ] for transport in transports: