From 7770b9410325693c24c702b8a126a94078e3c605 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 14 May 2021 04:52:04 +0000 Subject: [PATCH 1/2] chore: upgrade gapic-generator-python to 0.46.3 PiperOrigin-RevId: 373649163 Source-Link: https://github.com/googleapis/googleapis/commit/7e1b14e6c7a9ab96d2db7e4a131981f162446d34 Source-Link: https://github.com/googleapis/googleapis-gen/commit/0a3c7d272d697796db75857bac73905c68e498c3 --- owl-bot-staging/v1/MANIFEST.in | 2 + owl-bot-staging/v1/README.rst | 49 + owl-bot-staging/v1/docs/conf.py | 376 + owl-bot-staging/v1/docs/index.rst | 7 + .../certificate_authority_service.rst | 10 + .../v1/docs/privateca_v1/services.rst | 6 + .../v1/docs/privateca_v1/types.rst | 7 + .../cloud/security/privateca/__init__.py | 135 + .../google/cloud/security/privateca/py.typed | 2 + .../cloud/security/privateca_v1/__init__.py | 136 + .../security/privateca_v1/gapic_metadata.json | 313 + .../cloud/security/privateca_v1/py.typed | 2 + .../privateca_v1/services/__init__.py | 15 + .../certificate_authority_service/__init__.py | 22 + .../async_client.py | 2874 ++++++ .../certificate_authority_service/client.py | 3097 ++++++ .../certificate_authority_service/pagers.py | 629 ++ .../transports/__init__.py | 33 + .../transports/base.py | 582 ++ .../transports/grpc.py | 1055 ++ .../transports/grpc_asyncio.py | 1059 ++ .../security/privateca_v1/types/__init__.py | 134 + .../security/privateca_v1/types/resources.py | 1896 ++++ .../security/privateca_v1/types/service.py | 1656 +++ owl-bot-staging/v1/mypy.ini | 3 + owl-bot-staging/v1/noxfile.py | 132 + .../v1/scripts/fixup_privateca_v1_keywords.py | 204 + owl-bot-staging/v1/setup.py | 53 + owl-bot-staging/v1/tests/__init__.py | 16 + owl-bot-staging/v1/tests/unit/__init__.py | 16 + .../v1/tests/unit/gapic/__init__.py | 16 + .../tests/unit/gapic/privateca_v1/__init__.py | 16 + .../test_certificate_authority_service.py | 8989 +++++++++++++++++ owl-bot-staging/v1beta1/MANIFEST.in | 2 + owl-bot-staging/v1beta1/README.rst | 49 + owl-bot-staging/v1beta1/docs/conf.py | 376 + owl-bot-staging/v1beta1/docs/index.rst | 7 + .../certificate_authority_service.rst | 10 + .../docs/privateca_v1beta1/services.rst | 6 + .../v1beta1/docs/privateca_v1beta1/types.rst | 7 + .../cloud/security/privateca/__init__.py | 107 + .../google/cloud/security/privateca/py.typed | 2 + .../security/privateca_v1beta1/__init__.py | 108 + .../privateca_v1beta1/gapic_metadata.json | 223 + .../cloud/security/privateca_v1beta1/py.typed | 2 + .../privateca_v1beta1/services/__init__.py | 15 + .../certificate_authority_service/__init__.py | 22 + .../async_client.py | 2001 ++++ .../certificate_authority_service/client.py | 2215 ++++ .../certificate_authority_service/pagers.py | 507 + .../transports/__init__.py | 33 + .../transports/base.py | 456 + .../transports/grpc.py | 814 ++ .../transports/grpc_asyncio.py | 818 ++ .../privateca_v1beta1/types/__init__.py | 106 + .../privateca_v1beta1/types/resources.py | 1687 ++++ .../privateca_v1beta1/types/service.py | 1121 ++ owl-bot-staging/v1beta1/mypy.ini | 3 + owl-bot-staging/v1beta1/noxfile.py | 132 + .../fixup_privateca_v1beta1_keywords.py | 195 + owl-bot-staging/v1beta1/setup.py | 53 + owl-bot-staging/v1beta1/tests/__init__.py | 16 + .../v1beta1/tests/unit/__init__.py | 16 + .../v1beta1/tests/unit/gapic/__init__.py | 16 + .../unit/gapic/privateca_v1beta1/__init__.py | 16 + .../test_certificate_authority_service.py | 6611 ++++++++++++ 66 files changed, 41294 insertions(+) create mode 100644 owl-bot-staging/v1/MANIFEST.in create mode 100644 owl-bot-staging/v1/README.rst create mode 100644 owl-bot-staging/v1/docs/conf.py create mode 100644 owl-bot-staging/v1/docs/index.rst create mode 100644 owl-bot-staging/v1/docs/privateca_v1/certificate_authority_service.rst create mode 100644 owl-bot-staging/v1/docs/privateca_v1/services.rst create mode 100644 owl-bot-staging/v1/docs/privateca_v1/types.rst create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/types/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/types/resources.py create mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/types/service.py create mode 100644 owl-bot-staging/v1/mypy.ini create mode 100644 owl-bot-staging/v1/noxfile.py create mode 100644 owl-bot-staging/v1/scripts/fixup_privateca_v1_keywords.py create mode 100644 owl-bot-staging/v1/setup.py create mode 100644 owl-bot-staging/v1/tests/__init__.py create mode 100644 owl-bot-staging/v1/tests/unit/__init__.py create mode 100644 owl-bot-staging/v1/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/v1/tests/unit/gapic/privateca_v1/__init__.py create mode 100644 owl-bot-staging/v1/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py create mode 100644 owl-bot-staging/v1beta1/MANIFEST.in create mode 100644 owl-bot-staging/v1beta1/README.rst create mode 100644 owl-bot-staging/v1beta1/docs/conf.py create mode 100644 owl-bot-staging/v1beta1/docs/index.rst create mode 100644 owl-bot-staging/v1beta1/docs/privateca_v1beta1/certificate_authority_service.rst create mode 100644 owl-bot-staging/v1beta1/docs/privateca_v1beta1/services.rst create mode 100644 owl-bot-staging/v1beta1/docs/privateca_v1beta1/types.rst create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca/__init__.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca/py.typed create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/__init__.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/py.typed create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/__init__.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/__init__.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/__init__.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/__init__.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/resources.py create mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/service.py create mode 100644 owl-bot-staging/v1beta1/mypy.ini create mode 100644 owl-bot-staging/v1beta1/noxfile.py create mode 100644 owl-bot-staging/v1beta1/scripts/fixup_privateca_v1beta1_keywords.py create mode 100644 owl-bot-staging/v1beta1/setup.py create mode 100644 owl-bot-staging/v1beta1/tests/__init__.py create mode 100644 owl-bot-staging/v1beta1/tests/unit/__init__.py create mode 100644 owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/__init__.py create mode 100644 owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py diff --git a/owl-bot-staging/v1/MANIFEST.in b/owl-bot-staging/v1/MANIFEST.in new file mode 100644 index 0000000..3b6449c --- /dev/null +++ b/owl-bot-staging/v1/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/security/privateca *.py +recursive-include google/cloud/security/privateca_v1 *.py diff --git a/owl-bot-staging/v1/README.rst b/owl-bot-staging/v1/README.rst new file mode 100644 index 0000000..d1e676b --- /dev/null +++ b/owl-bot-staging/v1/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Security Privateca 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 Security Privateca API. +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + python3 -m venv + source /bin/activate + /bin/pip install /path/to/library + + +Windows +^^^^^^^ + +.. code-block:: console + + python3 -m venv + \Scripts\activate + \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1/docs/conf.py b/owl-bot-staging/v1/docs/conf.py new file mode 100644 index 0000000..a29fc06 --- /dev/null +++ b/owl-bot-staging/v1/docs/conf.py @@ -0,0 +1,376 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# google-cloud-security-privateca documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath("..")) + +__version__ = "0.1.0" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "1.6.3" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_flags = ["members"] +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# Allow markdown includes (so releases.md can include CHANGLEOG.md) +# http://www.sphinx-doc.org/en/master/markdown.html +source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = u"google-cloud-security-privateca" +copyright = u"2020, Google, LLC" +author = u"Google APIs" # TODO: autogenerate this bit + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Security 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-security-privateca-doc" + +# -- Options for warnings ------------------------------------------------------ + + +suppress_warnings = [ + # Temporarily suppress this to avoid "more than one target found for + # cross-reference" warning, which are intractable for us to avoid while in + # a mono-repo. + # See https://github.com/sphinx-doc/sphinx/blob + # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 + "ref.python" +] + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', + # Latex figure (float) alignment + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + master_doc, + "google-cloud-security-privateca.tex", + u"google-cloud-security-privateca Documentation", + author, + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + master_doc, + "google-cloud-security-privateca", + u"Google Cloud Security Privateca Documentation", + [author], + 1, + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "google-cloud-security-privateca", + u"google-cloud-security-privateca Documentation", + author, + "google-cloud-security-privateca", + "GAPIC library for Google Cloud Security Privateca 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..eadcd6d --- /dev/null +++ b/owl-bot-staging/v1/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + privateca_v1/services + privateca_v1/types diff --git a/owl-bot-staging/v1/docs/privateca_v1/certificate_authority_service.rst b/owl-bot-staging/v1/docs/privateca_v1/certificate_authority_service.rst new file mode 100644 index 0000000..00601bc --- /dev/null +++ b/owl-bot-staging/v1/docs/privateca_v1/certificate_authority_service.rst @@ -0,0 +1,10 @@ +CertificateAuthorityService +--------------------------------------------- + +.. automodule:: google.cloud.security.privateca_v1.services.certificate_authority_service + :members: + :inherited-members: + +.. automodule:: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v1/docs/privateca_v1/services.rst b/owl-bot-staging/v1/docs/privateca_v1/services.rst new file mode 100644 index 0000000..6b8d380 --- /dev/null +++ b/owl-bot-staging/v1/docs/privateca_v1/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Security Privateca v1 API +=================================================== +.. toctree:: + :maxdepth: 2 + + certificate_authority_service diff --git a/owl-bot-staging/v1/docs/privateca_v1/types.rst b/owl-bot-staging/v1/docs/privateca_v1/types.rst new file mode 100644 index 0000000..52719f3 --- /dev/null +++ b/owl-bot-staging/v1/docs/privateca_v1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Security Privateca v1 API +================================================ + +.. automodule:: google.cloud.security.privateca_v1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1/google/cloud/security/privateca/__init__.py b/owl-bot-staging/v1/google/cloud/security/privateca/__init__.py new file mode 100644 index 0000000..6799d6e --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca/__init__.py @@ -0,0 +1,135 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.security.privateca_v1.services.certificate_authority_service.client import CertificateAuthorityServiceClient +from google.cloud.security.privateca_v1.services.certificate_authority_service.async_client import CertificateAuthorityServiceAsyncClient + +from google.cloud.security.privateca_v1.types.resources import CaPool +from google.cloud.security.privateca_v1.types.resources import Certificate +from google.cloud.security.privateca_v1.types.resources import CertificateAuthority +from google.cloud.security.privateca_v1.types.resources import CertificateConfig +from google.cloud.security.privateca_v1.types.resources import CertificateDescription +from google.cloud.security.privateca_v1.types.resources import CertificateExtensionConstraints +from google.cloud.security.privateca_v1.types.resources import CertificateIdentityConstraints +from google.cloud.security.privateca_v1.types.resources import CertificateRevocationList +from google.cloud.security.privateca_v1.types.resources import CertificateTemplate +from google.cloud.security.privateca_v1.types.resources import KeyUsage +from google.cloud.security.privateca_v1.types.resources import ObjectId +from google.cloud.security.privateca_v1.types.resources import PublicKey +from google.cloud.security.privateca_v1.types.resources import Subject +from google.cloud.security.privateca_v1.types.resources import SubjectAltNames +from google.cloud.security.privateca_v1.types.resources import SubordinateConfig +from google.cloud.security.privateca_v1.types.resources import X509Extension +from google.cloud.security.privateca_v1.types.resources import X509Parameters +from google.cloud.security.privateca_v1.types.resources import RevocationReason +from google.cloud.security.privateca_v1.types.resources import SubjectRequestMode +from google.cloud.security.privateca_v1.types.service import ActivateCertificateAuthorityRequest +from google.cloud.security.privateca_v1.types.service import CreateCaPoolRequest +from google.cloud.security.privateca_v1.types.service import CreateCertificateAuthorityRequest +from google.cloud.security.privateca_v1.types.service import CreateCertificateRequest +from google.cloud.security.privateca_v1.types.service import CreateCertificateTemplateRequest +from google.cloud.security.privateca_v1.types.service import DeleteCaPoolRequest +from google.cloud.security.privateca_v1.types.service import DeleteCertificateAuthorityRequest +from google.cloud.security.privateca_v1.types.service import DeleteCertificateTemplateRequest +from google.cloud.security.privateca_v1.types.service import DisableCertificateAuthorityRequest +from google.cloud.security.privateca_v1.types.service import EnableCertificateAuthorityRequest +from google.cloud.security.privateca_v1.types.service import FetchCaCertsRequest +from google.cloud.security.privateca_v1.types.service import FetchCaCertsResponse +from google.cloud.security.privateca_v1.types.service import FetchCertificateAuthorityCsrRequest +from google.cloud.security.privateca_v1.types.service import FetchCertificateAuthorityCsrResponse +from google.cloud.security.privateca_v1.types.service import GetCaPoolRequest +from google.cloud.security.privateca_v1.types.service import GetCertificateAuthorityRequest +from google.cloud.security.privateca_v1.types.service import GetCertificateRequest +from google.cloud.security.privateca_v1.types.service import GetCertificateRevocationListRequest +from google.cloud.security.privateca_v1.types.service import GetCertificateTemplateRequest +from google.cloud.security.privateca_v1.types.service import ListCaPoolsRequest +from google.cloud.security.privateca_v1.types.service import ListCaPoolsResponse +from google.cloud.security.privateca_v1.types.service import ListCertificateAuthoritiesRequest +from google.cloud.security.privateca_v1.types.service import ListCertificateAuthoritiesResponse +from google.cloud.security.privateca_v1.types.service import ListCertificateRevocationListsRequest +from google.cloud.security.privateca_v1.types.service import ListCertificateRevocationListsResponse +from google.cloud.security.privateca_v1.types.service import ListCertificatesRequest +from google.cloud.security.privateca_v1.types.service import ListCertificatesResponse +from google.cloud.security.privateca_v1.types.service import ListCertificateTemplatesRequest +from google.cloud.security.privateca_v1.types.service import ListCertificateTemplatesResponse +from google.cloud.security.privateca_v1.types.service import OperationMetadata +from google.cloud.security.privateca_v1.types.service import RevokeCertificateRequest +from google.cloud.security.privateca_v1.types.service import UndeleteCertificateAuthorityRequest +from google.cloud.security.privateca_v1.types.service import UpdateCaPoolRequest +from google.cloud.security.privateca_v1.types.service import UpdateCertificateAuthorityRequest +from google.cloud.security.privateca_v1.types.service import UpdateCertificateRequest +from google.cloud.security.privateca_v1.types.service import UpdateCertificateRevocationListRequest +from google.cloud.security.privateca_v1.types.service import UpdateCertificateTemplateRequest + +__all__ = ('CertificateAuthorityServiceClient', + 'CertificateAuthorityServiceAsyncClient', + 'CaPool', + 'Certificate', + 'CertificateAuthority', + 'CertificateConfig', + 'CertificateDescription', + 'CertificateExtensionConstraints', + 'CertificateIdentityConstraints', + 'CertificateRevocationList', + 'CertificateTemplate', + 'KeyUsage', + 'ObjectId', + 'PublicKey', + 'Subject', + 'SubjectAltNames', + 'SubordinateConfig', + 'X509Extension', + 'X509Parameters', + 'RevocationReason', + 'SubjectRequestMode', + 'ActivateCertificateAuthorityRequest', + 'CreateCaPoolRequest', + 'CreateCertificateAuthorityRequest', + 'CreateCertificateRequest', + 'CreateCertificateTemplateRequest', + 'DeleteCaPoolRequest', + 'DeleteCertificateAuthorityRequest', + 'DeleteCertificateTemplateRequest', + 'DisableCertificateAuthorityRequest', + 'EnableCertificateAuthorityRequest', + 'FetchCaCertsRequest', + 'FetchCaCertsResponse', + 'FetchCertificateAuthorityCsrRequest', + 'FetchCertificateAuthorityCsrResponse', + 'GetCaPoolRequest', + 'GetCertificateAuthorityRequest', + 'GetCertificateRequest', + 'GetCertificateRevocationListRequest', + 'GetCertificateTemplateRequest', + 'ListCaPoolsRequest', + 'ListCaPoolsResponse', + 'ListCertificateAuthoritiesRequest', + 'ListCertificateAuthoritiesResponse', + 'ListCertificateRevocationListsRequest', + 'ListCertificateRevocationListsResponse', + 'ListCertificatesRequest', + 'ListCertificatesResponse', + 'ListCertificateTemplatesRequest', + 'ListCertificateTemplatesResponse', + 'OperationMetadata', + 'RevokeCertificateRequest', + 'UndeleteCertificateAuthorityRequest', + 'UpdateCaPoolRequest', + 'UpdateCertificateAuthorityRequest', + 'UpdateCertificateRequest', + 'UpdateCertificateRevocationListRequest', + 'UpdateCertificateTemplateRequest', +) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca/py.typed b/owl-bot-staging/v1/google/cloud/security/privateca/py.typed new file mode 100644 index 0000000..866f40f --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-security-privateca package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/__init__.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/__init__.py new file mode 100644 index 0000000..62f3fee --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/__init__.py @@ -0,0 +1,136 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from .services.certificate_authority_service import CertificateAuthorityServiceClient +from .services.certificate_authority_service import CertificateAuthorityServiceAsyncClient + +from .types.resources import CaPool +from .types.resources import Certificate +from .types.resources import CertificateAuthority +from .types.resources import CertificateConfig +from .types.resources import CertificateDescription +from .types.resources import CertificateExtensionConstraints +from .types.resources import CertificateIdentityConstraints +from .types.resources import CertificateRevocationList +from .types.resources import CertificateTemplate +from .types.resources import KeyUsage +from .types.resources import ObjectId +from .types.resources import PublicKey +from .types.resources import Subject +from .types.resources import SubjectAltNames +from .types.resources import SubordinateConfig +from .types.resources import X509Extension +from .types.resources import X509Parameters +from .types.resources import RevocationReason +from .types.resources import SubjectRequestMode +from .types.service import ActivateCertificateAuthorityRequest +from .types.service import CreateCaPoolRequest +from .types.service import CreateCertificateAuthorityRequest +from .types.service import CreateCertificateRequest +from .types.service import CreateCertificateTemplateRequest +from .types.service import DeleteCaPoolRequest +from .types.service import DeleteCertificateAuthorityRequest +from .types.service import DeleteCertificateTemplateRequest +from .types.service import DisableCertificateAuthorityRequest +from .types.service import EnableCertificateAuthorityRequest +from .types.service import FetchCaCertsRequest +from .types.service import FetchCaCertsResponse +from .types.service import FetchCertificateAuthorityCsrRequest +from .types.service import FetchCertificateAuthorityCsrResponse +from .types.service import GetCaPoolRequest +from .types.service import GetCertificateAuthorityRequest +from .types.service import GetCertificateRequest +from .types.service import GetCertificateRevocationListRequest +from .types.service import GetCertificateTemplateRequest +from .types.service import ListCaPoolsRequest +from .types.service import ListCaPoolsResponse +from .types.service import ListCertificateAuthoritiesRequest +from .types.service import ListCertificateAuthoritiesResponse +from .types.service import ListCertificateRevocationListsRequest +from .types.service import ListCertificateRevocationListsResponse +from .types.service import ListCertificatesRequest +from .types.service import ListCertificatesResponse +from .types.service import ListCertificateTemplatesRequest +from .types.service import ListCertificateTemplatesResponse +from .types.service import OperationMetadata +from .types.service import RevokeCertificateRequest +from .types.service import UndeleteCertificateAuthorityRequest +from .types.service import UpdateCaPoolRequest +from .types.service import UpdateCertificateAuthorityRequest +from .types.service import UpdateCertificateRequest +from .types.service import UpdateCertificateRevocationListRequest +from .types.service import UpdateCertificateTemplateRequest + +__all__ = ( + 'CertificateAuthorityServiceAsyncClient', +'ActivateCertificateAuthorityRequest', +'CaPool', +'Certificate', +'CertificateAuthority', +'CertificateAuthorityServiceClient', +'CertificateConfig', +'CertificateDescription', +'CertificateExtensionConstraints', +'CertificateIdentityConstraints', +'CertificateRevocationList', +'CertificateTemplate', +'CreateCaPoolRequest', +'CreateCertificateAuthorityRequest', +'CreateCertificateRequest', +'CreateCertificateTemplateRequest', +'DeleteCaPoolRequest', +'DeleteCertificateAuthorityRequest', +'DeleteCertificateTemplateRequest', +'DisableCertificateAuthorityRequest', +'EnableCertificateAuthorityRequest', +'FetchCaCertsRequest', +'FetchCaCertsResponse', +'FetchCertificateAuthorityCsrRequest', +'FetchCertificateAuthorityCsrResponse', +'GetCaPoolRequest', +'GetCertificateAuthorityRequest', +'GetCertificateRequest', +'GetCertificateRevocationListRequest', +'GetCertificateTemplateRequest', +'KeyUsage', +'ListCaPoolsRequest', +'ListCaPoolsResponse', +'ListCertificateAuthoritiesRequest', +'ListCertificateAuthoritiesResponse', +'ListCertificateRevocationListsRequest', +'ListCertificateRevocationListsResponse', +'ListCertificateTemplatesRequest', +'ListCertificateTemplatesResponse', +'ListCertificatesRequest', +'ListCertificatesResponse', +'ObjectId', +'OperationMetadata', +'PublicKey', +'RevocationReason', +'RevokeCertificateRequest', +'Subject', +'SubjectAltNames', +'SubjectRequestMode', +'SubordinateConfig', +'UndeleteCertificateAuthorityRequest', +'UpdateCaPoolRequest', +'UpdateCertificateAuthorityRequest', +'UpdateCertificateRequest', +'UpdateCertificateRevocationListRequest', +'UpdateCertificateTemplateRequest', +'X509Extension', +'X509Parameters', +) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/gapic_metadata.json b/owl-bot-staging/v1/google/cloud/security/privateca_v1/gapic_metadata.json new file mode 100644 index 0000000..9eb6757 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/gapic_metadata.json @@ -0,0 +1,313 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.security.privateca_v1", + "protoPackage": "google.cloud.security.privateca.v1", + "schema": "1.0", + "services": { + "CertificateAuthorityService": { + "clients": { + "grpc": { + "libraryClient": "CertificateAuthorityServiceClient", + "rpcs": { + "ActivateCertificateAuthority": { + "methods": [ + "activate_certificate_authority" + ] + }, + "CreateCaPool": { + "methods": [ + "create_ca_pool" + ] + }, + "CreateCertificate": { + "methods": [ + "create_certificate" + ] + }, + "CreateCertificateAuthority": { + "methods": [ + "create_certificate_authority" + ] + }, + "CreateCertificateTemplate": { + "methods": [ + "create_certificate_template" + ] + }, + "DeleteCaPool": { + "methods": [ + "delete_ca_pool" + ] + }, + "DeleteCertificateAuthority": { + "methods": [ + "delete_certificate_authority" + ] + }, + "DeleteCertificateTemplate": { + "methods": [ + "delete_certificate_template" + ] + }, + "DisableCertificateAuthority": { + "methods": [ + "disable_certificate_authority" + ] + }, + "EnableCertificateAuthority": { + "methods": [ + "enable_certificate_authority" + ] + }, + "FetchCaCerts": { + "methods": [ + "fetch_ca_certs" + ] + }, + "FetchCertificateAuthorityCsr": { + "methods": [ + "fetch_certificate_authority_csr" + ] + }, + "GetCaPool": { + "methods": [ + "get_ca_pool" + ] + }, + "GetCertificate": { + "methods": [ + "get_certificate" + ] + }, + "GetCertificateAuthority": { + "methods": [ + "get_certificate_authority" + ] + }, + "GetCertificateRevocationList": { + "methods": [ + "get_certificate_revocation_list" + ] + }, + "GetCertificateTemplate": { + "methods": [ + "get_certificate_template" + ] + }, + "ListCaPools": { + "methods": [ + "list_ca_pools" + ] + }, + "ListCertificateAuthorities": { + "methods": [ + "list_certificate_authorities" + ] + }, + "ListCertificateRevocationLists": { + "methods": [ + "list_certificate_revocation_lists" + ] + }, + "ListCertificateTemplates": { + "methods": [ + "list_certificate_templates" + ] + }, + "ListCertificates": { + "methods": [ + "list_certificates" + ] + }, + "RevokeCertificate": { + "methods": [ + "revoke_certificate" + ] + }, + "UndeleteCertificateAuthority": { + "methods": [ + "undelete_certificate_authority" + ] + }, + "UpdateCaPool": { + "methods": [ + "update_ca_pool" + ] + }, + "UpdateCertificate": { + "methods": [ + "update_certificate" + ] + }, + "UpdateCertificateAuthority": { + "methods": [ + "update_certificate_authority" + ] + }, + "UpdateCertificateRevocationList": { + "methods": [ + "update_certificate_revocation_list" + ] + }, + "UpdateCertificateTemplate": { + "methods": [ + "update_certificate_template" + ] + } + } + }, + "grpc-async": { + "libraryClient": "CertificateAuthorityServiceAsyncClient", + "rpcs": { + "ActivateCertificateAuthority": { + "methods": [ + "activate_certificate_authority" + ] + }, + "CreateCaPool": { + "methods": [ + "create_ca_pool" + ] + }, + "CreateCertificate": { + "methods": [ + "create_certificate" + ] + }, + "CreateCertificateAuthority": { + "methods": [ + "create_certificate_authority" + ] + }, + "CreateCertificateTemplate": { + "methods": [ + "create_certificate_template" + ] + }, + "DeleteCaPool": { + "methods": [ + "delete_ca_pool" + ] + }, + "DeleteCertificateAuthority": { + "methods": [ + "delete_certificate_authority" + ] + }, + "DeleteCertificateTemplate": { + "methods": [ + "delete_certificate_template" + ] + }, + "DisableCertificateAuthority": { + "methods": [ + "disable_certificate_authority" + ] + }, + "EnableCertificateAuthority": { + "methods": [ + "enable_certificate_authority" + ] + }, + "FetchCaCerts": { + "methods": [ + "fetch_ca_certs" + ] + }, + "FetchCertificateAuthorityCsr": { + "methods": [ + "fetch_certificate_authority_csr" + ] + }, + "GetCaPool": { + "methods": [ + "get_ca_pool" + ] + }, + "GetCertificate": { + "methods": [ + "get_certificate" + ] + }, + "GetCertificateAuthority": { + "methods": [ + "get_certificate_authority" + ] + }, + "GetCertificateRevocationList": { + "methods": [ + "get_certificate_revocation_list" + ] + }, + "GetCertificateTemplate": { + "methods": [ + "get_certificate_template" + ] + }, + "ListCaPools": { + "methods": [ + "list_ca_pools" + ] + }, + "ListCertificateAuthorities": { + "methods": [ + "list_certificate_authorities" + ] + }, + "ListCertificateRevocationLists": { + "methods": [ + "list_certificate_revocation_lists" + ] + }, + "ListCertificateTemplates": { + "methods": [ + "list_certificate_templates" + ] + }, + "ListCertificates": { + "methods": [ + "list_certificates" + ] + }, + "RevokeCertificate": { + "methods": [ + "revoke_certificate" + ] + }, + "UndeleteCertificateAuthority": { + "methods": [ + "undelete_certificate_authority" + ] + }, + "UpdateCaPool": { + "methods": [ + "update_ca_pool" + ] + }, + "UpdateCertificate": { + "methods": [ + "update_certificate" + ] + }, + "UpdateCertificateAuthority": { + "methods": [ + "update_certificate_authority" + ] + }, + "UpdateCertificateRevocationList": { + "methods": [ + "update_certificate_revocation_list" + ] + }, + "UpdateCertificateTemplate": { + "methods": [ + "update_certificate_template" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/py.typed b/owl-bot-staging/v1/google/cloud/security/privateca_v1/py.typed new file mode 100644 index 0000000..866f40f --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-security-privateca package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/__init__.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/__init__.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/__init__.py new file mode 100644 index 0000000..33b4459 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from .client import CertificateAuthorityServiceClient +from .async_client import CertificateAuthorityServiceAsyncClient + +__all__ = ( + 'CertificateAuthorityServiceClient', + 'CertificateAuthorityServiceAsyncClient', +) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py new file mode 100644 index 0000000..4221a97 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py @@ -0,0 +1,2874 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +import functools +import re +from typing import Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.security.privateca_v1.services.certificate_authority_service import pagers +from google.cloud.security.privateca_v1.types import resources +from google.cloud.security.privateca_v1.types import service +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 CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport +from .client import CertificateAuthorityServiceClient + + +class CertificateAuthorityServiceAsyncClient: + """[Certificate Authority + Service][google.cloud.security.privateca.v1.CertificateAuthorityService] + manages private certificate authorities and issued certificates. + """ + + _client: CertificateAuthorityServiceClient + + DEFAULT_ENDPOINT = CertificateAuthorityServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = CertificateAuthorityServiceClient.DEFAULT_MTLS_ENDPOINT + + ca_pool_path = staticmethod(CertificateAuthorityServiceClient.ca_pool_path) + parse_ca_pool_path = staticmethod(CertificateAuthorityServiceClient.parse_ca_pool_path) + certificate_path = staticmethod(CertificateAuthorityServiceClient.certificate_path) + parse_certificate_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_path) + certificate_authority_path = staticmethod(CertificateAuthorityServiceClient.certificate_authority_path) + parse_certificate_authority_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_authority_path) + certificate_revocation_list_path = staticmethod(CertificateAuthorityServiceClient.certificate_revocation_list_path) + parse_certificate_revocation_list_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_revocation_list_path) + certificate_template_path = staticmethod(CertificateAuthorityServiceClient.certificate_template_path) + parse_certificate_template_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_template_path) + common_billing_account_path = staticmethod(CertificateAuthorityServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(CertificateAuthorityServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(CertificateAuthorityServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(CertificateAuthorityServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(CertificateAuthorityServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(CertificateAuthorityServiceClient.parse_common_organization_path) + common_project_path = staticmethod(CertificateAuthorityServiceClient.common_project_path) + parse_common_project_path = staticmethod(CertificateAuthorityServiceClient.parse_common_project_path) + common_location_path = staticmethod(CertificateAuthorityServiceClient.common_location_path) + parse_common_location_path = staticmethod(CertificateAuthorityServiceClient.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: + CertificateAuthorityServiceAsyncClient: The constructed client. + """ + return CertificateAuthorityServiceClient.from_service_account_info.__func__(CertificateAuthorityServiceAsyncClient, 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: + CertificateAuthorityServiceAsyncClient: The constructed client. + """ + return CertificateAuthorityServiceClient.from_service_account_file.__func__(CertificateAuthorityServiceAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> CertificateAuthorityServiceTransport: + """Returns the transport used by the client instance. + + Returns: + CertificateAuthorityServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(CertificateAuthorityServiceClient).get_transport_class, type(CertificateAuthorityServiceClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, CertificateAuthorityServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the certificate authority service client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.CertificateAuthorityServiceTransport]): 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 = CertificateAuthorityServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def create_certificate(self, + request: service.CreateCertificateRequest = None, + *, + parent: str = None, + certificate: resources.Certificate = None, + certificate_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Create a new + [Certificate][google.cloud.security.privateca.v1.Certificate] in + a given Project, Location from a particular + [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.CreateCertificateRequest`): + The request object. Request message for + [CertificateAuthorityService.CreateCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificate]. + parent (:class:`str`): + Required. The resource name of the + [CaPool][google.cloud.security.privateca.v1.CaPool] + associated with the + [Certificate][google.cloud.security.privateca.v1.Certificate], + in the format ``projects/*/locations/*/caPools/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate (:class:`google.cloud.security.privateca_v1.types.Certificate`): + Required. A + [Certificate][google.cloud.security.privateca.v1.Certificate] + with initial field values. + + This corresponds to the ``certificate`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_id (:class:`str`): + Optional. It must be unique within a location and match + the regular expression ``[a-zA-Z0-9_-]{1,63}``. This + field is required when using a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the Enterprise [CertificateAuthority.Tier][], but is + optional and its value is ignored otherwise. + + 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.cloud.security.privateca_v1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, 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 = service.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_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_certificate(self, + request: service.GetCertificateRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Returns a + [Certificate][google.cloud.security.privateca.v1.Certificate]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.GetCertificateRequest`): + The request object. Request message for + [CertificateAuthorityService.GetCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificate]. + name (:class:`str`): + Required. The + [name][google.cloud.security.privateca.v1.Certificate.name] + of the + [Certificate][google.cloud.security.privateca.v1.Certificate] + to get. + + 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.security.privateca_v1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.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_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_certificates(self, + request: service.ListCertificatesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificatesAsyncPager: + r"""Lists + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.ListCertificatesRequest`): + The request object. Request message for + [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificates]. + parent (:class:`str`): + Required. The resource name of the location associated + with the + [Certificates][google.cloud.security.privateca.v1.Certificate], + in the format ``projects/*/locations/*/caPools/*``. + + 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificatesAsyncPager: + Response message for + [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificates]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.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_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCertificatesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def revoke_certificate(self, + request: service.RevokeCertificateRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Revoke a + [Certificate][google.cloud.security.privateca.v1.Certificate]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.RevokeCertificateRequest`): + The request object. Request message for + [CertificateAuthorityService.RevokeCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.RevokeCertificate]. + name (:class:`str`): + Required. The resource name for this + [Certificate][google.cloud.security.privateca.v1.Certificate] + in the format + ``projects/*/locations/*/caPools/*/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.security.privateca_v1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.RevokeCertificateRequest(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.revoke_certificate, + 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 update_certificate(self, + request: service.UpdateCertificateRequest = None, + *, + certificate: resources.Certificate = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Update a + [Certificate][google.cloud.security.privateca.v1.Certificate]. + Currently, the only field you can update is the + [labels][google.cloud.security.privateca.v1.Certificate.labels] + field. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.UpdateCertificateRequest`): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificate]. + certificate (:class:`google.cloud.security.privateca_v1.types.Certificate`): + Required. + [Certificate][google.cloud.security.privateca.v1.Certificate] + with updated values. + + 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. A list of fields to be + updated in this request. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.security.privateca_v1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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 = service.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_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(( + ("certificate.name", request.certificate.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def activate_certificate_authority(self, + request: service.ActivateCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Activate a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that is in state + [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. + After the parent Certificate Authority signs a certificate + signing request from + [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr], + this method can complete the activation process. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.ActivateCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. + name (:class:`str`): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.ActivateCertificateAuthorityRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.activate_certificate_authority, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_certificate_authority(self, + request: service.CreateCertificateAuthorityRequest = None, + *, + parent: str = None, + certificate_authority: resources.CertificateAuthority = None, + certificate_authority_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Create a new + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in a given Project and Location. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.CreateCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.CreateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificateAuthority]. + parent (:class:`str`): + Required. The resource name of the + [CaPool][google.cloud.security.privateca.v1.CaPool] + associated with the + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority], + in the format ``projects/*/locations/*/caPools/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_authority (:class:`google.cloud.security.privateca_v1.types.CertificateAuthority`): + Required. A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + with initial field values. + + This corresponds to the ``certificate_authority`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_authority_id (:class:`str`): + Required. It must be unique within a location and match + the regular expression ``[a-zA-Z0-9_-]{1,63}`` + + This corresponds to the ``certificate_authority_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.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate_authority, certificate_authority_id]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.CreateCertificateAuthorityRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate_authority is not None: + request.certificate_authority = certificate_authority + if certificate_authority_id is not None: + request.certificate_authority_id = certificate_authority_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_authority, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def disable_certificate_authority(self, + request: service.DisableCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Disable a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.DisableCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.DisableCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.DisableCertificateAuthority]. + name (:class:`str`): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.DisableCertificateAuthorityRequest(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.disable_certificate_authority, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def enable_certificate_authority(self, + request: service.EnableCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Enable a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.EnableCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.EnableCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.EnableCertificateAuthority]. + name (:class:`str`): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.EnableCertificateAuthorityRequest(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.enable_certificate_authority, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def fetch_certificate_authority_csr(self, + request: service.FetchCertificateAuthorityCsrRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.FetchCertificateAuthorityCsrResponse: + r"""Fetch a certificate signing request (CSR) from a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that is in state + [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. + The CSR must then be signed by the desired parent Certificate + Authority, which could be another + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resource, or could be an on-prem certificate authority. See also + [ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.FetchCertificateAuthorityCsrRequest`): + The request object. Request message for + [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. + name (:class:`str`): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + 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.security.privateca_v1.types.FetchCertificateAuthorityCsrResponse: + Response message for + [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.FetchCertificateAuthorityCsrRequest(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.fetch_certificate_authority_csr, + 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_certificate_authority(self, + request: service.GetCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CertificateAuthority: + r"""Returns a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.GetCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.GetCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateAuthority]. + name (:class:`str`): + Required. The + [name][google.cloud.security.privateca.v1.CertificateAuthority.name] + of the + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + to get. + + 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.security.privateca_v1.types.CertificateAuthority: + A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.GetCertificateAuthorityRequest(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_authority, + 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_certificate_authorities(self, + request: service.ListCertificateAuthoritiesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateAuthoritiesAsyncPager: + r"""Lists + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesRequest`): + The request object. Request message for + [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateAuthorities]. + parent (:class:`str`): + Required. The resource name of the + [CaPool][google.cloud.security.privateca.v1.CaPool] + associated with the + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority], + in the format ``projects/*/locations/*/caPools/*``. + + 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesAsyncPager: + Response message for + [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateAuthorities]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.ListCertificateAuthoritiesRequest(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_authorities, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCertificateAuthoritiesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def undelete_certificate_authority(self, + request: service.UndeleteCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Undelete a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that has been deleted. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.UndeleteCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.UndeleteCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.UndeleteCertificateAuthority]. + name (:class:`str`): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.UndeleteCertificateAuthorityRequest(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.undelete_certificate_authority, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_certificate_authority(self, + request: service.DeleteCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Delete a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.DeleteCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.DeleteCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCertificateAuthority]. + name (:class:`str`): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.DeleteCertificateAuthorityRequest(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_authority, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_certificate_authority(self, + request: service.UpdateCertificateAuthorityRequest = None, + *, + certificate_authority: resources.CertificateAuthority = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Update a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.UpdateCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateAuthority]. + certificate_authority (:class:`google.cloud.security.privateca_v1.types.CertificateAuthority`): + Required. + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + with updated values. + + This corresponds to the ``certificate_authority`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. A list of fields to be + updated in this request. + + 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.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_authority, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.UpdateCertificateAuthorityRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_authority is not None: + request.certificate_authority = certificate_authority + 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_authority, + 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(( + ("certificate_authority.name", request.certificate_authority.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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_ca_pool(self, + request: service.CreateCaPoolRequest = None, + *, + parent: str = None, + ca_pool: resources.CaPool = None, + ca_pool_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.CreateCaPoolRequest`): + The request object. Request message for + [CertificateAuthorityService.CreateCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCaPool]. + parent (:class:`str`): + Required. The resource name of the location associated + with the + [CaPool][google.cloud.security.privateca.v1.CaPool], in + the format ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + ca_pool (:class:`google.cloud.security.privateca_v1.types.CaPool`): + Required. A + [CaPool][google.cloud.security.privateca.v1.CaPool] with + initial field values. + + This corresponds to the ``ca_pool`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + ca_pool_id (:class:`str`): + Required. It must be unique within a location and match + the regular expression ``[a-zA-Z0-9_-]{1,63}`` + + This corresponds to the ``ca_pool_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.security.privateca_v1.types.CaPool` A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] + that form a trust anchor. A + [CaPool][google.cloud.security.privateca.v1.CaPool] + can be used to manage issuance policies for one or + more + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources and to rotate CA certificates in and out of + the trust anchor. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, ca_pool, ca_pool_id]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.CreateCaPoolRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if ca_pool is not None: + request.ca_pool = ca_pool + if ca_pool_id is not None: + request.ca_pool_id = ca_pool_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_ca_pool, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CaPool, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_ca_pool(self, + request: service.UpdateCaPoolRequest = None, + *, + ca_pool: resources.CaPool = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.UpdateCaPoolRequest`): + The request object. Request message for + [CertificateAuthorityService.UpdateCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCaPool]. + ca_pool (:class:`google.cloud.security.privateca_v1.types.CaPool`): + Required. + [CaPool][google.cloud.security.privateca.v1.CaPool] with + updated values. + + This corresponds to the ``ca_pool`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. A list of fields to be + updated in this request. + + 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.security.privateca_v1.types.CaPool` A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] + that form a trust anchor. A + [CaPool][google.cloud.security.privateca.v1.CaPool] + can be used to manage issuance policies for one or + more + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources and to rotate CA certificates in and out of + the trust anchor. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([ca_pool, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.UpdateCaPoolRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if ca_pool is not None: + request.ca_pool = ca_pool + 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_ca_pool, + 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(( + ("ca_pool.name", request.ca_pool.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, + resources.CaPool, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_ca_pool(self, + request: service.GetCaPoolRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CaPool: + r"""Returns a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.GetCaPoolRequest`): + The request object. Request message for + [CertificateAuthorityService.GetCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCaPool]. + name (:class:`str`): + Required. The + [name][google.cloud.security.privateca.v1.CaPool.name] + of the + [CaPool][google.cloud.security.privateca.v1.CaPool] to + get. + + 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.security.privateca_v1.types.CaPool: + A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] + that form a trust anchor. A + [CaPool][google.cloud.security.privateca.v1.CaPool] + can be used to manage issuance policies for one or + more + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources and to rotate CA certificates in and out of + the trust anchor. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.GetCaPoolRequest(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_ca_pool, + 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_ca_pools(self, + request: service.ListCaPoolsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCaPoolsAsyncPager: + r"""Lists [CaPools][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.ListCaPoolsRequest`): + The request object. Request message for + [CertificateAuthorityService.ListCaPools][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCaPools]. + parent (:class:`str`): + Required. The resource name of the location associated + with the + [CaPools][google.cloud.security.privateca.v1.CaPool], 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCaPoolsAsyncPager: + Response message for + [CertificateAuthorityService.ListCaPools][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCaPools]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.ListCaPoolsRequest(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_ca_pools, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCaPoolsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_ca_pool(self, + request: service.DeleteCaPoolRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.DeleteCaPoolRequest`): + The request object. Request message for + [CertificateAuthorityService.DeleteCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCaPool]. + name (:class:`str`): + Required. The resource name for this + [CaPool][google.cloud.security.privateca.v1.CaPool] in + the format ``projects/*/locations/*/caPools/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CaPool` A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] + that form a trust anchor. A + [CaPool][google.cloud.security.privateca.v1.CaPool] + can be used to manage issuance policies for one or + more + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources and to rotate CA certificates in and out of + the trust anchor. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.DeleteCaPoolRequest(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_ca_pool, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CaPool, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def fetch_ca_certs(self, + request: service.FetchCaCertsRequest = None, + *, + ca_pool: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.FetchCaCertsResponse: + r"""FetchCaCerts returns the current trust anchor for the + [CaPool][google.cloud.security.privateca.v1.CaPool]. This will + include CA certificate chains for all ACTIVE + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources in the + [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.FetchCaCertsRequest`): + The request object. Request message for + [CertificateAuthorityService.FetchCaCerts][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCaCerts]. + ca_pool (:class:`str`): + Required. The resource name for the + [CaPool][google.cloud.security.privateca.v1.CaPool] in + the format ``projects/*/locations/*/caPools/*``. + + This corresponds to the ``ca_pool`` 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.security.privateca_v1.types.FetchCaCertsResponse: + Response message for + [CertificateAuthorityService.FetchCaCerts][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCaCerts]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([ca_pool]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.FetchCaCertsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if ca_pool is not None: + request.ca_pool = ca_pool + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.fetch_ca_certs, + 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(( + ("ca_pool", request.ca_pool), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_certificate_revocation_list(self, + request: service.GetCertificateRevocationListRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CertificateRevocationList: + r"""Returns a + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.GetCertificateRevocationListRequest`): + The request object. Request message for + [CertificateAuthorityService.GetCertificateRevocationList][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateRevocationList]. + name (:class:`str`): + Required. The + [name][google.cloud.security.privateca.v1.CertificateRevocationList.name] + of the + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] + to get. + + 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.security.privateca_v1.types.CertificateRevocationList: + A [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] corresponds to a signed X.509 certificate + Revocation List (CRL). A CRL contains the serial + numbers of certificates that should no longer be + trusted. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.GetCertificateRevocationListRequest(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_revocation_list, + 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_certificate_revocation_lists(self, + request: service.ListCertificateRevocationListsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateRevocationListsAsyncPager: + r"""Lists + [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.ListCertificateRevocationListsRequest`): + The request object. Request message for + [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateRevocationLists]. + parent (:class:`str`): + Required. The resource name of the location associated + with the + [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList], + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateRevocationListsAsyncPager: + Response message for + [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateRevocationLists]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.ListCertificateRevocationListsRequest(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_revocation_lists, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCertificateRevocationListsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_certificate_revocation_list(self, + request: service.UpdateCertificateRevocationListRequest = None, + *, + certificate_revocation_list: resources.CertificateRevocationList = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Update a + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.UpdateCertificateRevocationListRequest`): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificateRevocationList][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateRevocationList]. + certificate_revocation_list (:class:`google.cloud.security.privateca_v1.types.CertificateRevocationList`): + Required. + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] + with updated values. + + This corresponds to the ``certificate_revocation_list`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. A list of fields to be + updated in this request. + + 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.security.privateca_v1.types.CertificateRevocationList` A [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] corresponds to a signed X.509 certificate + Revocation List (CRL). A CRL contains the serial + numbers of certificates that should no longer be + trusted. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_revocation_list, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.UpdateCertificateRevocationListRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_revocation_list is not None: + request.certificate_revocation_list = certificate_revocation_list + 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_revocation_list, + 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(( + ("certificate_revocation_list.name", request.certificate_revocation_list.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, + resources.CertificateRevocationList, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_certificate_template(self, + request: service.CreateCertificateTemplateRequest = None, + *, + parent: str = None, + certificate_template: resources.CertificateTemplate = None, + certificate_template_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Create a new + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + in a given Project and Location. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.CreateCertificateTemplateRequest`): + The request object. Request message for + [CertificateAuthorityService.CreateCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificateTemplate]. + parent (:class:`str`): + Required. The resource name of the location associated + with the + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate], + 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_template (:class:`google.cloud.security.privateca_v1.types.CertificateTemplate`): + Required. A + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + with initial field values. + + This corresponds to the ``certificate_template`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_template_id (:class:`str`): + Required. It must be unique within a location and match + the regular expression ``[a-zA-Z0-9_-]{1,63}`` + + This corresponds to the ``certificate_template_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.security.privateca_v1.types.CertificateTemplate` A [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] refers to a managed template for certificate + issuance. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate_template, certificate_template_id]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.CreateCertificateTemplateRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate_template is not None: + request.certificate_template = certificate_template + if certificate_template_id is not None: + request.certificate_template_id = certificate_template_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_template, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateTemplate, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_certificate_template(self, + request: service.DeleteCertificateTemplateRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""DeleteCertificateTemplate deletes a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.DeleteCertificateTemplateRequest`): + The request object. Request message for + [CertificateAuthorityService.DeleteCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCertificateTemplate]. + name (:class:`str`): + Required. The resource name for this + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + in the format + ``projects/*/locations/*/certificateTemplates/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.DeleteCertificateTemplateRequest(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_template, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_certificate_template(self, + request: service.GetCertificateTemplateRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CertificateTemplate: + r"""Returns a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.GetCertificateTemplateRequest`): + The request object. Request message for + [CertificateAuthorityService.GetCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateTemplate]. + name (:class:`str`): + Required. The + [name][google.cloud.security.privateca.v1.CertificateTemplate.name] + of the + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + to get. + + 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.security.privateca_v1.types.CertificateTemplate: + A [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] refers to a managed template for certificate + issuance. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.GetCertificateTemplateRequest(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_template, + 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_certificate_templates(self, + request: service.ListCertificateTemplatesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateTemplatesAsyncPager: + r"""Lists + [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.ListCertificateTemplatesRequest`): + The request object. Request message for + [CertificateAuthorityService.ListCertificateTemplates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateTemplates]. + parent (:class:`str`): + Required. The resource name of the location associated + with the + [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate], + 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateTemplatesAsyncPager: + Response message for + [CertificateAuthorityService.ListCertificateTemplates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateTemplates]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.ListCertificateTemplatesRequest(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_templates, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCertificateTemplatesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_certificate_template(self, + request: service.UpdateCertificateTemplateRequest = None, + *, + certificate_template: resources.CertificateTemplate = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Update a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + + Args: + request (:class:`google.cloud.security.privateca_v1.types.UpdateCertificateTemplateRequest`): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateTemplate]. + certificate_template (:class:`google.cloud.security.privateca_v1.types.CertificateTemplate`): + Required. + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + with updated values. + + This corresponds to the ``certificate_template`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. A list of fields to be + updated in this request. + + 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.security.privateca_v1.types.CertificateTemplate` A [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] refers to a managed template for certificate + issuance. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_template, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.UpdateCertificateTemplateRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_template is not None: + request.certificate_template = certificate_template + 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_template, + 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(( + ("certificate_template.name", request.certificate_template.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, + resources.CertificateTemplate, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-security-privateca", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "CertificateAuthorityServiceAsyncClient", +) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py new file mode 100644 index 0000000..74c7bae --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py @@ -0,0 +1,3097 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +from distutils import util +import os +import re +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +import pkg_resources + +from google.api_core import client_options as client_options_lib # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.security.privateca_v1.services.certificate_authority_service import pagers +from google.cloud.security.privateca_v1.types import resources +from google.cloud.security.privateca_v1.types import service +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 CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import CertificateAuthorityServiceGrpcTransport +from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport + + +class CertificateAuthorityServiceClientMeta(type): + """Metaclass for the CertificateAuthorityService 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[CertificateAuthorityServiceTransport]] + _transport_registry["grpc"] = CertificateAuthorityServiceGrpcTransport + _transport_registry["grpc_asyncio"] = CertificateAuthorityServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[CertificateAuthorityServiceTransport]: + """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 CertificateAuthorityServiceClient(metaclass=CertificateAuthorityServiceClientMeta): + """[Certificate Authority + Service][google.cloud.security.privateca.v1.CertificateAuthorityService] + manages private certificate authorities and issued certificates. + """ + + @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 = "privateca.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: + CertificateAuthorityServiceClient: 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: + CertificateAuthorityServiceClient: 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) -> CertificateAuthorityServiceTransport: + """Returns the transport used by the client instance. + + Returns: + CertificateAuthorityServiceTransport: 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,ca_pool: str,certificate: str,) -> str: + """Returns a fully-qualified certificate string.""" + return "projects/{project}/locations/{location}/caPools/{ca_pool}/certificates/{certificate}".format(project=project, location=location, ca_pool=ca_pool, 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.+?)/caPools/(?P.+?)/certificates/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def certificate_authority_path(project: str,location: str,ca_pool: str,certificate_authority: str,) -> str: + """Returns a fully-qualified certificate_authority string.""" + return "projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}".format(project=project, location=location, ca_pool=ca_pool, certificate_authority=certificate_authority, ) + + @staticmethod + def parse_certificate_authority_path(path: str) -> Dict[str,str]: + """Parses a certificate_authority path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/caPools/(?P.+?)/certificateAuthorities/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def certificate_revocation_list_path(project: str,location: str,ca_pool: str,certificate_authority: str,certificate_revocation_list: str,) -> str: + """Returns a fully-qualified certificate_revocation_list string.""" + return "projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list}".format(project=project, location=location, ca_pool=ca_pool, certificate_authority=certificate_authority, certificate_revocation_list=certificate_revocation_list, ) + + @staticmethod + def parse_certificate_revocation_list_path(path: str) -> Dict[str,str]: + """Parses a certificate_revocation_list path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/caPools/(?P.+?)/certificateAuthorities/(?P.+?)/certificateRevocationLists/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def certificate_template_path(project: str,location: str,certificate_template: str,) -> str: + """Returns a fully-qualified certificate_template string.""" + return "projects/{project}/locations/{location}/certificateTemplates/{certificate_template}".format(project=project, location=location, certificate_template=certificate_template, ) + + @staticmethod + def parse_certificate_template_path(path: str) -> Dict[str,str]: + """Parses a certificate_template path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificateTemplates/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_billing_account_path(billing_account: str, ) -> str: + """Returns a fully-qualified billing_account string.""" + return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str,str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str, ) -> str: + """Returns a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder, ) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str,str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str, ) -> str: + """Returns a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization, ) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str,str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str, ) -> str: + """Returns a fully-qualified project string.""" + return "projects/{project}".format(project=project, ) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str,str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_location_path(project: str, location: str, ) -> str: + """Returns a fully-qualified location string.""" + return "projects/{project}/locations/{location}".format(project=project, location=location, ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str,str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, CertificateAuthorityServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the certificate authority service client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, CertificateAuthorityServiceTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = client_options_lib.from_dict(client_options) + if client_options is None: + client_options = client_options_lib.ClientOptions() + + # Create SSL credentials for mutual TLS if needed. + use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) + + client_cert_source_func = None + is_mtls = False + if use_client_cert: + if client_options.client_cert_source: + is_mtls = True + client_cert_source_func = client_options.client_cert_source + else: + is_mtls = mtls.has_default_client_cert_source() + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + else: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_mtls_env == "never": + api_endpoint = self.DEFAULT_ENDPOINT + elif use_mtls_env == "always": + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + elif use_mtls_env == "auto": + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT + else: + raise MutualTLSChannelError( + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, CertificateAuthorityServiceTransport): + # transport is a CertificateAuthorityServiceTransport instance. + if credentials or client_options.credentials_file: + raise ValueError("When providing a transport instance, " + "provide its credentials directly.") + if client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = transport + else: + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=api_endpoint, + scopes=client_options.scopes, + client_cert_source_for_mtls=client_cert_source_func, + quota_project_id=client_options.quota_project_id, + client_info=client_info, + ) + + def create_certificate(self, + request: service.CreateCertificateRequest = None, + *, + parent: str = None, + certificate: resources.Certificate = None, + certificate_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Create a new + [Certificate][google.cloud.security.privateca.v1.Certificate] in + a given Project, Location from a particular + [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (google.cloud.security.privateca_v1.types.CreateCertificateRequest): + The request object. Request message for + [CertificateAuthorityService.CreateCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificate]. + parent (str): + Required. The resource name of the + [CaPool][google.cloud.security.privateca.v1.CaPool] + associated with the + [Certificate][google.cloud.security.privateca.v1.Certificate], + in the format ``projects/*/locations/*/caPools/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate (google.cloud.security.privateca_v1.types.Certificate): + Required. A + [Certificate][google.cloud.security.privateca.v1.Certificate] + with initial field values. + + This corresponds to the ``certificate`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_id (str): + Optional. It must be unique within a location and match + the regular expression ``[a-zA-Z0-9_-]{1,63}``. This + field is required when using a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the Enterprise [CertificateAuthority.Tier][], but is + optional and its value is ignored otherwise. + + 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.cloud.security.privateca_v1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, 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 service.CreateCertificateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateCertificateRequest): + request = service.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, + ) + + # Done; return the response. + return response + + def get_certificate(self, + request: service.GetCertificateRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Returns a + [Certificate][google.cloud.security.privateca.v1.Certificate]. + + Args: + request (google.cloud.security.privateca_v1.types.GetCertificateRequest): + The request object. Request message for + [CertificateAuthorityService.GetCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificate]. + name (str): + Required. The + [name][google.cloud.security.privateca.v1.Certificate.name] + of the + [Certificate][google.cloud.security.privateca.v1.Certificate] + to get. + + 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.security.privateca_v1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetCertificateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetCertificateRequest): + request = service.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 list_certificates(self, + request: service.ListCertificatesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificatesPager: + r"""Lists + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + Args: + request (google.cloud.security.privateca_v1.types.ListCertificatesRequest): + The request object. Request message for + [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificates]. + parent (str): + Required. The resource name of the location associated + with the + [Certificates][google.cloud.security.privateca.v1.Certificate], + in the format ``projects/*/locations/*/caPools/*``. + + 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificatesPager: + Response message for + [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificates]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.ListCertificatesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListCertificatesRequest): + request = service.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 revoke_certificate(self, + request: service.RevokeCertificateRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Revoke a + [Certificate][google.cloud.security.privateca.v1.Certificate]. + + Args: + request (google.cloud.security.privateca_v1.types.RevokeCertificateRequest): + The request object. Request message for + [CertificateAuthorityService.RevokeCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.RevokeCertificate]. + name (str): + Required. The resource name for this + [Certificate][google.cloud.security.privateca.v1.Certificate] + in the format + ``projects/*/locations/*/caPools/*/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.security.privateca_v1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.RevokeCertificateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.RevokeCertificateRequest): + request = service.RevokeCertificateRequest(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.revoke_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 update_certificate(self, + request: service.UpdateCertificateRequest = None, + *, + certificate: resources.Certificate = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Update a + [Certificate][google.cloud.security.privateca.v1.Certificate]. + Currently, the only field you can update is the + [labels][google.cloud.security.privateca.v1.Certificate.labels] + field. + + Args: + request (google.cloud.security.privateca_v1.types.UpdateCertificateRequest): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificate]. + certificate (google.cloud.security.privateca_v1.types.Certificate): + Required. + [Certificate][google.cloud.security.privateca.v1.Certificate] + with updated values. + + 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. A list of fields to be + updated in this request. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.security.privateca_v1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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 service.UpdateCertificateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateCertificateRequest): + request = service.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, + ) + + # Done; return the response. + return response + + def activate_certificate_authority(self, + request: service.ActivateCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Activate a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that is in state + [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. + After the parent Certificate Authority signs a certificate + signing request from + [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr], + this method can complete the activation process. + + Args: + request (google.cloud.security.privateca_v1.types.ActivateCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.ActivateCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ActivateCertificateAuthorityRequest): + request = service.ActivateCertificateAuthorityRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.activate_certificate_authority] + + # 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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_certificate_authority(self, + request: service.CreateCertificateAuthorityRequest = None, + *, + parent: str = None, + certificate_authority: resources.CertificateAuthority = None, + certificate_authority_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Create a new + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in a given Project and Location. + + Args: + request (google.cloud.security.privateca_v1.types.CreateCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.CreateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificateAuthority]. + parent (str): + Required. The resource name of the + [CaPool][google.cloud.security.privateca.v1.CaPool] + associated with the + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority], + in the format ``projects/*/locations/*/caPools/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_authority (google.cloud.security.privateca_v1.types.CertificateAuthority): + Required. A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + with initial field values. + + This corresponds to the ``certificate_authority`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_authority_id (str): + Required. It must be unique within a location and match + the regular expression ``[a-zA-Z0-9_-]{1,63}`` + + This corresponds to the ``certificate_authority_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.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate_authority, certificate_authority_id]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.CreateCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateCertificateAuthorityRequest): + request = service.CreateCertificateAuthorityRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate_authority is not None: + request.certificate_authority = certificate_authority + if certificate_authority_id is not None: + request.certificate_authority_id = certificate_authority_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_certificate_authority] + + # 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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def disable_certificate_authority(self, + request: service.DisableCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Disable a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1.types.DisableCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.DisableCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.DisableCertificateAuthority]. + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.DisableCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.DisableCertificateAuthorityRequest): + request = service.DisableCertificateAuthorityRequest(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.disable_certificate_authority] + + # 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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def enable_certificate_authority(self, + request: service.EnableCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Enable a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1.types.EnableCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.EnableCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.EnableCertificateAuthority]. + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.EnableCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.EnableCertificateAuthorityRequest): + request = service.EnableCertificateAuthorityRequest(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.enable_certificate_authority] + + # 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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def fetch_certificate_authority_csr(self, + request: service.FetchCertificateAuthorityCsrRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.FetchCertificateAuthorityCsrResponse: + r"""Fetch a certificate signing request (CSR) from a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that is in state + [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. + The CSR must then be signed by the desired parent Certificate + Authority, which could be another + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resource, or could be an on-prem certificate authority. See also + [ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1.types.FetchCertificateAuthorityCsrRequest): + The request object. Request message for + [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + 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.security.privateca_v1.types.FetchCertificateAuthorityCsrResponse: + Response message for + [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.FetchCertificateAuthorityCsrRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.FetchCertificateAuthorityCsrRequest): + request = service.FetchCertificateAuthorityCsrRequest(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.fetch_certificate_authority_csr] + + # 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_certificate_authority(self, + request: service.GetCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CertificateAuthority: + r"""Returns a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1.types.GetCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.GetCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateAuthority]. + name (str): + Required. The + [name][google.cloud.security.privateca.v1.CertificateAuthority.name] + of the + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + to get. + + 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.security.privateca_v1.types.CertificateAuthority: + A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetCertificateAuthorityRequest): + request = service.GetCertificateAuthorityRequest(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_authority] + + # 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_certificate_authorities(self, + request: service.ListCertificateAuthoritiesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateAuthoritiesPager: + r"""Lists + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesRequest): + The request object. Request message for + [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateAuthorities]. + parent (str): + Required. The resource name of the + [CaPool][google.cloud.security.privateca.v1.CaPool] + associated with the + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority], + in the format ``projects/*/locations/*/caPools/*``. + + 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesPager: + Response message for + [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateAuthorities]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.ListCertificateAuthoritiesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListCertificateAuthoritiesRequest): + request = service.ListCertificateAuthoritiesRequest(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_authorities] + + # 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.ListCertificateAuthoritiesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def undelete_certificate_authority(self, + request: service.UndeleteCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Undelete a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that has been deleted. + + Args: + request (google.cloud.security.privateca_v1.types.UndeleteCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.UndeleteCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.UndeleteCertificateAuthority]. + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.UndeleteCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UndeleteCertificateAuthorityRequest): + request = service.UndeleteCertificateAuthorityRequest(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.undelete_certificate_authority] + + # 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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_certificate_authority(self, + request: service.DeleteCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Delete a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1.types.DeleteCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.DeleteCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCertificateAuthority]. + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.DeleteCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.DeleteCertificateAuthorityRequest): + request = service.DeleteCertificateAuthorityRequest(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_authority] + + # 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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_certificate_authority(self, + request: service.UpdateCertificateAuthorityRequest = None, + *, + certificate_authority: resources.CertificateAuthority = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Update a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1.types.UpdateCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateAuthority]. + certificate_authority (google.cloud.security.privateca_v1.types.CertificateAuthority): + Required. + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + with updated values. + + This corresponds to the ``certificate_authority`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be + updated in this request. + + 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.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_authority, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.UpdateCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateCertificateAuthorityRequest): + request = service.UpdateCertificateAuthorityRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_authority is not None: + request.certificate_authority = certificate_authority + 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_authority] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("certificate_authority.name", request.certificate_authority.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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_ca_pool(self, + request: service.CreateCaPoolRequest = None, + *, + parent: str = None, + ca_pool: resources.CaPool = None, + ca_pool_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (google.cloud.security.privateca_v1.types.CreateCaPoolRequest): + The request object. Request message for + [CertificateAuthorityService.CreateCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCaPool]. + parent (str): + Required. The resource name of the location associated + with the + [CaPool][google.cloud.security.privateca.v1.CaPool], in + the format ``projects/*/locations/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + ca_pool (google.cloud.security.privateca_v1.types.CaPool): + Required. A + [CaPool][google.cloud.security.privateca.v1.CaPool] with + initial field values. + + This corresponds to the ``ca_pool`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + ca_pool_id (str): + Required. It must be unique within a location and match + the regular expression ``[a-zA-Z0-9_-]{1,63}`` + + This corresponds to the ``ca_pool_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.security.privateca_v1.types.CaPool` A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] + that form a trust anchor. A + [CaPool][google.cloud.security.privateca.v1.CaPool] + can be used to manage issuance policies for one or + more + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources and to rotate CA certificates in and out of + the trust anchor. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, ca_pool, ca_pool_id]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.CreateCaPoolRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateCaPoolRequest): + request = service.CreateCaPoolRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if ca_pool is not None: + request.ca_pool = ca_pool + if ca_pool_id is not None: + request.ca_pool_id = ca_pool_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_ca_pool] + + # 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, + resources.CaPool, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_ca_pool(self, + request: service.UpdateCaPoolRequest = None, + *, + ca_pool: resources.CaPool = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (google.cloud.security.privateca_v1.types.UpdateCaPoolRequest): + The request object. Request message for + [CertificateAuthorityService.UpdateCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCaPool]. + ca_pool (google.cloud.security.privateca_v1.types.CaPool): + Required. + [CaPool][google.cloud.security.privateca.v1.CaPool] with + updated values. + + This corresponds to the ``ca_pool`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be + updated in this request. + + 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.security.privateca_v1.types.CaPool` A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] + that form a trust anchor. A + [CaPool][google.cloud.security.privateca.v1.CaPool] + can be used to manage issuance policies for one or + more + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources and to rotate CA certificates in and out of + the trust anchor. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([ca_pool, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.UpdateCaPoolRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateCaPoolRequest): + request = service.UpdateCaPoolRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if ca_pool is not None: + request.ca_pool = ca_pool + 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_ca_pool] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("ca_pool.name", request.ca_pool.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, + resources.CaPool, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_ca_pool(self, + request: service.GetCaPoolRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CaPool: + r"""Returns a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (google.cloud.security.privateca_v1.types.GetCaPoolRequest): + The request object. Request message for + [CertificateAuthorityService.GetCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCaPool]. + name (str): + Required. The + [name][google.cloud.security.privateca.v1.CaPool.name] + of the + [CaPool][google.cloud.security.privateca.v1.CaPool] to + get. + + 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.security.privateca_v1.types.CaPool: + A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] + that form a trust anchor. A + [CaPool][google.cloud.security.privateca.v1.CaPool] + can be used to manage issuance policies for one or + more + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources and to rotate CA certificates in and out of + the trust anchor. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetCaPoolRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetCaPoolRequest): + request = service.GetCaPoolRequest(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_ca_pool] + + # 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_ca_pools(self, + request: service.ListCaPoolsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCaPoolsPager: + r"""Lists [CaPools][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (google.cloud.security.privateca_v1.types.ListCaPoolsRequest): + The request object. Request message for + [CertificateAuthorityService.ListCaPools][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCaPools]. + parent (str): + Required. The resource name of the location associated + with the + [CaPools][google.cloud.security.privateca.v1.CaPool], 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCaPoolsPager: + Response message for + [CertificateAuthorityService.ListCaPools][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCaPools]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.ListCaPoolsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListCaPoolsRequest): + request = service.ListCaPoolsRequest(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_ca_pools] + + # 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.ListCaPoolsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_ca_pool(self, + request: service.DeleteCaPoolRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (google.cloud.security.privateca_v1.types.DeleteCaPoolRequest): + The request object. Request message for + [CertificateAuthorityService.DeleteCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCaPool]. + name (str): + Required. The resource name for this + [CaPool][google.cloud.security.privateca.v1.CaPool] in + the format ``projects/*/locations/*/caPools/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CaPool` A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] + that form a trust anchor. A + [CaPool][google.cloud.security.privateca.v1.CaPool] + can be used to manage issuance policies for one or + more + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources and to rotate CA certificates in and out of + the trust anchor. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.DeleteCaPoolRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.DeleteCaPoolRequest): + request = service.DeleteCaPoolRequest(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_ca_pool] + + # 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, + resources.CaPool, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def fetch_ca_certs(self, + request: service.FetchCaCertsRequest = None, + *, + ca_pool: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.FetchCaCertsResponse: + r"""FetchCaCerts returns the current trust anchor for the + [CaPool][google.cloud.security.privateca.v1.CaPool]. This will + include CA certificate chains for all ACTIVE + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources in the + [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Args: + request (google.cloud.security.privateca_v1.types.FetchCaCertsRequest): + The request object. Request message for + [CertificateAuthorityService.FetchCaCerts][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCaCerts]. + ca_pool (str): + Required. The resource name for the + [CaPool][google.cloud.security.privateca.v1.CaPool] in + the format ``projects/*/locations/*/caPools/*``. + + This corresponds to the ``ca_pool`` 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.security.privateca_v1.types.FetchCaCertsResponse: + Response message for + [CertificateAuthorityService.FetchCaCerts][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCaCerts]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([ca_pool]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.FetchCaCertsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.FetchCaCertsRequest): + request = service.FetchCaCertsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if ca_pool is not None: + request.ca_pool = ca_pool + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.fetch_ca_certs] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("ca_pool", request.ca_pool), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_certificate_revocation_list(self, + request: service.GetCertificateRevocationListRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CertificateRevocationList: + r"""Returns a + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. + + Args: + request (google.cloud.security.privateca_v1.types.GetCertificateRevocationListRequest): + The request object. Request message for + [CertificateAuthorityService.GetCertificateRevocationList][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateRevocationList]. + name (str): + Required. The + [name][google.cloud.security.privateca.v1.CertificateRevocationList.name] + of the + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] + to get. + + 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.security.privateca_v1.types.CertificateRevocationList: + A [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] corresponds to a signed X.509 certificate + Revocation List (CRL). A CRL contains the serial + numbers of certificates that should no longer be + trusted. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetCertificateRevocationListRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetCertificateRevocationListRequest): + request = service.GetCertificateRevocationListRequest(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_revocation_list] + + # 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_certificate_revocation_lists(self, + request: service.ListCertificateRevocationListsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateRevocationListsPager: + r"""Lists + [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. + + Args: + request (google.cloud.security.privateca_v1.types.ListCertificateRevocationListsRequest): + The request object. Request message for + [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateRevocationLists]. + parent (str): + Required. The resource name of the location associated + with the + [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList], + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + + 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateRevocationListsPager: + Response message for + [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateRevocationLists]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.ListCertificateRevocationListsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListCertificateRevocationListsRequest): + request = service.ListCertificateRevocationListsRequest(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_revocation_lists] + + # 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.ListCertificateRevocationListsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_certificate_revocation_list(self, + request: service.UpdateCertificateRevocationListRequest = None, + *, + certificate_revocation_list: resources.CertificateRevocationList = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Update a + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. + + Args: + request (google.cloud.security.privateca_v1.types.UpdateCertificateRevocationListRequest): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificateRevocationList][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateRevocationList]. + certificate_revocation_list (google.cloud.security.privateca_v1.types.CertificateRevocationList): + Required. + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] + with updated values. + + This corresponds to the ``certificate_revocation_list`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be + updated in this request. + + 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.security.privateca_v1.types.CertificateRevocationList` A [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] corresponds to a signed X.509 certificate + Revocation List (CRL). A CRL contains the serial + numbers of certificates that should no longer be + trusted. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_revocation_list, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.UpdateCertificateRevocationListRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateCertificateRevocationListRequest): + request = service.UpdateCertificateRevocationListRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_revocation_list is not None: + request.certificate_revocation_list = certificate_revocation_list + 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_revocation_list] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("certificate_revocation_list.name", request.certificate_revocation_list.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, + resources.CertificateRevocationList, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_certificate_template(self, + request: service.CreateCertificateTemplateRequest = None, + *, + parent: str = None, + certificate_template: resources.CertificateTemplate = None, + certificate_template_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Create a new + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + in a given Project and Location. + + Args: + request (google.cloud.security.privateca_v1.types.CreateCertificateTemplateRequest): + The request object. Request message for + [CertificateAuthorityService.CreateCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificateTemplate]. + parent (str): + Required. The resource name of the location associated + with the + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate], + 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_template (google.cloud.security.privateca_v1.types.CertificateTemplate): + Required. A + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + with initial field values. + + This corresponds to the ``certificate_template`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_template_id (str): + Required. It must be unique within a location and match + the regular expression ``[a-zA-Z0-9_-]{1,63}`` + + This corresponds to the ``certificate_template_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.security.privateca_v1.types.CertificateTemplate` A [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] refers to a managed template for certificate + issuance. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate_template, certificate_template_id]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.CreateCertificateTemplateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateCertificateTemplateRequest): + request = service.CreateCertificateTemplateRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate_template is not None: + request.certificate_template = certificate_template + if certificate_template_id is not None: + request.certificate_template_id = certificate_template_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_certificate_template] + + # 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, + resources.CertificateTemplate, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_certificate_template(self, + request: service.DeleteCertificateTemplateRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""DeleteCertificateTemplate deletes a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + + Args: + request (google.cloud.security.privateca_v1.types.DeleteCertificateTemplateRequest): + The request object. Request message for + [CertificateAuthorityService.DeleteCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCertificateTemplate]. + name (str): + Required. The resource name for this + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + in the format + ``projects/*/locations/*/certificateTemplates/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.DeleteCertificateTemplateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.DeleteCertificateTemplateRequest): + request = service.DeleteCertificateTemplateRequest(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_template] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_certificate_template(self, + request: service.GetCertificateTemplateRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CertificateTemplate: + r"""Returns a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + + Args: + request (google.cloud.security.privateca_v1.types.GetCertificateTemplateRequest): + The request object. Request message for + [CertificateAuthorityService.GetCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateTemplate]. + name (str): + Required. The + [name][google.cloud.security.privateca.v1.CertificateTemplate.name] + of the + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + to get. + + 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.security.privateca_v1.types.CertificateTemplate: + A [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] refers to a managed template for certificate + issuance. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetCertificateTemplateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetCertificateTemplateRequest): + request = service.GetCertificateTemplateRequest(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_template] + + # 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_certificate_templates(self, + request: service.ListCertificateTemplatesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateTemplatesPager: + r"""Lists + [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. + + Args: + request (google.cloud.security.privateca_v1.types.ListCertificateTemplatesRequest): + The request object. Request message for + [CertificateAuthorityService.ListCertificateTemplates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateTemplates]. + parent (str): + Required. The resource name of the location associated + with the + [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate], + 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateTemplatesPager: + Response message for + [CertificateAuthorityService.ListCertificateTemplates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateTemplates]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.ListCertificateTemplatesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListCertificateTemplatesRequest): + request = service.ListCertificateTemplatesRequest(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_templates] + + # 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.ListCertificateTemplatesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_certificate_template(self, + request: service.UpdateCertificateTemplateRequest = None, + *, + certificate_template: resources.CertificateTemplate = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Update a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + + Args: + request (google.cloud.security.privateca_v1.types.UpdateCertificateTemplateRequest): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateTemplate]. + certificate_template (google.cloud.security.privateca_v1.types.CertificateTemplate): + Required. + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + with updated values. + + This corresponds to the ``certificate_template`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be + updated in this request. + + 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.security.privateca_v1.types.CertificateTemplate` A [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] refers to a managed template for certificate + issuance. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_template, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.UpdateCertificateTemplateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateCertificateTemplateRequest): + request = service.UpdateCertificateTemplateRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_template is not None: + request.certificate_template = certificate_template + 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_template] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("certificate_template.name", request.certificate_template.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, + resources.CertificateTemplate, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-security-privateca", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "CertificateAuthorityServiceClient", +) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py new file mode 100644 index 0000000..ae535cb --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py @@ -0,0 +1,629 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional + +from google.cloud.security.privateca_v1.types import resources +from google.cloud.security.privateca_v1.types import service + + +class ListCertificatesPager: + """A pager for iterating through ``list_certificates`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_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.security.privateca_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[..., service.ListCertificatesResponse], + request: service.ListCertificatesRequest, + response: service.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.security.privateca_v1.types.ListCertificatesRequest): + The initial request object. + response (google.cloud.security.privateca_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 = service.ListCertificatesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.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) -> Iterable[resources.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.security.privateca_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.security.privateca_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[service.ListCertificatesResponse]], + request: service.ListCertificatesRequest, + response: service.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.security.privateca_v1.types.ListCertificatesRequest): + The initial request object. + response (google.cloud.security.privateca_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 = service.ListCertificatesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.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) -> AsyncIterable[resources.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 ListCertificateAuthoritiesPager: + """A pager for iterating through ``list_certificate_authorities`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``certificate_authorities`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCertificateAuthorities`` requests and continue to iterate + through the ``certificate_authorities`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., service.ListCertificateAuthoritiesResponse], + request: service.ListCertificateAuthoritiesRequest, + response: service.ListCertificateAuthoritiesResponse, + *, + 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.security.privateca_v1.types.ListCertificateAuthoritiesRequest): + The initial request object. + response (google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListCertificateAuthoritiesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.ListCertificateAuthoritiesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.CertificateAuthority]: + for page in self.pages: + yield from page.certificate_authorities + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateAuthoritiesAsyncPager: + """A pager for iterating through ``list_certificate_authorities`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``certificate_authorities`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCertificateAuthorities`` requests and continue to iterate + through the ``certificate_authorities`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., Awaitable[service.ListCertificateAuthoritiesResponse]], + request: service.ListCertificateAuthoritiesRequest, + response: service.ListCertificateAuthoritiesResponse, + *, + 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.security.privateca_v1.types.ListCertificateAuthoritiesRequest): + The initial request object. + response (google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListCertificateAuthoritiesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.ListCertificateAuthoritiesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.CertificateAuthority]: + async def async_generator(): + async for page in self.pages: + for response in page.certificate_authorities: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCaPoolsPager: + """A pager for iterating through ``list_ca_pools`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1.types.ListCaPoolsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``ca_pools`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCaPools`` requests and continue to iterate + through the ``ca_pools`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1.types.ListCaPoolsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., service.ListCaPoolsResponse], + request: service.ListCaPoolsRequest, + response: service.ListCaPoolsResponse, + *, + 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.security.privateca_v1.types.ListCaPoolsRequest): + The initial request object. + response (google.cloud.security.privateca_v1.types.ListCaPoolsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListCaPoolsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.ListCaPoolsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.CaPool]: + for page in self.pages: + yield from page.ca_pools + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCaPoolsAsyncPager: + """A pager for iterating through ``list_ca_pools`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1.types.ListCaPoolsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``ca_pools`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCaPools`` requests and continue to iterate + through the ``ca_pools`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1.types.ListCaPoolsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., Awaitable[service.ListCaPoolsResponse]], + request: service.ListCaPoolsRequest, + response: service.ListCaPoolsResponse, + *, + 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.security.privateca_v1.types.ListCaPoolsRequest): + The initial request object. + response (google.cloud.security.privateca_v1.types.ListCaPoolsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListCaPoolsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.ListCaPoolsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.CaPool]: + async def async_generator(): + async for page in self.pages: + for response in page.ca_pools: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateRevocationListsPager: + """A pager for iterating through ``list_certificate_revocation_lists`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1.types.ListCertificateRevocationListsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``certificate_revocation_lists`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCertificateRevocationLists`` requests and continue to iterate + through the ``certificate_revocation_lists`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1.types.ListCertificateRevocationListsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., service.ListCertificateRevocationListsResponse], + request: service.ListCertificateRevocationListsRequest, + response: service.ListCertificateRevocationListsResponse, + *, + 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.security.privateca_v1.types.ListCertificateRevocationListsRequest): + The initial request object. + response (google.cloud.security.privateca_v1.types.ListCertificateRevocationListsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListCertificateRevocationListsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.ListCertificateRevocationListsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.CertificateRevocationList]: + for page in self.pages: + yield from page.certificate_revocation_lists + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateRevocationListsAsyncPager: + """A pager for iterating through ``list_certificate_revocation_lists`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1.types.ListCertificateRevocationListsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``certificate_revocation_lists`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCertificateRevocationLists`` requests and continue to iterate + through the ``certificate_revocation_lists`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1.types.ListCertificateRevocationListsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., Awaitable[service.ListCertificateRevocationListsResponse]], + request: service.ListCertificateRevocationListsRequest, + response: service.ListCertificateRevocationListsResponse, + *, + 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.security.privateca_v1.types.ListCertificateRevocationListsRequest): + The initial request object. + response (google.cloud.security.privateca_v1.types.ListCertificateRevocationListsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListCertificateRevocationListsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.ListCertificateRevocationListsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.CertificateRevocationList]: + async def async_generator(): + async for page in self.pages: + for response in page.certificate_revocation_lists: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateTemplatesPager: + """A pager for iterating through ``list_certificate_templates`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1.types.ListCertificateTemplatesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``certificate_templates`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCertificateTemplates`` requests and continue to iterate + through the ``certificate_templates`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1.types.ListCertificateTemplatesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., service.ListCertificateTemplatesResponse], + request: service.ListCertificateTemplatesRequest, + response: service.ListCertificateTemplatesResponse, + *, + 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.security.privateca_v1.types.ListCertificateTemplatesRequest): + The initial request object. + response (google.cloud.security.privateca_v1.types.ListCertificateTemplatesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListCertificateTemplatesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.ListCertificateTemplatesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.CertificateTemplate]: + for page in self.pages: + yield from page.certificate_templates + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateTemplatesAsyncPager: + """A pager for iterating through ``list_certificate_templates`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1.types.ListCertificateTemplatesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``certificate_templates`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCertificateTemplates`` requests and continue to iterate + through the ``certificate_templates`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1.types.ListCertificateTemplatesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., Awaitable[service.ListCertificateTemplatesResponse]], + request: service.ListCertificateTemplatesRequest, + response: service.ListCertificateTemplatesResponse, + *, + 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.security.privateca_v1.types.ListCertificateTemplatesRequest): + The initial request object. + response (google.cloud.security.privateca_v1.types.ListCertificateTemplatesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListCertificateTemplatesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.ListCertificateTemplatesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.CertificateTemplate]: + async def async_generator(): + async for page in self.pages: + for response in page.certificate_templates: + 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/security/privateca_v1/services/certificate_authority_service/transports/__init__.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/__init__.py new file mode 100644 index 0000000..8a08053 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +from typing import Dict, Type + +from .base import CertificateAuthorityServiceTransport +from .grpc import CertificateAuthorityServiceGrpcTransport +from .grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[CertificateAuthorityServiceTransport]] +_transport_registry['grpc'] = CertificateAuthorityServiceGrpcTransport +_transport_registry['grpc_asyncio'] = CertificateAuthorityServiceGrpcAsyncIOTransport + +__all__ = ( + 'CertificateAuthorityServiceTransport', + 'CertificateAuthorityServiceGrpcTransport', + 'CertificateAuthorityServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py new file mode 100644 index 0000000..262576c --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py @@ -0,0 +1,582 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version +import pkg_resources + +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore + +from google.cloud.security.privateca_v1.types import resources +from google.cloud.security.privateca_v1.types import service +from google.longrunning import operations_pb2 # type: ignore + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + 'google-cloud-security-privateca', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + + +class CertificateAuthorityServiceTransport(abc.ABC): + """Abstract transport class for CertificateAuthorityService.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'privateca.googleapis.com' + def __init__( + self, *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + **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. + """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ':' not in host: + host += ':443' + self._host = host + + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + + # Save the scopes. + self._scopes = scopes or self.AUTH_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) + + # Save the credentials. + self._credentials = credentials + + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.create_certificate: gapic_v1.method.wrap_method( + self.create_certificate, + default_timeout=None, + client_info=client_info, + ), + self.get_certificate: gapic_v1.method.wrap_method( + self.get_certificate, + default_timeout=None, + client_info=client_info, + ), + self.list_certificates: gapic_v1.method.wrap_method( + self.list_certificates, + default_timeout=None, + client_info=client_info, + ), + self.revoke_certificate: gapic_v1.method.wrap_method( + self.revoke_certificate, + default_timeout=None, + client_info=client_info, + ), + self.update_certificate: gapic_v1.method.wrap_method( + self.update_certificate, + default_timeout=None, + client_info=client_info, + ), + self.activate_certificate_authority: gapic_v1.method.wrap_method( + self.activate_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.create_certificate_authority: gapic_v1.method.wrap_method( + self.create_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.disable_certificate_authority: gapic_v1.method.wrap_method( + self.disable_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.enable_certificate_authority: gapic_v1.method.wrap_method( + self.enable_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.fetch_certificate_authority_csr: gapic_v1.method.wrap_method( + self.fetch_certificate_authority_csr, + default_timeout=None, + client_info=client_info, + ), + self.get_certificate_authority: gapic_v1.method.wrap_method( + self.get_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.list_certificate_authorities: gapic_v1.method.wrap_method( + self.list_certificate_authorities, + default_timeout=None, + client_info=client_info, + ), + self.undelete_certificate_authority: gapic_v1.method.wrap_method( + self.undelete_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.delete_certificate_authority: gapic_v1.method.wrap_method( + self.delete_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.update_certificate_authority: gapic_v1.method.wrap_method( + self.update_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.create_ca_pool: gapic_v1.method.wrap_method( + self.create_ca_pool, + default_timeout=None, + client_info=client_info, + ), + self.update_ca_pool: gapic_v1.method.wrap_method( + self.update_ca_pool, + default_timeout=None, + client_info=client_info, + ), + self.get_ca_pool: gapic_v1.method.wrap_method( + self.get_ca_pool, + default_timeout=None, + client_info=client_info, + ), + self.list_ca_pools: gapic_v1.method.wrap_method( + self.list_ca_pools, + default_timeout=None, + client_info=client_info, + ), + self.delete_ca_pool: gapic_v1.method.wrap_method( + self.delete_ca_pool, + default_timeout=None, + client_info=client_info, + ), + self.fetch_ca_certs: gapic_v1.method.wrap_method( + self.fetch_ca_certs, + default_timeout=None, + client_info=client_info, + ), + self.get_certificate_revocation_list: gapic_v1.method.wrap_method( + self.get_certificate_revocation_list, + default_timeout=None, + client_info=client_info, + ), + self.list_certificate_revocation_lists: gapic_v1.method.wrap_method( + self.list_certificate_revocation_lists, + default_timeout=None, + client_info=client_info, + ), + self.update_certificate_revocation_list: gapic_v1.method.wrap_method( + self.update_certificate_revocation_list, + default_timeout=None, + client_info=client_info, + ), + self.create_certificate_template: gapic_v1.method.wrap_method( + self.create_certificate_template, + default_timeout=None, + client_info=client_info, + ), + self.delete_certificate_template: gapic_v1.method.wrap_method( + self.delete_certificate_template, + default_timeout=None, + client_info=client_info, + ), + self.get_certificate_template: gapic_v1.method.wrap_method( + self.get_certificate_template, + default_timeout=None, + client_info=client_info, + ), + self.list_certificate_templates: gapic_v1.method.wrap_method( + self.list_certificate_templates, + default_timeout=None, + client_info=client_info, + ), + self.update_certificate_template: gapic_v1.method.wrap_method( + self.update_certificate_template, + default_timeout=None, + client_info=client_info, + ), + } + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def create_certificate(self) -> Callable[ + [service.CreateCertificateRequest], + Union[ + resources.Certificate, + Awaitable[resources.Certificate] + ]]: + raise NotImplementedError() + + @property + def get_certificate(self) -> Callable[ + [service.GetCertificateRequest], + Union[ + resources.Certificate, + Awaitable[resources.Certificate] + ]]: + raise NotImplementedError() + + @property + def list_certificates(self) -> Callable[ + [service.ListCertificatesRequest], + Union[ + service.ListCertificatesResponse, + Awaitable[service.ListCertificatesResponse] + ]]: + raise NotImplementedError() + + @property + def revoke_certificate(self) -> Callable[ + [service.RevokeCertificateRequest], + Union[ + resources.Certificate, + Awaitable[resources.Certificate] + ]]: + raise NotImplementedError() + + @property + def update_certificate(self) -> Callable[ + [service.UpdateCertificateRequest], + Union[ + resources.Certificate, + Awaitable[resources.Certificate] + ]]: + raise NotImplementedError() + + @property + def activate_certificate_authority(self) -> Callable[ + [service.ActivateCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_certificate_authority(self) -> Callable[ + [service.CreateCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def disable_certificate_authority(self) -> Callable[ + [service.DisableCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def enable_certificate_authority(self) -> Callable[ + [service.EnableCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def fetch_certificate_authority_csr(self) -> Callable[ + [service.FetchCertificateAuthorityCsrRequest], + Union[ + service.FetchCertificateAuthorityCsrResponse, + Awaitable[service.FetchCertificateAuthorityCsrResponse] + ]]: + raise NotImplementedError() + + @property + def get_certificate_authority(self) -> Callable[ + [service.GetCertificateAuthorityRequest], + Union[ + resources.CertificateAuthority, + Awaitable[resources.CertificateAuthority] + ]]: + raise NotImplementedError() + + @property + def list_certificate_authorities(self) -> Callable[ + [service.ListCertificateAuthoritiesRequest], + Union[ + service.ListCertificateAuthoritiesResponse, + Awaitable[service.ListCertificateAuthoritiesResponse] + ]]: + raise NotImplementedError() + + @property + def undelete_certificate_authority(self) -> Callable[ + [service.UndeleteCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_certificate_authority(self) -> Callable[ + [service.DeleteCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_certificate_authority(self) -> Callable[ + [service.UpdateCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_ca_pool(self) -> Callable[ + [service.CreateCaPoolRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_ca_pool(self) -> Callable[ + [service.UpdateCaPoolRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_ca_pool(self) -> Callable[ + [service.GetCaPoolRequest], + Union[ + resources.CaPool, + Awaitable[resources.CaPool] + ]]: + raise NotImplementedError() + + @property + def list_ca_pools(self) -> Callable[ + [service.ListCaPoolsRequest], + Union[ + service.ListCaPoolsResponse, + Awaitable[service.ListCaPoolsResponse] + ]]: + raise NotImplementedError() + + @property + def delete_ca_pool(self) -> Callable[ + [service.DeleteCaPoolRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def fetch_ca_certs(self) -> Callable[ + [service.FetchCaCertsRequest], + Union[ + service.FetchCaCertsResponse, + Awaitable[service.FetchCaCertsResponse] + ]]: + raise NotImplementedError() + + @property + def get_certificate_revocation_list(self) -> Callable[ + [service.GetCertificateRevocationListRequest], + Union[ + resources.CertificateRevocationList, + Awaitable[resources.CertificateRevocationList] + ]]: + raise NotImplementedError() + + @property + def list_certificate_revocation_lists(self) -> Callable[ + [service.ListCertificateRevocationListsRequest], + Union[ + service.ListCertificateRevocationListsResponse, + Awaitable[service.ListCertificateRevocationListsResponse] + ]]: + raise NotImplementedError() + + @property + def update_certificate_revocation_list(self) -> Callable[ + [service.UpdateCertificateRevocationListRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_certificate_template(self) -> Callable[ + [service.CreateCertificateTemplateRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_certificate_template(self) -> Callable[ + [service.DeleteCertificateTemplateRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_certificate_template(self) -> Callable[ + [service.GetCertificateTemplateRequest], + Union[ + resources.CertificateTemplate, + Awaitable[resources.CertificateTemplate] + ]]: + raise NotImplementedError() + + @property + def list_certificate_templates(self) -> Callable[ + [service.ListCertificateTemplatesRequest], + Union[ + service.ListCertificateTemplatesResponse, + Awaitable[service.ListCertificateTemplatesResponse] + ]]: + raise NotImplementedError() + + @property + def update_certificate_template(self) -> Callable[ + [service.UpdateCertificateTemplateRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + +__all__ = ( + 'CertificateAuthorityServiceTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py new file mode 100644 index 0000000..4c91c5e --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py @@ -0,0 +1,1055 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.security.privateca_v1.types import resources +from google.cloud.security.privateca_v1.types import service +from google.longrunning import operations_pb2 # type: ignore +from .base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO + + +class CertificateAuthorityServiceGrpcTransport(CertificateAuthorityServiceTransport): + """gRPC backend transport for CertificateAuthorityService. + + [Certificate Authority + Service][google.cloud.security.privateca.v1.CertificateAuthorityService] + manages private certificate authorities and issued certificates. + + 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 = 'privateca.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'privateca.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_certificate(self) -> Callable[ + [service.CreateCertificateRequest], + resources.Certificate]: + r"""Return a callable for the create certificate method over gRPC. + + Create a new + [Certificate][google.cloud.security.privateca.v1.Certificate] in + a given Project, Location from a particular + [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.CreateCertificateRequest], + ~.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 'create_certificate' not in self._stubs: + self._stubs['create_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificate', + request_serializer=service.CreateCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['create_certificate'] + + @property + def get_certificate(self) -> Callable[ + [service.GetCertificateRequest], + resources.Certificate]: + r"""Return a callable for the get certificate method over gRPC. + + Returns a + [Certificate][google.cloud.security.privateca.v1.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.security.privateca.v1.CertificateAuthorityService/GetCertificate', + request_serializer=service.GetCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['get_certificate'] + + @property + def list_certificates(self) -> Callable[ + [service.ListCertificatesRequest], + service.ListCertificatesResponse]: + r"""Return a callable for the list certificates method over gRPC. + + Lists + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + 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.security.privateca.v1.CertificateAuthorityService/ListCertificates', + request_serializer=service.ListCertificatesRequest.serialize, + response_deserializer=service.ListCertificatesResponse.deserialize, + ) + return self._stubs['list_certificates'] + + @property + def revoke_certificate(self) -> Callable[ + [service.RevokeCertificateRequest], + resources.Certificate]: + r"""Return a callable for the revoke certificate method over gRPC. + + Revoke a + [Certificate][google.cloud.security.privateca.v1.Certificate]. + + Returns: + Callable[[~.RevokeCertificateRequest], + ~.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 'revoke_certificate' not in self._stubs: + self._stubs['revoke_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/RevokeCertificate', + request_serializer=service.RevokeCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['revoke_certificate'] + + @property + def update_certificate(self) -> Callable[ + [service.UpdateCertificateRequest], + resources.Certificate]: + r"""Return a callable for the update certificate method over gRPC. + + Update a + [Certificate][google.cloud.security.privateca.v1.Certificate]. + Currently, the only field you can update is the + [labels][google.cloud.security.privateca.v1.Certificate.labels] + field. + + Returns: + Callable[[~.UpdateCertificateRequest], + ~.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 'update_certificate' not in self._stubs: + self._stubs['update_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificate', + request_serializer=service.UpdateCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['update_certificate'] + + @property + def activate_certificate_authority(self) -> Callable[ + [service.ActivateCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the activate certificate authority method over gRPC. + + Activate a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that is in state + [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. + After the parent Certificate Authority signs a certificate + signing request from + [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr], + this method can complete the activation process. + + Returns: + Callable[[~.ActivateCertificateAuthorityRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'activate_certificate_authority' not in self._stubs: + self._stubs['activate_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/ActivateCertificateAuthority', + request_serializer=service.ActivateCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['activate_certificate_authority'] + + @property + def create_certificate_authority(self) -> Callable[ + [service.CreateCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the create certificate authority method over gRPC. + + Create a new + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in a given Project and Location. + + Returns: + Callable[[~.CreateCertificateAuthorityRequest], + ~.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_authority' not in self._stubs: + self._stubs['create_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateAuthority', + request_serializer=service.CreateCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate_authority'] + + @property + def disable_certificate_authority(self) -> Callable[ + [service.DisableCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the disable certificate authority method over gRPC. + + Disable a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Returns: + Callable[[~.DisableCertificateAuthorityRequest], + ~.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 'disable_certificate_authority' not in self._stubs: + self._stubs['disable_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/DisableCertificateAuthority', + request_serializer=service.DisableCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['disable_certificate_authority'] + + @property + def enable_certificate_authority(self) -> Callable[ + [service.EnableCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the enable certificate authority method over gRPC. + + Enable a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Returns: + Callable[[~.EnableCertificateAuthorityRequest], + ~.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 'enable_certificate_authority' not in self._stubs: + self._stubs['enable_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/EnableCertificateAuthority', + request_serializer=service.EnableCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['enable_certificate_authority'] + + @property + def fetch_certificate_authority_csr(self) -> Callable[ + [service.FetchCertificateAuthorityCsrRequest], + service.FetchCertificateAuthorityCsrResponse]: + r"""Return a callable for the fetch certificate authority + csr method over gRPC. + + Fetch a certificate signing request (CSR) from a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that is in state + [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. + The CSR must then be signed by the desired parent Certificate + Authority, which could be another + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resource, or could be an on-prem certificate authority. See also + [ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. + + Returns: + Callable[[~.FetchCertificateAuthorityCsrRequest], + ~.FetchCertificateAuthorityCsrResponse]: + 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 'fetch_certificate_authority_csr' not in self._stubs: + self._stubs['fetch_certificate_authority_csr'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/FetchCertificateAuthorityCsr', + request_serializer=service.FetchCertificateAuthorityCsrRequest.serialize, + response_deserializer=service.FetchCertificateAuthorityCsrResponse.deserialize, + ) + return self._stubs['fetch_certificate_authority_csr'] + + @property + def get_certificate_authority(self) -> Callable[ + [service.GetCertificateAuthorityRequest], + resources.CertificateAuthority]: + r"""Return a callable for the get certificate authority method over gRPC. + + Returns a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Returns: + Callable[[~.GetCertificateAuthorityRequest], + ~.CertificateAuthority]: + 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_authority' not in self._stubs: + self._stubs['get_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateAuthority', + request_serializer=service.GetCertificateAuthorityRequest.serialize, + response_deserializer=resources.CertificateAuthority.deserialize, + ) + return self._stubs['get_certificate_authority'] + + @property + def list_certificate_authorities(self) -> Callable[ + [service.ListCertificateAuthoritiesRequest], + service.ListCertificateAuthoritiesResponse]: + r"""Return a callable for the list certificate authorities method over gRPC. + + Lists + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. + + Returns: + Callable[[~.ListCertificateAuthoritiesRequest], + ~.ListCertificateAuthoritiesResponse]: + 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_authorities' not in self._stubs: + self._stubs['list_certificate_authorities'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateAuthorities', + request_serializer=service.ListCertificateAuthoritiesRequest.serialize, + response_deserializer=service.ListCertificateAuthoritiesResponse.deserialize, + ) + return self._stubs['list_certificate_authorities'] + + @property + def undelete_certificate_authority(self) -> Callable[ + [service.UndeleteCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the undelete certificate authority method over gRPC. + + Undelete a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that has been deleted. + + Returns: + Callable[[~.UndeleteCertificateAuthorityRequest], + ~.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 'undelete_certificate_authority' not in self._stubs: + self._stubs['undelete_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/UndeleteCertificateAuthority', + request_serializer=service.UndeleteCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['undelete_certificate_authority'] + + @property + def delete_certificate_authority(self) -> Callable[ + [service.DeleteCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete certificate authority method over gRPC. + + Delete a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Returns: + Callable[[~.DeleteCertificateAuthorityRequest], + ~.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_authority' not in self._stubs: + self._stubs['delete_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateAuthority', + request_serializer=service.DeleteCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_certificate_authority'] + + @property + def update_certificate_authority(self) -> Callable[ + [service.UpdateCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the update certificate authority method over gRPC. + + Update a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Returns: + Callable[[~.UpdateCertificateAuthorityRequest], + ~.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_authority' not in self._stubs: + self._stubs['update_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateAuthority', + request_serializer=service.UpdateCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_authority'] + + @property + def create_ca_pool(self) -> Callable[ + [service.CreateCaPoolRequest], + operations_pb2.Operation]: + r"""Return a callable for the create ca pool method over gRPC. + + Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.CreateCaPoolRequest], + ~.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_ca_pool' not in self._stubs: + self._stubs['create_ca_pool'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCaPool', + request_serializer=service.CreateCaPoolRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_ca_pool'] + + @property + def update_ca_pool(self) -> Callable[ + [service.UpdateCaPoolRequest], + operations_pb2.Operation]: + r"""Return a callable for the update ca pool method over gRPC. + + Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.UpdateCaPoolRequest], + ~.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_ca_pool' not in self._stubs: + self._stubs['update_ca_pool'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCaPool', + request_serializer=service.UpdateCaPoolRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_ca_pool'] + + @property + def get_ca_pool(self) -> Callable[ + [service.GetCaPoolRequest], + resources.CaPool]: + r"""Return a callable for the get ca pool method over gRPC. + + Returns a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.GetCaPoolRequest], + ~.CaPool]: + 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_ca_pool' not in self._stubs: + self._stubs['get_ca_pool'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCaPool', + request_serializer=service.GetCaPoolRequest.serialize, + response_deserializer=resources.CaPool.deserialize, + ) + return self._stubs['get_ca_pool'] + + @property + def list_ca_pools(self) -> Callable[ + [service.ListCaPoolsRequest], + service.ListCaPoolsResponse]: + r"""Return a callable for the list ca pools method over gRPC. + + Lists [CaPools][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.ListCaPoolsRequest], + ~.ListCaPoolsResponse]: + 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_ca_pools' not in self._stubs: + self._stubs['list_ca_pools'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCaPools', + request_serializer=service.ListCaPoolsRequest.serialize, + response_deserializer=service.ListCaPoolsResponse.deserialize, + ) + return self._stubs['list_ca_pools'] + + @property + def delete_ca_pool(self) -> Callable[ + [service.DeleteCaPoolRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete ca pool method over gRPC. + + Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.DeleteCaPoolRequest], + ~.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_ca_pool' not in self._stubs: + self._stubs['delete_ca_pool'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCaPool', + request_serializer=service.DeleteCaPoolRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_ca_pool'] + + @property + def fetch_ca_certs(self) -> Callable[ + [service.FetchCaCertsRequest], + service.FetchCaCertsResponse]: + r"""Return a callable for the fetch ca certs method over gRPC. + + FetchCaCerts returns the current trust anchor for the + [CaPool][google.cloud.security.privateca.v1.CaPool]. This will + include CA certificate chains for all ACTIVE + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources in the + [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.FetchCaCertsRequest], + ~.FetchCaCertsResponse]: + 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 'fetch_ca_certs' not in self._stubs: + self._stubs['fetch_ca_certs'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/FetchCaCerts', + request_serializer=service.FetchCaCertsRequest.serialize, + response_deserializer=service.FetchCaCertsResponse.deserialize, + ) + return self._stubs['fetch_ca_certs'] + + @property + def get_certificate_revocation_list(self) -> Callable[ + [service.GetCertificateRevocationListRequest], + resources.CertificateRevocationList]: + r"""Return a callable for the get certificate revocation + list method over gRPC. + + Returns a + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. + + Returns: + Callable[[~.GetCertificateRevocationListRequest], + ~.CertificateRevocationList]: + 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_revocation_list' not in self._stubs: + self._stubs['get_certificate_revocation_list'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateRevocationList', + request_serializer=service.GetCertificateRevocationListRequest.serialize, + response_deserializer=resources.CertificateRevocationList.deserialize, + ) + return self._stubs['get_certificate_revocation_list'] + + @property + def list_certificate_revocation_lists(self) -> Callable[ + [service.ListCertificateRevocationListsRequest], + service.ListCertificateRevocationListsResponse]: + r"""Return a callable for the list certificate revocation + lists method over gRPC. + + Lists + [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. + + Returns: + Callable[[~.ListCertificateRevocationListsRequest], + ~.ListCertificateRevocationListsResponse]: + 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_revocation_lists' not in self._stubs: + self._stubs['list_certificate_revocation_lists'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateRevocationLists', + request_serializer=service.ListCertificateRevocationListsRequest.serialize, + response_deserializer=service.ListCertificateRevocationListsResponse.deserialize, + ) + return self._stubs['list_certificate_revocation_lists'] + + @property + def update_certificate_revocation_list(self) -> Callable[ + [service.UpdateCertificateRevocationListRequest], + operations_pb2.Operation]: + r"""Return a callable for the update certificate revocation + list method over gRPC. + + Update a + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. + + Returns: + Callable[[~.UpdateCertificateRevocationListRequest], + ~.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_revocation_list' not in self._stubs: + self._stubs['update_certificate_revocation_list'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateRevocationList', + request_serializer=service.UpdateCertificateRevocationListRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_revocation_list'] + + @property + def create_certificate_template(self) -> Callable[ + [service.CreateCertificateTemplateRequest], + operations_pb2.Operation]: + r"""Return a callable for the create certificate template method over gRPC. + + Create a new + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + in a given Project and Location. + + Returns: + Callable[[~.CreateCertificateTemplateRequest], + ~.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_template' not in self._stubs: + self._stubs['create_certificate_template'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateTemplate', + request_serializer=service.CreateCertificateTemplateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate_template'] + + @property + def delete_certificate_template(self) -> Callable[ + [service.DeleteCertificateTemplateRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete certificate template method over gRPC. + + DeleteCertificateTemplate deletes a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + + Returns: + Callable[[~.DeleteCertificateTemplateRequest], + ~.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_template' not in self._stubs: + self._stubs['delete_certificate_template'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateTemplate', + request_serializer=service.DeleteCertificateTemplateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_certificate_template'] + + @property + def get_certificate_template(self) -> Callable[ + [service.GetCertificateTemplateRequest], + resources.CertificateTemplate]: + r"""Return a callable for the get certificate template method over gRPC. + + Returns a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + + Returns: + Callable[[~.GetCertificateTemplateRequest], + ~.CertificateTemplate]: + 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_template' not in self._stubs: + self._stubs['get_certificate_template'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateTemplate', + request_serializer=service.GetCertificateTemplateRequest.serialize, + response_deserializer=resources.CertificateTemplate.deserialize, + ) + return self._stubs['get_certificate_template'] + + @property + def list_certificate_templates(self) -> Callable[ + [service.ListCertificateTemplatesRequest], + service.ListCertificateTemplatesResponse]: + r"""Return a callable for the list certificate templates method over gRPC. + + Lists + [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. + + Returns: + Callable[[~.ListCertificateTemplatesRequest], + ~.ListCertificateTemplatesResponse]: + 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_templates' not in self._stubs: + self._stubs['list_certificate_templates'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateTemplates', + request_serializer=service.ListCertificateTemplatesRequest.serialize, + response_deserializer=service.ListCertificateTemplatesResponse.deserialize, + ) + return self._stubs['list_certificate_templates'] + + @property + def update_certificate_template(self) -> Callable[ + [service.UpdateCertificateTemplateRequest], + operations_pb2.Operation]: + r"""Return a callable for the update certificate template method over gRPC. + + Update a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + + Returns: + Callable[[~.UpdateCertificateTemplateRequest], + ~.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_template' not in self._stubs: + self._stubs['update_certificate_template'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateTemplate', + request_serializer=service.UpdateCertificateTemplateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_template'] + + +__all__ = ( + 'CertificateAuthorityServiceGrpcTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py new file mode 100644 index 0000000..ae7ed18 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py @@ -0,0 +1,1059 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.security.privateca_v1.types import resources +from google.cloud.security.privateca_v1.types import service +from google.longrunning import operations_pb2 # type: ignore +from .base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import CertificateAuthorityServiceGrpcTransport + + +class CertificateAuthorityServiceGrpcAsyncIOTransport(CertificateAuthorityServiceTransport): + """gRPC AsyncIO backend transport for CertificateAuthorityService. + + [Certificate Authority + Service][google.cloud.security.privateca.v1.CertificateAuthorityService] + manages private certificate authorities and issued certificates. + + 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 = 'privateca.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, + **kwargs + ) + + def __init__(self, *, + host: str = 'privateca.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_certificate(self) -> Callable[ + [service.CreateCertificateRequest], + Awaitable[resources.Certificate]]: + r"""Return a callable for the create certificate method over gRPC. + + Create a new + [Certificate][google.cloud.security.privateca.v1.Certificate] in + a given Project, Location from a particular + [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.CreateCertificateRequest], + 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 'create_certificate' not in self._stubs: + self._stubs['create_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificate', + request_serializer=service.CreateCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['create_certificate'] + + @property + def get_certificate(self) -> Callable[ + [service.GetCertificateRequest], + Awaitable[resources.Certificate]]: + r"""Return a callable for the get certificate method over gRPC. + + Returns a + [Certificate][google.cloud.security.privateca.v1.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.security.privateca.v1.CertificateAuthorityService/GetCertificate', + request_serializer=service.GetCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['get_certificate'] + + @property + def list_certificates(self) -> Callable[ + [service.ListCertificatesRequest], + Awaitable[service.ListCertificatesResponse]]: + r"""Return a callable for the list certificates method over gRPC. + + Lists + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + 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.security.privateca.v1.CertificateAuthorityService/ListCertificates', + request_serializer=service.ListCertificatesRequest.serialize, + response_deserializer=service.ListCertificatesResponse.deserialize, + ) + return self._stubs['list_certificates'] + + @property + def revoke_certificate(self) -> Callable[ + [service.RevokeCertificateRequest], + Awaitable[resources.Certificate]]: + r"""Return a callable for the revoke certificate method over gRPC. + + Revoke a + [Certificate][google.cloud.security.privateca.v1.Certificate]. + + Returns: + Callable[[~.RevokeCertificateRequest], + 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 'revoke_certificate' not in self._stubs: + self._stubs['revoke_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/RevokeCertificate', + request_serializer=service.RevokeCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['revoke_certificate'] + + @property + def update_certificate(self) -> Callable[ + [service.UpdateCertificateRequest], + Awaitable[resources.Certificate]]: + r"""Return a callable for the update certificate method over gRPC. + + Update a + [Certificate][google.cloud.security.privateca.v1.Certificate]. + Currently, the only field you can update is the + [labels][google.cloud.security.privateca.v1.Certificate.labels] + field. + + Returns: + Callable[[~.UpdateCertificateRequest], + 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 'update_certificate' not in self._stubs: + self._stubs['update_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificate', + request_serializer=service.UpdateCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['update_certificate'] + + @property + def activate_certificate_authority(self) -> Callable[ + [service.ActivateCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the activate certificate authority method over gRPC. + + Activate a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that is in state + [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. + After the parent Certificate Authority signs a certificate + signing request from + [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr], + this method can complete the activation process. + + Returns: + Callable[[~.ActivateCertificateAuthorityRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'activate_certificate_authority' not in self._stubs: + self._stubs['activate_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/ActivateCertificateAuthority', + request_serializer=service.ActivateCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['activate_certificate_authority'] + + @property + def create_certificate_authority(self) -> Callable[ + [service.CreateCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create certificate authority method over gRPC. + + Create a new + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in a given Project and Location. + + Returns: + Callable[[~.CreateCertificateAuthorityRequest], + 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_authority' not in self._stubs: + self._stubs['create_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateAuthority', + request_serializer=service.CreateCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate_authority'] + + @property + def disable_certificate_authority(self) -> Callable[ + [service.DisableCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the disable certificate authority method over gRPC. + + Disable a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Returns: + Callable[[~.DisableCertificateAuthorityRequest], + 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 'disable_certificate_authority' not in self._stubs: + self._stubs['disable_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/DisableCertificateAuthority', + request_serializer=service.DisableCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['disable_certificate_authority'] + + @property + def enable_certificate_authority(self) -> Callable[ + [service.EnableCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the enable certificate authority method over gRPC. + + Enable a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Returns: + Callable[[~.EnableCertificateAuthorityRequest], + 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 'enable_certificate_authority' not in self._stubs: + self._stubs['enable_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/EnableCertificateAuthority', + request_serializer=service.EnableCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['enable_certificate_authority'] + + @property + def fetch_certificate_authority_csr(self) -> Callable[ + [service.FetchCertificateAuthorityCsrRequest], + Awaitable[service.FetchCertificateAuthorityCsrResponse]]: + r"""Return a callable for the fetch certificate authority + csr method over gRPC. + + Fetch a certificate signing request (CSR) from a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that is in state + [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. + The CSR must then be signed by the desired parent Certificate + Authority, which could be another + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resource, or could be an on-prem certificate authority. See also + [ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. + + Returns: + Callable[[~.FetchCertificateAuthorityCsrRequest], + Awaitable[~.FetchCertificateAuthorityCsrResponse]]: + 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 'fetch_certificate_authority_csr' not in self._stubs: + self._stubs['fetch_certificate_authority_csr'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/FetchCertificateAuthorityCsr', + request_serializer=service.FetchCertificateAuthorityCsrRequest.serialize, + response_deserializer=service.FetchCertificateAuthorityCsrResponse.deserialize, + ) + return self._stubs['fetch_certificate_authority_csr'] + + @property + def get_certificate_authority(self) -> Callable[ + [service.GetCertificateAuthorityRequest], + Awaitable[resources.CertificateAuthority]]: + r"""Return a callable for the get certificate authority method over gRPC. + + Returns a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Returns: + Callable[[~.GetCertificateAuthorityRequest], + Awaitable[~.CertificateAuthority]]: + 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_authority' not in self._stubs: + self._stubs['get_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateAuthority', + request_serializer=service.GetCertificateAuthorityRequest.serialize, + response_deserializer=resources.CertificateAuthority.deserialize, + ) + return self._stubs['get_certificate_authority'] + + @property + def list_certificate_authorities(self) -> Callable[ + [service.ListCertificateAuthoritiesRequest], + Awaitable[service.ListCertificateAuthoritiesResponse]]: + r"""Return a callable for the list certificate authorities method over gRPC. + + Lists + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. + + Returns: + Callable[[~.ListCertificateAuthoritiesRequest], + Awaitable[~.ListCertificateAuthoritiesResponse]]: + 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_authorities' not in self._stubs: + self._stubs['list_certificate_authorities'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateAuthorities', + request_serializer=service.ListCertificateAuthoritiesRequest.serialize, + response_deserializer=service.ListCertificateAuthoritiesResponse.deserialize, + ) + return self._stubs['list_certificate_authorities'] + + @property + def undelete_certificate_authority(self) -> Callable[ + [service.UndeleteCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the undelete certificate authority method over gRPC. + + Undelete a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that has been deleted. + + Returns: + Callable[[~.UndeleteCertificateAuthorityRequest], + 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 'undelete_certificate_authority' not in self._stubs: + self._stubs['undelete_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/UndeleteCertificateAuthority', + request_serializer=service.UndeleteCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['undelete_certificate_authority'] + + @property + def delete_certificate_authority(self) -> Callable[ + [service.DeleteCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete certificate authority method over gRPC. + + Delete a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Returns: + Callable[[~.DeleteCertificateAuthorityRequest], + 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_authority' not in self._stubs: + self._stubs['delete_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateAuthority', + request_serializer=service.DeleteCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_certificate_authority'] + + @property + def update_certificate_authority(self) -> Callable[ + [service.UpdateCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update certificate authority method over gRPC. + + Update a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Returns: + Callable[[~.UpdateCertificateAuthorityRequest], + 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_authority' not in self._stubs: + self._stubs['update_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateAuthority', + request_serializer=service.UpdateCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_authority'] + + @property + def create_ca_pool(self) -> Callable[ + [service.CreateCaPoolRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create ca pool method over gRPC. + + Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.CreateCaPoolRequest], + 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_ca_pool' not in self._stubs: + self._stubs['create_ca_pool'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCaPool', + request_serializer=service.CreateCaPoolRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_ca_pool'] + + @property + def update_ca_pool(self) -> Callable[ + [service.UpdateCaPoolRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update ca pool method over gRPC. + + Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.UpdateCaPoolRequest], + 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_ca_pool' not in self._stubs: + self._stubs['update_ca_pool'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCaPool', + request_serializer=service.UpdateCaPoolRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_ca_pool'] + + @property + def get_ca_pool(self) -> Callable[ + [service.GetCaPoolRequest], + Awaitable[resources.CaPool]]: + r"""Return a callable for the get ca pool method over gRPC. + + Returns a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.GetCaPoolRequest], + Awaitable[~.CaPool]]: + 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_ca_pool' not in self._stubs: + self._stubs['get_ca_pool'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCaPool', + request_serializer=service.GetCaPoolRequest.serialize, + response_deserializer=resources.CaPool.deserialize, + ) + return self._stubs['get_ca_pool'] + + @property + def list_ca_pools(self) -> Callable[ + [service.ListCaPoolsRequest], + Awaitable[service.ListCaPoolsResponse]]: + r"""Return a callable for the list ca pools method over gRPC. + + Lists [CaPools][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.ListCaPoolsRequest], + Awaitable[~.ListCaPoolsResponse]]: + 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_ca_pools' not in self._stubs: + self._stubs['list_ca_pools'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCaPools', + request_serializer=service.ListCaPoolsRequest.serialize, + response_deserializer=service.ListCaPoolsResponse.deserialize, + ) + return self._stubs['list_ca_pools'] + + @property + def delete_ca_pool(self) -> Callable[ + [service.DeleteCaPoolRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete ca pool method over gRPC. + + Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.DeleteCaPoolRequest], + 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_ca_pool' not in self._stubs: + self._stubs['delete_ca_pool'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCaPool', + request_serializer=service.DeleteCaPoolRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_ca_pool'] + + @property + def fetch_ca_certs(self) -> Callable[ + [service.FetchCaCertsRequest], + Awaitable[service.FetchCaCertsResponse]]: + r"""Return a callable for the fetch ca certs method over gRPC. + + FetchCaCerts returns the current trust anchor for the + [CaPool][google.cloud.security.privateca.v1.CaPool]. This will + include CA certificate chains for all ACTIVE + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources in the + [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Returns: + Callable[[~.FetchCaCertsRequest], + Awaitable[~.FetchCaCertsResponse]]: + 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 'fetch_ca_certs' not in self._stubs: + self._stubs['fetch_ca_certs'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/FetchCaCerts', + request_serializer=service.FetchCaCertsRequest.serialize, + response_deserializer=service.FetchCaCertsResponse.deserialize, + ) + return self._stubs['fetch_ca_certs'] + + @property + def get_certificate_revocation_list(self) -> Callable[ + [service.GetCertificateRevocationListRequest], + Awaitable[resources.CertificateRevocationList]]: + r"""Return a callable for the get certificate revocation + list method over gRPC. + + Returns a + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. + + Returns: + Callable[[~.GetCertificateRevocationListRequest], + Awaitable[~.CertificateRevocationList]]: + 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_revocation_list' not in self._stubs: + self._stubs['get_certificate_revocation_list'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateRevocationList', + request_serializer=service.GetCertificateRevocationListRequest.serialize, + response_deserializer=resources.CertificateRevocationList.deserialize, + ) + return self._stubs['get_certificate_revocation_list'] + + @property + def list_certificate_revocation_lists(self) -> Callable[ + [service.ListCertificateRevocationListsRequest], + Awaitable[service.ListCertificateRevocationListsResponse]]: + r"""Return a callable for the list certificate revocation + lists method over gRPC. + + Lists + [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. + + Returns: + Callable[[~.ListCertificateRevocationListsRequest], + Awaitable[~.ListCertificateRevocationListsResponse]]: + 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_revocation_lists' not in self._stubs: + self._stubs['list_certificate_revocation_lists'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateRevocationLists', + request_serializer=service.ListCertificateRevocationListsRequest.serialize, + response_deserializer=service.ListCertificateRevocationListsResponse.deserialize, + ) + return self._stubs['list_certificate_revocation_lists'] + + @property + def update_certificate_revocation_list(self) -> Callable[ + [service.UpdateCertificateRevocationListRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update certificate revocation + list method over gRPC. + + Update a + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. + + Returns: + Callable[[~.UpdateCertificateRevocationListRequest], + 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_revocation_list' not in self._stubs: + self._stubs['update_certificate_revocation_list'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateRevocationList', + request_serializer=service.UpdateCertificateRevocationListRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_revocation_list'] + + @property + def create_certificate_template(self) -> Callable[ + [service.CreateCertificateTemplateRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create certificate template method over gRPC. + + Create a new + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + in a given Project and Location. + + Returns: + Callable[[~.CreateCertificateTemplateRequest], + 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_template' not in self._stubs: + self._stubs['create_certificate_template'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateTemplate', + request_serializer=service.CreateCertificateTemplateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate_template'] + + @property + def delete_certificate_template(self) -> Callable[ + [service.DeleteCertificateTemplateRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete certificate template method over gRPC. + + DeleteCertificateTemplate deletes a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + + Returns: + Callable[[~.DeleteCertificateTemplateRequest], + 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_template' not in self._stubs: + self._stubs['delete_certificate_template'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateTemplate', + request_serializer=service.DeleteCertificateTemplateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_certificate_template'] + + @property + def get_certificate_template(self) -> Callable[ + [service.GetCertificateTemplateRequest], + Awaitable[resources.CertificateTemplate]]: + r"""Return a callable for the get certificate template method over gRPC. + + Returns a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + + Returns: + Callable[[~.GetCertificateTemplateRequest], + Awaitable[~.CertificateTemplate]]: + 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_template' not in self._stubs: + self._stubs['get_certificate_template'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateTemplate', + request_serializer=service.GetCertificateTemplateRequest.serialize, + response_deserializer=resources.CertificateTemplate.deserialize, + ) + return self._stubs['get_certificate_template'] + + @property + def list_certificate_templates(self) -> Callable[ + [service.ListCertificateTemplatesRequest], + Awaitable[service.ListCertificateTemplatesResponse]]: + r"""Return a callable for the list certificate templates method over gRPC. + + Lists + [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. + + Returns: + Callable[[~.ListCertificateTemplatesRequest], + Awaitable[~.ListCertificateTemplatesResponse]]: + 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_templates' not in self._stubs: + self._stubs['list_certificate_templates'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateTemplates', + request_serializer=service.ListCertificateTemplatesRequest.serialize, + response_deserializer=service.ListCertificateTemplatesResponse.deserialize, + ) + return self._stubs['list_certificate_templates'] + + @property + def update_certificate_template(self) -> Callable[ + [service.UpdateCertificateTemplateRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update certificate template method over gRPC. + + Update a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + + Returns: + Callable[[~.UpdateCertificateTemplateRequest], + 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_template' not in self._stubs: + self._stubs['update_certificate_template'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateTemplate', + request_serializer=service.UpdateCertificateTemplateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_template'] + + +__all__ = ( + 'CertificateAuthorityServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/__init__.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/__init__.py new file mode 100644 index 0000000..1865e5a --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/__init__.py @@ -0,0 +1,134 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 .resources import ( + CaPool, + Certificate, + CertificateAuthority, + CertificateConfig, + CertificateDescription, + CertificateExtensionConstraints, + CertificateIdentityConstraints, + CertificateRevocationList, + CertificateTemplate, + KeyUsage, + ObjectId, + PublicKey, + Subject, + SubjectAltNames, + SubordinateConfig, + X509Extension, + X509Parameters, + RevocationReason, + SubjectRequestMode, +) +from .service import ( + ActivateCertificateAuthorityRequest, + CreateCaPoolRequest, + CreateCertificateAuthorityRequest, + CreateCertificateRequest, + CreateCertificateTemplateRequest, + DeleteCaPoolRequest, + DeleteCertificateAuthorityRequest, + DeleteCertificateTemplateRequest, + DisableCertificateAuthorityRequest, + EnableCertificateAuthorityRequest, + FetchCaCertsRequest, + FetchCaCertsResponse, + FetchCertificateAuthorityCsrRequest, + FetchCertificateAuthorityCsrResponse, + GetCaPoolRequest, + GetCertificateAuthorityRequest, + GetCertificateRequest, + GetCertificateRevocationListRequest, + GetCertificateTemplateRequest, + ListCaPoolsRequest, + ListCaPoolsResponse, + ListCertificateAuthoritiesRequest, + ListCertificateAuthoritiesResponse, + ListCertificateRevocationListsRequest, + ListCertificateRevocationListsResponse, + ListCertificatesRequest, + ListCertificatesResponse, + ListCertificateTemplatesRequest, + ListCertificateTemplatesResponse, + OperationMetadata, + RevokeCertificateRequest, + UndeleteCertificateAuthorityRequest, + UpdateCaPoolRequest, + UpdateCertificateAuthorityRequest, + UpdateCertificateRequest, + UpdateCertificateRevocationListRequest, + UpdateCertificateTemplateRequest, +) + +__all__ = ( + 'CaPool', + 'Certificate', + 'CertificateAuthority', + 'CertificateConfig', + 'CertificateDescription', + 'CertificateExtensionConstraints', + 'CertificateIdentityConstraints', + 'CertificateRevocationList', + 'CertificateTemplate', + 'KeyUsage', + 'ObjectId', + 'PublicKey', + 'Subject', + 'SubjectAltNames', + 'SubordinateConfig', + 'X509Extension', + 'X509Parameters', + 'RevocationReason', + 'SubjectRequestMode', + 'ActivateCertificateAuthorityRequest', + 'CreateCaPoolRequest', + 'CreateCertificateAuthorityRequest', + 'CreateCertificateRequest', + 'CreateCertificateTemplateRequest', + 'DeleteCaPoolRequest', + 'DeleteCertificateAuthorityRequest', + 'DeleteCertificateTemplateRequest', + 'DisableCertificateAuthorityRequest', + 'EnableCertificateAuthorityRequest', + 'FetchCaCertsRequest', + 'FetchCaCertsResponse', + 'FetchCertificateAuthorityCsrRequest', + 'FetchCertificateAuthorityCsrResponse', + 'GetCaPoolRequest', + 'GetCertificateAuthorityRequest', + 'GetCertificateRequest', + 'GetCertificateRevocationListRequest', + 'GetCertificateTemplateRequest', + 'ListCaPoolsRequest', + 'ListCaPoolsResponse', + 'ListCertificateAuthoritiesRequest', + 'ListCertificateAuthoritiesResponse', + 'ListCertificateRevocationListsRequest', + 'ListCertificateRevocationListsResponse', + 'ListCertificatesRequest', + 'ListCertificatesResponse', + 'ListCertificateTemplatesRequest', + 'ListCertificateTemplatesResponse', + 'OperationMetadata', + 'RevokeCertificateRequest', + 'UndeleteCertificateAuthorityRequest', + 'UpdateCaPoolRequest', + 'UpdateCertificateAuthorityRequest', + 'UpdateCertificateRequest', + 'UpdateCertificateRevocationListRequest', + 'UpdateCertificateTemplateRequest', +) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/resources.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/resources.py new file mode 100644 index 0000000..85ea3dc --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/resources.py @@ -0,0 +1,1896 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import proto # type: ignore + +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import expr_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.security.privateca.v1', + manifest={ + 'RevocationReason', + 'SubjectRequestMode', + 'CertificateAuthority', + 'CaPool', + 'CertificateRevocationList', + 'Certificate', + 'CertificateTemplate', + 'X509Parameters', + 'SubordinateConfig', + 'PublicKey', + 'CertificateConfig', + 'CertificateDescription', + 'ObjectId', + 'X509Extension', + 'KeyUsage', + 'Subject', + 'SubjectAltNames', + 'CertificateIdentityConstraints', + 'CertificateExtensionConstraints', + }, +) + + +class RevocationReason(proto.Enum): + r"""A + [RevocationReason][google.cloud.security.privateca.v1.RevocationReason] + indicates whether a + [Certificate][google.cloud.security.privateca.v1.Certificate] has + been revoked, and the reason for revocation. These correspond to + standard revocation reasons from RFC 5280. Note that the enum labels + and values in this definition are not the same ASN.1 values defined + in RFC 5280. These values will be translated to the correct ASN.1 + values when a CRL is created. + """ + REVOCATION_REASON_UNSPECIFIED = 0 + KEY_COMPROMISE = 1 + CERTIFICATE_AUTHORITY_COMPROMISE = 2 + AFFILIATION_CHANGED = 3 + SUPERSEDED = 4 + CESSATION_OF_OPERATION = 5 + CERTIFICATE_HOLD = 6 + PRIVILEGE_WITHDRAWN = 7 + ATTRIBUTE_AUTHORITY_COMPROMISE = 8 + + +class SubjectRequestMode(proto.Enum): + r"""Describes the way in which a + [Certificate][google.cloud.security.privateca.v1.Certificate]'s + [Subject][google.cloud.security.privateca.v1.Subject] and/or + [SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames] + will be resolved. + """ + SUBJECT_REQUEST_MODE_UNSPECIFIED = 0 + DEFAULT = 1 + REFLECTED_SPIFFE = 2 + + +class CertificateAuthority(proto.Message): + r"""A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + represents an individual Certificate Authority. A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1.Certificate]. + + Attributes: + name (str): + Output only. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + type_ (google.cloud.security.privateca_v1.types.CertificateAuthority.Type): + Required. Immutable. The + [Type][google.cloud.security.privateca.v1.CertificateAuthority.Type] + of this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + config (google.cloud.security.privateca_v1.types.CertificateConfig): + Required. Immutable. The config used to + create a self-signed X.509 certificate or CSR. + lifetime (google.protobuf.duration_pb2.Duration): + Required. The desired lifetime of the CA certificate. Used + to create the "not_before_time" and "not_after_time" fields + inside an X.509 certificate. + key_spec (google.cloud.security.privateca_v1.types.CertificateAuthority.KeyVersionSpec): + Required. Immutable. Used when issuing certificates for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + If this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + is a self-signed CertificateAuthority, this key is also used + to sign the self-signed CA certificate. Otherwise, it is + used to sign a CSR. + subordinate_config (google.cloud.security.privateca_v1.types.SubordinateConfig): + Optional. If this is a subordinate + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority], + this field will be set with the subordinate configuration, + which describes its issuers. This may be updated, but this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + must continue to validate. + tier (google.cloud.security.privateca_v1.types.CaPool.Tier): + Output only. The + [CaPool.Tier][google.cloud.security.privateca.v1.CaPool.Tier] + of the [CaPool][google.cloud.security.privateca.v1.CaPool] + that includes this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + state (google.cloud.security.privateca_v1.types.CertificateAuthority.State): + Output only. The + [State][google.cloud.security.privateca.v1.CertificateAuthority.State] + for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + pem_ca_certificates (Sequence[str]): + Output only. This + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s + certificate chain, including the current + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s + certificate. Ordered such that the root issuer is the final + element (consistent with RFC 5246). For a self-signed CA, + this will only list the current + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s + certificate. + ca_certificate_descriptions (Sequence[google.cloud.security.privateca_v1.types.CertificateDescription]): + Output only. A structured description of this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s + CA certificate and its issuers. Ordered as self-to-root. + gcs_bucket (str): + Immutable. The name of a Cloud Storage bucket where this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + will publish content, such as the CA certificate and CRLs. + This must be a bucket name, without any prefixes (such as + ``gs://``) or suffixes (such as ``.googleapis.com``). For + example, to use a bucket named ``my-bucket``, you would + simply specify ``my-bucket``. If not specified, a managed + bucket will be created. + access_urls (google.cloud.security.privateca_v1.types.CertificateAuthority.AccessUrls): + Output only. URLs for accessing content + published by this CA, such as the CA certificate + and CRLs. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + was last updated. + delete_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + was soft deleted, if it is in the + [DELETED][google.cloud.security.privateca.v1.CertificateAuthority.State.DELETED] + state. + expire_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + will be permanently purged, if it is in the + [DELETED][google.cloud.security.privateca.v1.CertificateAuthority.State.DELETED] + state. + labels (Sequence[google.cloud.security.privateca_v1.types.CertificateAuthority.LabelsEntry]): + Optional. Labels with user-defined metadata. + """ + class Type(proto.Enum): + r"""The type of a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority], + indicating its issuing chain. + """ + TYPE_UNSPECIFIED = 0 + SELF_SIGNED = 1 + SUBORDINATE = 2 + + class State(proto.Enum): + r"""The state of a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority], + indicating if it can be used. + """ + STATE_UNSPECIFIED = 0 + ENABLED = 1 + DISABLED = 2 + STAGED = 3 + AWAITING_USER_ACTIVATION = 4 + DELETED = 5 + + class SignHashAlgorithm(proto.Enum): + r"""The algorithm of a Cloud KMS CryptoKeyVersion of a + [CryptoKey][google.cloud.kms.v1.CryptoKey] with the + [CryptoKeyPurpose][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose] + value ``ASYMMETRIC_SIGN``. These values correspond to the + [CryptoKeyVersionAlgorithm][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionAlgorithm] + values. For RSA signing algorithms, the PSS algorithms should be + preferred, use PKCS1 algorithms if required for compatibility. For + further recommandations, see + https://cloud.google.com/kms/docs/algorithms#algorithm_recommendations. + """ + SIGN_HASH_ALGORITHM_UNSPECIFIED = 0 + RSA_PSS_2048_SHA256 = 1 + RSA_PSS_3072_SHA256 = 2 + RSA_PSS_4096_SHA256 = 3 + RSA_PKCS1_2048_SHA256 = 6 + RSA_PKCS1_3072_SHA256 = 7 + RSA_PKCS1_4096_SHA256 = 8 + EC_P256_SHA256 = 4 + EC_P384_SHA384 = 5 + + class AccessUrls(proto.Message): + r"""URLs where a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + will publish content. + + Attributes: + ca_certificate_access_url (str): + The URL where this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s + CA certificate is published. This will only be set for CAs + that have been activated. + crl_access_urls (Sequence[str]): + The URLs where this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s + CRLs are published. This will only be set for CAs that have + been activated. + """ + + ca_certificate_access_url = proto.Field( + proto.STRING, + number=1, + ) + crl_access_urls = proto.RepeatedField( + proto.STRING, + number=2, + ) + + class KeyVersionSpec(proto.Message): + r"""A Cloud KMS key configuration that a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + will use. + + Attributes: + cloud_kms_key_version (str): + The resource name for an existing Cloud KMS CryptoKeyVersion + in the format + ``projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*``. + This option enables full flexibility in the key's + capabilities and properties. + algorithm (google.cloud.security.privateca_v1.types.CertificateAuthority.SignHashAlgorithm): + The algorithm to use for creating a managed Cloud KMS key + for a for a simplified experience. All managed keys will be + have their + [ProtectionLevel][google.cloud.kms.v1.ProtectionLevel] as + ``HSM``. + """ + + cloud_kms_key_version = proto.Field( + proto.STRING, + number=1, + oneof='KeyVersion', + ) + algorithm = proto.Field( + proto.ENUM, + number=2, + oneof='KeyVersion', + enum='CertificateAuthority.SignHashAlgorithm', + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + type_ = proto.Field( + proto.ENUM, + number=2, + enum=Type, + ) + config = proto.Field( + proto.MESSAGE, + number=3, + message='CertificateConfig', + ) + lifetime = proto.Field( + proto.MESSAGE, + number=4, + message=duration_pb2.Duration, + ) + key_spec = proto.Field( + proto.MESSAGE, + number=5, + message=KeyVersionSpec, + ) + subordinate_config = proto.Field( + proto.MESSAGE, + number=6, + message='SubordinateConfig', + ) + tier = proto.Field( + proto.ENUM, + number=7, + enum='CaPool.Tier', + ) + state = proto.Field( + proto.ENUM, + number=8, + enum=State, + ) + pem_ca_certificates = proto.RepeatedField( + proto.STRING, + number=9, + ) + ca_certificate_descriptions = proto.RepeatedField( + proto.MESSAGE, + number=10, + message='CertificateDescription', + ) + gcs_bucket = proto.Field( + proto.STRING, + number=11, + ) + access_urls = proto.Field( + proto.MESSAGE, + number=12, + message=AccessUrls, + ) + create_time = proto.Field( + proto.MESSAGE, + number=13, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=14, + message=timestamp_pb2.Timestamp, + ) + delete_time = proto.Field( + proto.MESSAGE, + number=15, + message=timestamp_pb2.Timestamp, + ) + expire_time = proto.Field( + proto.MESSAGE, + number=16, + message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=17, + ) + + +class CaPool(proto.Message): + r"""A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a + group of + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] + that form a trust anchor. A + [CaPool][google.cloud.security.privateca.v1.CaPool] can be used to + manage issuance policies for one or more + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources and to rotate CA certificates in and out of the trust + anchor. + + Attributes: + name (str): + Output only. The resource name for this + [CaPool][google.cloud.security.privateca.v1.CaPool] in the + format ``projects/*/locations/*/caPools/*``. + tier (google.cloud.security.privateca_v1.types.CaPool.Tier): + Required. Immutable. The + [Tier][google.cloud.security.privateca.v1.CaPool.Tier] of + this [CaPool][google.cloud.security.privateca.v1.CaPool]. + issuance_policy (google.cloud.security.privateca_v1.types.CaPool.IssuancePolicy): + Optional. The + [IssuancePolicy][google.cloud.security.privateca.v1.CaPool.IssuancePolicy] + to control how + [Certificates][google.cloud.security.privateca.v1.Certificate] + will be issued from this + [CaPool][google.cloud.security.privateca.v1.CaPool]. + publishing_options (google.cloud.security.privateca_v1.types.CaPool.PublishingOptions): + Optional. The + [PublishingOptions][google.cloud.security.privateca.v1.CaPool.PublishingOptions] + to follow when issuing + [Certificates][google.cloud.security.privateca.v1.Certificate] + from any + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in this [CaPool][google.cloud.security.privateca.v1.CaPool]. + labels (Sequence[google.cloud.security.privateca_v1.types.CaPool.LabelsEntry]): + Optional. Labels with user-defined metadata. + """ + class Tier(proto.Enum): + r"""The tier of a [CaPool][google.cloud.security.privateca.v1.CaPool], + indicating its supported functionality and/or billing SKU. + """ + TIER_UNSPECIFIED = 0 + ENTERPRISE = 1 + DEVOPS = 2 + + class PublishingOptions(proto.Message): + r"""Options relating to the publication of each + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s + CA certificate and CRLs and their inclusion as extensions in issued + [Certificates][google.cloud.security.privateca.v1.Certificate]. The + options set here apply to certificates issued by any + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Attributes: + publish_ca_cert (bool): + Required. When true, publishes each + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s + CA certificate and includes its URL in the "Authority + Information Access" X.509 extension in all issued + [Certificates][google.cloud.security.privateca.v1.Certificate]. + If this is false, the CA certificate will not be published + and the corresponding X.509 extension will not be written in + issued certificates. + publish_crl (bool): + Required. When true, publishes each + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s + CRL and includes its URL in the "CRL Distribution Points" + X.509 extension in all issued + [Certificates][google.cloud.security.privateca.v1.Certificate]. + If this is false, CRLs will not be published and the + corresponding X.509 extension will not be written in issued + certificates. CRLs will expire 7 days from their creation. + However, we will rebuild daily. CRLs are also rebuilt + shortly after a certificate is revoked. + """ + + publish_ca_cert = proto.Field( + proto.BOOL, + number=1, + ) + publish_crl = proto.Field( + proto.BOOL, + number=2, + ) + + class IssuancePolicy(proto.Message): + r"""Defines controls over all certificate issuance within a + [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Attributes: + allowed_key_types (Sequence[google.cloud.security.privateca_v1.types.CaPool.IssuancePolicy.AllowedKeyType]): + Optional. If any + [AllowedKeyType][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.AllowedKeyType] + is specified, then the certificate request's public key must + match one of the key types listed here. Otherwise, any key + may be used. + maximum_lifetime (google.protobuf.duration_pb2.Duration): + Optional. The maximum lifetime allowed for issued + [Certificates][google.cloud.security.privateca.v1.Certificate]. + Note that if the issuing + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + expires before a + [Certificate][google.cloud.security.privateca.v1.Certificate]'s + requested maximum_lifetime, the effective lifetime will be + explicitly truncated to match it. + allowed_issuance_modes (google.cloud.security.privateca_v1.types.CaPool.IssuancePolicy.IssuanceModes): + Optional. If specified, then only methods allowed in the + [IssuanceModes][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.IssuanceModes] + may be used to issue + [Certificates][google.cloud.security.privateca.v1.Certificate]. + baseline_values (google.cloud.security.privateca_v1.types.X509Parameters): + Optional. A set of X.509 values that will be applied to all + certificates issued through this + [CaPool][google.cloud.security.privateca.v1.CaPool]. If a + certificate request includes conflicting values for the same + properties, they will be overwritten by the values defined + here. If a certificate request uses a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + that defines conflicting + [predefined_values][google.cloud.security.privateca.v1.CertificateTemplate.predefined_values] + for the same properties, the certificate issuance request + will fail. + identity_constraints (google.cloud.security.privateca_v1.types.CertificateIdentityConstraints): + Optional. Describes constraints on identities that may + appear in + [Certificates][google.cloud.security.privateca.v1.Certificate] + issued through this + [CaPool][google.cloud.security.privateca.v1.CaPool]. If this + is omitted, then this + [CaPool][google.cloud.security.privateca.v1.CaPool] will not + add restrictions on a certificate's identity. + passthrough_extensions (google.cloud.security.privateca_v1.types.CertificateExtensionConstraints): + Optional. Describes the set of X.509 extensions that may + appear in a + [Certificate][google.cloud.security.privateca.v1.Certificate] + issued through this + [CaPool][google.cloud.security.privateca.v1.CaPool]. If a + certificate request sets extensions that don't appear in the + [passthrough_extensions][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.passthrough_extensions], + those extensions will be dropped. If a certificate request + uses a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + with + [predefined_values][google.cloud.security.privateca.v1.CertificateTemplate.predefined_values] + that don't appear here, the certificate issuance request + will fail. If this is omitted, then this + [CaPool][google.cloud.security.privateca.v1.CaPool] will not + add restrictions on a certificate's X.509 extensions. These + constraints do not apply to X.509 extensions set in this + [CaPool][google.cloud.security.privateca.v1.CaPool]'s + [baseline_values][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.baseline_values]. + """ + + class AllowedKeyType(proto.Message): + r"""Describes a "type" of key that may be used in a + [Certificate][google.cloud.security.privateca.v1.Certificate] issued + from a [CaPool][google.cloud.security.privateca.v1.CaPool]. Note + that a single + [AllowedKeyType][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.AllowedKeyType] + may refer to either a fully-qualified key algorithm, such as RSA + 4096, or a family of key algorithms, such as any RSA key. + + Attributes: + rsa (google.cloud.security.privateca_v1.types.CaPool.IssuancePolicy.AllowedKeyType.RsaKeyType): + Represents an allowed RSA key type. + elliptic_curve (google.cloud.security.privateca_v1.types.CaPool.IssuancePolicy.AllowedKeyType.EcKeyType): + Represents an allowed Elliptic Curve key + type. + """ + + class RsaKeyType(proto.Message): + r"""Describes an RSA key that may be used in a + [Certificate][google.cloud.security.privateca.v1.Certificate] issued + from a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Attributes: + min_modulus_size (int): + Optional. The minimum allowed RSA modulus + size, in bits. If this is not set, or if set to + zero, the service-level min RSA modulus size + will continue to apply. + max_modulus_size (int): + Optional. The maximum allowed RSA modulus + size, in bits. If this is not set, or if set to + zero, the service will not enforce an explicit + upper bound on RSA modulus sizes. + """ + + min_modulus_size = proto.Field( + proto.INT64, + number=1, + ) + max_modulus_size = proto.Field( + proto.INT64, + number=2, + ) + + class EcKeyType(proto.Message): + r"""Describes an Elliptic Curve key that may be used in a + [Certificate][google.cloud.security.privateca.v1.Certificate] issued + from a [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Attributes: + signature_algorithm (google.cloud.security.privateca_v1.types.CaPool.IssuancePolicy.AllowedKeyType.EcKeyType.EcSignatureAlgorithm): + Optional. A signature algorithm that must be + used. If this is omitted, any EC-based signature + algorithm will be allowed. + """ + class EcSignatureAlgorithm(proto.Enum): + r"""Describes an elliptic curve-based signature algorithm that may be + used in a + [Certificate][google.cloud.security.privateca.v1.Certificate] issued + from a [CaPool][google.cloud.security.privateca.v1.CaPool]. + """ + EC_SIGNATURE_ALGORITHM_UNSPECIFIED = 0 + ECDSA_P256 = 1 + ECDSA_P384 = 2 + EDDSA_25519 = 3 + + signature_algorithm = proto.Field( + proto.ENUM, + number=1, + enum='CaPool.IssuancePolicy.AllowedKeyType.EcKeyType.EcSignatureAlgorithm', + ) + + rsa = proto.Field( + proto.MESSAGE, + number=1, + oneof='key_type', + message='CaPool.IssuancePolicy.AllowedKeyType.RsaKeyType', + ) + elliptic_curve = proto.Field( + proto.MESSAGE, + number=2, + oneof='key_type', + message='CaPool.IssuancePolicy.AllowedKeyType.EcKeyType', + ) + + class IssuanceModes(proto.Message): + r"""[IssuanceModes][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.IssuanceModes] + specifies the allowed ways in which + [Certificates][google.cloud.security.privateca.v1.Certificate] may + be requested from this + [CaPool][google.cloud.security.privateca.v1.CaPool]. + + Attributes: + allow_csr_based_issuance (bool): + Required. When true, allows callers to create + [Certificates][google.cloud.security.privateca.v1.Certificate] + by specifying a CSR. + allow_config_based_issuance (bool): + Required. When true, allows callers to create + [Certificates][google.cloud.security.privateca.v1.Certificate] + by specifying a + [CertificateConfig][google.cloud.security.privateca.v1.CertificateConfig]. + """ + + allow_csr_based_issuance = proto.Field( + proto.BOOL, + number=1, + ) + allow_config_based_issuance = proto.Field( + proto.BOOL, + number=2, + ) + + allowed_key_types = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='CaPool.IssuancePolicy.AllowedKeyType', + ) + maximum_lifetime = proto.Field( + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, + ) + allowed_issuance_modes = proto.Field( + proto.MESSAGE, + number=3, + message='CaPool.IssuancePolicy.IssuanceModes', + ) + baseline_values = proto.Field( + proto.MESSAGE, + number=4, + message='X509Parameters', + ) + identity_constraints = proto.Field( + proto.MESSAGE, + number=5, + message='CertificateIdentityConstraints', + ) + passthrough_extensions = proto.Field( + proto.MESSAGE, + number=6, + message='CertificateExtensionConstraints', + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + tier = proto.Field( + proto.ENUM, + number=2, + enum=Tier, + ) + issuance_policy = proto.Field( + proto.MESSAGE, + number=3, + message=IssuancePolicy, + ) + publishing_options = proto.Field( + proto.MESSAGE, + number=4, + message=PublishingOptions, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=5, + ) + + +class CertificateRevocationList(proto.Message): + r"""A + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] + corresponds to a signed X.509 certificate Revocation List (CRL). A + CRL contains the serial numbers of certificates that should no + longer be trusted. + + Attributes: + name (str): + Output only. The resource name for this + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] + in the format + ``projects/*/locations/*/caPools/*certificateAuthorities/*/ certificateRevocationLists/*``. + sequence_number (int): + Output only. The CRL sequence number that appears in + pem_crl. + revoked_certificates (Sequence[google.cloud.security.privateca_v1.types.CertificateRevocationList.RevokedCertificate]): + Output only. The revoked serial numbers that appear in + pem_crl. + pem_crl (str): + Output only. The PEM-encoded X.509 CRL. + access_url (str): + Output only. The location where 'pem_crl' can be accessed. + state (google.cloud.security.privateca_v1.types.CertificateRevocationList.State): + Output only. The + [State][google.cloud.security.privateca.v1.CertificateRevocationList.State] + for this + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] + was updated. + revision_id (str): + Output only. The revision ID of this + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. + A new revision is committed whenever a new CRL is published. + The format is an 8-character hexadecimal string. + labels (Sequence[google.cloud.security.privateca_v1.types.CertificateRevocationList.LabelsEntry]): + Optional. Labels with user-defined metadata. + """ + class State(proto.Enum): + r"""The state of a + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList], + indicating if it is current. + """ + STATE_UNSPECIFIED = 0 + ACTIVE = 1 + SUPERSEDED = 2 + + class RevokedCertificate(proto.Message): + r"""Describes a revoked + [Certificate][google.cloud.security.privateca.v1.Certificate]. + + Attributes: + certificate (str): + The resource name for the + [Certificate][google.cloud.security.privateca.v1.Certificate] + in the format + ``projects/*/locations/*/caPools/*/certificates/*``. + hex_serial_number (str): + The serial number of the + [Certificate][google.cloud.security.privateca.v1.Certificate]. + revocation_reason (google.cloud.security.privateca_v1.types.RevocationReason): + The reason the + [Certificate][google.cloud.security.privateca.v1.Certificate] + was revoked. + """ + + certificate = proto.Field( + proto.STRING, + number=1, + ) + hex_serial_number = proto.Field( + proto.STRING, + number=2, + ) + revocation_reason = proto.Field( + proto.ENUM, + number=3, + enum='RevocationReason', + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + sequence_number = proto.Field( + proto.INT64, + number=2, + ) + revoked_certificates = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=RevokedCertificate, + ) + pem_crl = proto.Field( + proto.STRING, + number=4, + ) + access_url = proto.Field( + proto.STRING, + number=5, + ) + state = proto.Field( + proto.ENUM, + number=6, + enum=State, + ) + create_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + revision_id = proto.Field( + proto.STRING, + number=9, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=10, + ) + + +class Certificate(proto.Message): + r"""A [Certificate][google.cloud.security.privateca.v1.Certificate] + corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + + Attributes: + name (str): + Output only. The resource name for this + [Certificate][google.cloud.security.privateca.v1.Certificate] + in the format + ``projects/*/locations/*/caPools/*/certificates/*``. + pem_csr (str): + Immutable. A pem-encoded X.509 certificate + signing request (CSR). + config (google.cloud.security.privateca_v1.types.CertificateConfig): + Immutable. A description of the certificate + and key that does not require X.509 or ASN.1. + issuer_certificate_authority (str): + Output only. The resource name of the issuing + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + lifetime (google.protobuf.duration_pb2.Duration): + Required. Immutable. The desired lifetime of a certificate. + Used to create the "not_before_time" and "not_after_time" + fields inside an X.509 certificate. Note that the lifetime + may be truncated if it would extend past the life of any + certificate authority in the issuing chain. + certificate_template (str): + Immutable. The resource name for a + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + used to issue this certificate, in the format + ``projects/*/locations/*/certificateTemplates/*``. If this + is specified, the caller must have the necessary permission + to use this template. If this is omitted, no template will + be used. This template must be in the same location as the + [Certificate][google.cloud.security.privateca.v1.Certificate]. + subject_mode (google.cloud.security.privateca_v1.types.SubjectRequestMode): + Immutable. Specifies how the + [Certificate][google.cloud.security.privateca.v1.Certificate]'s + identity fields are to be decided. If this is omitted, the + ``DEFAULT`` subject mode will be used. + revocation_details (google.cloud.security.privateca_v1.types.Certificate.RevocationDetails): + Output only. Details regarding the revocation of this + [Certificate][google.cloud.security.privateca.v1.Certificate]. + This + [Certificate][google.cloud.security.privateca.v1.Certificate] + is considered revoked if and only if this field is present. + pem_certificate (str): + Output only. The pem-encoded, signed X.509 + certificate. + certificate_description (google.cloud.security.privateca_v1.types.CertificateDescription): + Output only. A structured description of the + issued X.509 certificate. + pem_certificate_chain (Sequence[str]): + Output only. The chain that may be used to + verify the X.509 certificate. Expected to be in + issuer-to-root order according to RFC 5246. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [Certificate][google.cloud.security.privateca.v1.Certificate] + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [Certificate][google.cloud.security.privateca.v1.Certificate] + was updated. + labels (Sequence[google.cloud.security.privateca_v1.types.Certificate.LabelsEntry]): + Optional. Labels with user-defined metadata. + """ + + class RevocationDetails(proto.Message): + r"""Describes fields that are relavent to the revocation of a + [Certificate][google.cloud.security.privateca.v1.Certificate]. + + Attributes: + revocation_state (google.cloud.security.privateca_v1.types.RevocationReason): + Indicates why a + [Certificate][google.cloud.security.privateca.v1.Certificate] + was revoked. + revocation_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which this + [Certificate][google.cloud.security.privateca.v1.Certificate] + was revoked. + """ + + revocation_state = proto.Field( + proto.ENUM, + number=1, + enum='RevocationReason', + ) + revocation_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + pem_csr = proto.Field( + proto.STRING, + number=2, + oneof='certificate_config', + ) + config = proto.Field( + proto.MESSAGE, + number=3, + oneof='certificate_config', + message='CertificateConfig', + ) + issuer_certificate_authority = proto.Field( + proto.STRING, + number=4, + ) + lifetime = proto.Field( + proto.MESSAGE, + number=5, + message=duration_pb2.Duration, + ) + certificate_template = proto.Field( + proto.STRING, + number=6, + ) + subject_mode = proto.Field( + proto.ENUM, + number=7, + enum='SubjectRequestMode', + ) + revocation_details = proto.Field( + proto.MESSAGE, + number=8, + message=RevocationDetails, + ) + pem_certificate = proto.Field( + proto.STRING, + number=9, + ) + certificate_description = proto.Field( + proto.MESSAGE, + number=10, + message='CertificateDescription', + ) + pem_certificate_chain = proto.RepeatedField( + proto.STRING, + number=11, + ) + create_time = proto.Field( + proto.MESSAGE, + number=12, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=13, + message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=14, + ) + + +class CertificateTemplate(proto.Message): + r"""A + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + refers to a managed template for certificate issuance. + + Attributes: + name (str): + Output only. The resource name for this + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + in the format + ``projects/*/locations/*/certificateTemplates/*``. + predefined_values (google.cloud.security.privateca_v1.types.X509Parameters): + Optional. A set of X.509 values that will be applied to all + issued certificates that use this template. If the + certificate request includes conflicting values for the same + properties, they will be overwritten by the values defined + here. If the issuing + [CaPool][google.cloud.security.privateca.v1.CaPool]'s + [IssuancePolicy][google.cloud.security.privateca.v1.CaPool.IssuancePolicy] + defines conflicting + [baseline_values][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.baseline_values] + for the same properties, the certificate issuance request + will fail. + identity_constraints (google.cloud.security.privateca_v1.types.CertificateIdentityConstraints): + Optional. Describes constraints on identities that may be + appear in + [Certificates][google.cloud.security.privateca.v1.Certificate] + issued using this template. If this is omitted, then this + template will not add restrictions on a certificate's + identity. + passthrough_extensions (google.cloud.security.privateca_v1.types.CertificateExtensionConstraints): + Optional. Describes the set of X.509 extensions that may + appear in a + [Certificate][google.cloud.security.privateca.v1.Certificate] + issued using this + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + If a certificate request sets extensions that don't appear + in the + [passthrough_extensions][google.cloud.security.privateca.v1.CertificateTemplate.passthrough_extensions], + those extensions will be dropped. If the issuing + [CaPool][google.cloud.security.privateca.v1.CaPool]'s + [IssuancePolicy][google.cloud.security.privateca.v1.CaPool.IssuancePolicy] + defines + [baseline_values][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.baseline_values] + that don't appear here, the certificate issuance request + will fail. If this is omitted, then this template will not + add restrictions on a certificate's X.509 extensions. These + constraints do not apply to X.509 extensions set in this + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]'s + [predefined_values][google.cloud.security.privateca.v1.CertificateTemplate.predefined_values]. + description (str): + Optional. A human-readable description of + scenarios this template is intended for. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + was updated. + labels (Sequence[google.cloud.security.privateca_v1.types.CertificateTemplate.LabelsEntry]): + Optional. Labels with user-defined metadata. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + predefined_values = proto.Field( + proto.MESSAGE, + number=2, + message='X509Parameters', + ) + identity_constraints = proto.Field( + proto.MESSAGE, + number=3, + message='CertificateIdentityConstraints', + ) + passthrough_extensions = proto.Field( + proto.MESSAGE, + number=4, + message='CertificateExtensionConstraints', + ) + description = proto.Field( + proto.STRING, + number=5, + ) + create_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=8, + ) + + +class X509Parameters(proto.Message): + r"""An + [X509Parameters][google.cloud.security.privateca.v1.X509Parameters] + is used to describe certain fields of an X.509 certificate, such as + the key usage fields, fields specific to CA certificates, + certificate policy extensions and custom extensions. + + Attributes: + key_usage (google.cloud.security.privateca_v1.types.KeyUsage): + Optional. Indicates the intended use for keys + that correspond to a certificate. + ca_options (google.cloud.security.privateca_v1.types.X509Parameters.CaOptions): + Optional. Describes options in this + [X509Parameters][google.cloud.security.privateca.v1.X509Parameters] + that are relevant in a CA certificate. + policy_ids (Sequence[google.cloud.security.privateca_v1.types.ObjectId]): + Optional. Describes the X.509 certificate + policy object identifiers, per + https://tools.ietf.org/html/rfc5280#section-4.2.1.4. + aia_ocsp_servers (Sequence[str]): + Optional. Describes Online Certificate Status + Protocol (OCSP) endpoint addresses that appear + in the "Authority Information Access" extension + in the certificate. + additional_extensions (Sequence[google.cloud.security.privateca_v1.types.X509Extension]): + Optional. Describes custom X.509 extensions. + """ + + class CaOptions(proto.Message): + r"""Describes values that are relevant in a CA certificate. + Attributes: + is_ca (bool): + Optional. Refers to the "CA" X.509 extension, + which is a boolean value. When this value is + missing, the extension will be omitted from the + CA certificate. + max_issuer_path_length (int): + Optional. Refers to the path length + restriction X.509 extension. For a CA + certificate, this value describes the depth of + subordinate CA certificates that are allowed. + If this value is less than 0, the request will + fail. If this value is missing, the max path + length will be omitted from the CA certificate. + """ + + is_ca = proto.Field( + proto.BOOL, + number=1, + optional=True, + ) + max_issuer_path_length = proto.Field( + proto.INT32, + number=2, + optional=True, + ) + + key_usage = proto.Field( + proto.MESSAGE, + number=1, + message='KeyUsage', + ) + ca_options = proto.Field( + proto.MESSAGE, + number=2, + message=CaOptions, + ) + policy_ids = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='ObjectId', + ) + aia_ocsp_servers = proto.RepeatedField( + proto.STRING, + number=4, + ) + additional_extensions = proto.RepeatedField( + proto.MESSAGE, + number=5, + message='X509Extension', + ) + + +class SubordinateConfig(proto.Message): + r"""Describes a subordinate CA's issuers. This is either a resource name + to a known issuing + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority], + or a PEM issuer certificate chain. + + Attributes: + certificate_authority (str): + Required. This can refer to a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the same project that was used to create a subordinate + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + This field is used for information and usability purposes + only. The resource name is in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + pem_issuer_chain (google.cloud.security.privateca_v1.types.SubordinateConfig.SubordinateConfigChain): + Required. Contains the PEM certificate chain for the issuers + of this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority], + but not pem certificate for this CA itself. + """ + + class SubordinateConfigChain(proto.Message): + r"""This message describes a subordinate CA's issuer certificate + chain. This wrapper exists for compatibility reasons. + + Attributes: + pem_certificates (Sequence[str]): + Required. Expected to be in leaf-to-root + order according to RFC 5246. + """ + + pem_certificates = proto.RepeatedField( + proto.STRING, + number=1, + ) + + certificate_authority = proto.Field( + proto.STRING, + number=1, + oneof='subordinate_config', + ) + pem_issuer_chain = proto.Field( + proto.MESSAGE, + number=2, + oneof='subordinate_config', + message=SubordinateConfigChain, + ) + + +class PublicKey(proto.Message): + r"""A [PublicKey][google.cloud.security.privateca.v1.PublicKey] + describes a public key. + + Attributes: + key (bytes): + Required. A public key. The padding and encoding must match + with the ``KeyFormat`` value specified for the ``format`` + field. + format_ (google.cloud.security.privateca_v1.types.PublicKey.KeyFormat): + Required. The format of the public key. + """ + class KeyFormat(proto.Enum): + r"""Types of public keys formats that are supported. Currently, only + ``PEM`` format is supported. + """ + KEY_FORMAT_UNSPECIFIED = 0 + PEM = 1 + + key = proto.Field( + proto.BYTES, + number=1, + ) + format_ = proto.Field( + proto.ENUM, + number=2, + enum=KeyFormat, + ) + + +class CertificateConfig(proto.Message): + r"""A + [CertificateConfig][google.cloud.security.privateca.v1.CertificateConfig] + describes an X.509 certificate or CSR that is to be created, as an + alternative to using ASN.1. + + Attributes: + subject_config (google.cloud.security.privateca_v1.types.CertificateConfig.SubjectConfig): + Required. Specifies some of the values in a + certificate that are related to the subject. + x509_config (google.cloud.security.privateca_v1.types.X509Parameters): + Required. Describes how some of the technical + X.509 fields in a certificate should be + populated. + public_key (google.cloud.security.privateca_v1.types.PublicKey): + Optional. The public key that corresponds to this config. + This is, for example, used when issuing + [Certificates][google.cloud.security.privateca.v1.Certificate], + but not when creating a self-signed + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + or + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + CSR. + """ + + class SubjectConfig(proto.Message): + r"""These values are used to create the distinguished name and + subject alternative name fields in an X.509 certificate. + + Attributes: + subject (google.cloud.security.privateca_v1.types.Subject): + Required. Contains distinguished name fields + such as the common name, location and + organization. + subject_alt_name (google.cloud.security.privateca_v1.types.SubjectAltNames): + Optional. The subject alternative name + fields. + """ + + subject = proto.Field( + proto.MESSAGE, + number=1, + message='Subject', + ) + subject_alt_name = proto.Field( + proto.MESSAGE, + number=2, + message='SubjectAltNames', + ) + + subject_config = proto.Field( + proto.MESSAGE, + number=1, + message=SubjectConfig, + ) + x509_config = proto.Field( + proto.MESSAGE, + number=2, + message='X509Parameters', + ) + public_key = proto.Field( + proto.MESSAGE, + number=3, + message='PublicKey', + ) + + +class CertificateDescription(proto.Message): + r"""A + [CertificateDescription][google.cloud.security.privateca.v1.CertificateDescription] + describes an X.509 certificate or CSR that has been issued, as an + alternative to using ASN.1 / X.509. + + Attributes: + subject_description (google.cloud.security.privateca_v1.types.CertificateDescription.SubjectDescription): + Describes some of the values in a certificate + that are related to the subject and lifetime. + x509_description (google.cloud.security.privateca_v1.types.X509Parameters): + Describes some of the technical X.509 fields + in a certificate. + public_key (google.cloud.security.privateca_v1.types.PublicKey): + The public key that corresponds to an issued + certificate. + subject_key_id (google.cloud.security.privateca_v1.types.CertificateDescription.KeyId): + Provides a means of identifiying certificates + that contain a particular public key, per + https://tools.ietf.org/html/rfc5280#section-4.2.1.2. + authority_key_id (google.cloud.security.privateca_v1.types.CertificateDescription.KeyId): + Identifies the subject_key_id of the parent certificate, per + https://tools.ietf.org/html/rfc5280#section-4.2.1.1 + crl_distribution_points (Sequence[str]): + Describes a list of locations to obtain CRL + information, i.e. the DistributionPoint.fullName + described by + https://tools.ietf.org/html/rfc5280#section-4.2.1.13 + aia_issuing_certificate_urls (Sequence[str]): + Describes lists of issuer CA certificate URLs + that appear in the "Authority Information + Access" extension in the certificate. + cert_fingerprint (google.cloud.security.privateca_v1.types.CertificateDescription.CertificateFingerprint): + The hash of the x.509 certificate. + """ + + class SubjectDescription(proto.Message): + r"""These values describe fields in an issued X.509 certificate + such as the distinguished name, subject alternative names, + serial number, and lifetime. + + Attributes: + subject (google.cloud.security.privateca_v1.types.Subject): + Contains distinguished name fields such as + the common name, location and / organization. + subject_alt_name (google.cloud.security.privateca_v1.types.SubjectAltNames): + The subject alternative name fields. + hex_serial_number (str): + The serial number encoded in lowercase + hexadecimal. + lifetime (google.protobuf.duration_pb2.Duration): + For convenience, the actual lifetime of an issued + certificate. Corresponds to 'not_after_time' - + 'not_before_time'. + not_before_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which the certificate becomes + valid. + not_after_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which the certificate expires. + """ + + subject = proto.Field( + proto.MESSAGE, + number=1, + message='Subject', + ) + subject_alt_name = proto.Field( + proto.MESSAGE, + number=2, + message='SubjectAltNames', + ) + hex_serial_number = proto.Field( + proto.STRING, + number=3, + ) + lifetime = proto.Field( + proto.MESSAGE, + number=4, + message=duration_pb2.Duration, + ) + not_before_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + not_after_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + + class KeyId(proto.Message): + r"""A KeyId identifies a specific public key, usually by hashing + the public key. + + Attributes: + key_id (str): + Optional. The value of this KeyId encoded in + lowercase hexadecimal. This is most likely the + 160 bit SHA-1 hash of the public key. + """ + + key_id = proto.Field( + proto.STRING, + number=1, + ) + + class CertificateFingerprint(proto.Message): + r"""A group of fingerprints for the x509 certificate. + Attributes: + sha256_hash (str): + The SHA 256 hash, encoded in hexadecimal, of + the DER x509 certificate. + """ + + sha256_hash = proto.Field( + proto.STRING, + number=1, + ) + + subject_description = proto.Field( + proto.MESSAGE, + number=1, + message=SubjectDescription, + ) + x509_description = proto.Field( + proto.MESSAGE, + number=2, + message='X509Parameters', + ) + public_key = proto.Field( + proto.MESSAGE, + number=3, + message='PublicKey', + ) + subject_key_id = proto.Field( + proto.MESSAGE, + number=4, + message=KeyId, + ) + authority_key_id = proto.Field( + proto.MESSAGE, + number=5, + message=KeyId, + ) + crl_distribution_points = proto.RepeatedField( + proto.STRING, + number=6, + ) + aia_issuing_certificate_urls = proto.RepeatedField( + proto.STRING, + number=7, + ) + cert_fingerprint = proto.Field( + proto.MESSAGE, + number=8, + message=CertificateFingerprint, + ) + + +class ObjectId(proto.Message): + r"""An [ObjectId][google.cloud.security.privateca.v1.ObjectId] specifies + an object identifier (OID). These provide context and describe types + in ASN.1 messages. + + Attributes: + object_id_path (Sequence[int]): + Required. The parts of an OID path. The most + significant parts of the path come first. + """ + + object_id_path = proto.RepeatedField( + proto.INT32, + number=1, + ) + + +class X509Extension(proto.Message): + r"""An [X509Extension][google.cloud.security.privateca.v1.X509Extension] + specifies an X.509 extension, which may be used in different parts + of X.509 objects like certificates, CSRs, and CRLs. + + Attributes: + object_id (google.cloud.security.privateca_v1.types.ObjectId): + Required. The OID for this X.509 extension. + critical (bool): + Required. Indicates whether or not this + extension is critical (i.e., if the client does + not know how to handle this extension, the + client should consider this to be an error). + value (bytes): + Required. The value of this X.509 extension. + """ + + object_id = proto.Field( + proto.MESSAGE, + number=1, + message='ObjectId', + ) + critical = proto.Field( + proto.BOOL, + number=2, + ) + value = proto.Field( + proto.BYTES, + number=3, + ) + + +class KeyUsage(proto.Message): + r"""A [KeyUsage][google.cloud.security.privateca.v1.KeyUsage] describes + key usage values that may appear in an X.509 certificate. + + Attributes: + base_key_usage (google.cloud.security.privateca_v1.types.KeyUsage.KeyUsageOptions): + Describes high-level ways in which a key may + be used. + extended_key_usage (google.cloud.security.privateca_v1.types.KeyUsage.ExtendedKeyUsageOptions): + Detailed scenarios in which a key may be + used. + unknown_extended_key_usages (Sequence[google.cloud.security.privateca_v1.types.ObjectId]): + Used to describe extended key usages that are not listed in + the + [KeyUsage.ExtendedKeyUsageOptions][google.cloud.security.privateca.v1.KeyUsage.ExtendedKeyUsageOptions] + message. + """ + + class KeyUsageOptions(proto.Message): + r"""[KeyUsage.KeyUsageOptions][google.cloud.security.privateca.v1.KeyUsage.KeyUsageOptions] + corresponds to the key usage values described in + https://tools.ietf.org/html/rfc5280#section-4.2.1.3. + + Attributes: + digital_signature (bool): + The key may be used for digital signatures. + content_commitment (bool): + The key may be used for cryptographic + commitments. Note that this may also be referred + to as "non-repudiation". + key_encipherment (bool): + The key may be used to encipher other keys. + data_encipherment (bool): + The key may be used to encipher data. + key_agreement (bool): + The key may be used in a key agreement + protocol. + cert_sign (bool): + The key may be used to sign certificates. + crl_sign (bool): + The key may be used sign certificate + revocation lists. + encipher_only (bool): + The key may be used to encipher only. + decipher_only (bool): + The key may be used to decipher only. + """ + + digital_signature = proto.Field( + proto.BOOL, + number=1, + ) + content_commitment = proto.Field( + proto.BOOL, + number=2, + ) + key_encipherment = proto.Field( + proto.BOOL, + number=3, + ) + data_encipherment = proto.Field( + proto.BOOL, + number=4, + ) + key_agreement = proto.Field( + proto.BOOL, + number=5, + ) + cert_sign = proto.Field( + proto.BOOL, + number=6, + ) + crl_sign = proto.Field( + proto.BOOL, + number=7, + ) + encipher_only = proto.Field( + proto.BOOL, + number=8, + ) + decipher_only = proto.Field( + proto.BOOL, + number=9, + ) + + class ExtendedKeyUsageOptions(proto.Message): + r"""[KeyUsage.ExtendedKeyUsageOptions][google.cloud.security.privateca.v1.KeyUsage.ExtendedKeyUsageOptions] + has fields that correspond to certain common OIDs that could be + specified as an extended key usage value. + + Attributes: + server_auth (bool): + Corresponds to OID 1.3.6.1.5.5.7.3.1. + Officially described as "TLS WWW server + authentication", though regularly used for non- + WWW TLS. + client_auth (bool): + Corresponds to OID 1.3.6.1.5.5.7.3.2. + Officially described as "TLS WWW client + authentication", though regularly used for non- + WWW TLS. + code_signing (bool): + Corresponds to OID 1.3.6.1.5.5.7.3.3. + Officially described as "Signing of downloadable + executable code client authentication". + email_protection (bool): + Corresponds to OID 1.3.6.1.5.5.7.3.4. + Officially described as "Email protection". + time_stamping (bool): + Corresponds to OID 1.3.6.1.5.5.7.3.8. + Officially described as "Binding the hash of an + object to a time". + ocsp_signing (bool): + Corresponds to OID 1.3.6.1.5.5.7.3.9. + Officially described as "Signing OCSP + responses". + """ + + server_auth = proto.Field( + proto.BOOL, + number=1, + ) + client_auth = proto.Field( + proto.BOOL, + number=2, + ) + code_signing = proto.Field( + proto.BOOL, + number=3, + ) + email_protection = proto.Field( + proto.BOOL, + number=4, + ) + time_stamping = proto.Field( + proto.BOOL, + number=5, + ) + ocsp_signing = proto.Field( + proto.BOOL, + number=6, + ) + + base_key_usage = proto.Field( + proto.MESSAGE, + number=1, + message=KeyUsageOptions, + ) + extended_key_usage = proto.Field( + proto.MESSAGE, + number=2, + message=ExtendedKeyUsageOptions, + ) + unknown_extended_key_usages = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='ObjectId', + ) + + +class Subject(proto.Message): + r"""[Subject][google.cloud.security.privateca.v1.Subject] describes + parts of a distinguished name that, in turn, describes the subject + of the certificate. + + Attributes: + common_name (str): + The "common name" of the subject. + country_code (str): + The country code of the subject. + organization (str): + The organization of the subject. + organizational_unit (str): + The organizational_unit of the subject. + locality (str): + The locality or city of the subject. + province (str): + The province, territory, or regional state of + the subject. + street_address (str): + The street address of the subject. + postal_code (str): + The postal code of the subject. + """ + + common_name = proto.Field( + proto.STRING, + number=1, + ) + country_code = proto.Field( + proto.STRING, + number=2, + ) + organization = proto.Field( + proto.STRING, + number=3, + ) + organizational_unit = proto.Field( + proto.STRING, + number=4, + ) + locality = proto.Field( + proto.STRING, + number=5, + ) + province = proto.Field( + proto.STRING, + number=6, + ) + street_address = proto.Field( + proto.STRING, + number=7, + ) + postal_code = proto.Field( + proto.STRING, + number=8, + ) + + +class SubjectAltNames(proto.Message): + r"""[SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames] + corresponds to a more modern way of listing what the asserted + identity is in a certificate (i.e., compared to the "common name" in + the distinguished name). + + Attributes: + dns_names (Sequence[str]): + Contains only valid, fully-qualified host + names. + uris (Sequence[str]): + Contains only valid RFC 3986 URIs. + email_addresses (Sequence[str]): + Contains only valid RFC 2822 E-mail + addresses. + ip_addresses (Sequence[str]): + Contains only valid 32-bit IPv4 addresses or + RFC 4291 IPv6 addresses. + custom_sans (Sequence[google.cloud.security.privateca_v1.types.X509Extension]): + Contains additional subject alternative name + values. + """ + + dns_names = proto.RepeatedField( + proto.STRING, + number=1, + ) + uris = proto.RepeatedField( + proto.STRING, + number=2, + ) + email_addresses = proto.RepeatedField( + proto.STRING, + number=3, + ) + ip_addresses = proto.RepeatedField( + proto.STRING, + number=4, + ) + custom_sans = proto.RepeatedField( + proto.MESSAGE, + number=5, + message='X509Extension', + ) + + +class CertificateIdentityConstraints(proto.Message): + r"""Describes constraints on a + [Certificate][google.cloud.security.privateca.v1.Certificate]'s + [Subject][google.cloud.security.privateca.v1.Subject] and + [SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames]. + + Attributes: + cel_expression (google.type.expr_pb2.Expr): + Optional. A CEL expression that may be used + to validate the resolved X.509 Subject and/or + Subject Alternative Name before a certificate is + signed. To see the full allowed syntax and some + examples, see + https://cloud.google.com/certificate-authority- + service/docs/cel-guide + allow_subject_passthrough (bool): + Required. If this is true, the + [Subject][google.cloud.security.privateca.v1.Subject] field + may be copied from a certificate request into the signed + certificate. Otherwise, the requested + [Subject][google.cloud.security.privateca.v1.Subject] will + be discarded. The bool is optional to indicate an unset + field, which suggests a forgotten value that needs to be set + by the caller. + allow_subject_alt_names_passthrough (bool): + Required. If this is true, the + [SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames] + extension may be copied from a certificate request into the + signed certificate. Otherwise, the requested + [SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames] + will be discarded. The bool is optional to indicate an unset + field, which suggests a forgotten value that needs to be set + by the caller. + """ + + cel_expression = proto.Field( + proto.MESSAGE, + number=1, + message=expr_pb2.Expr, + ) + allow_subject_passthrough = proto.Field( + proto.BOOL, + number=2, + optional=True, + ) + allow_subject_alt_names_passthrough = proto.Field( + proto.BOOL, + number=3, + optional=True, + ) + + +class CertificateExtensionConstraints(proto.Message): + r"""Describes a set of X.509 extensions that may be part of some + certificate issuance controls. + + Attributes: + known_extensions (Sequence[google.cloud.security.privateca_v1.types.CertificateExtensionConstraints.KnownCertificateExtension]): + Optional. A set of named X.509 extensions. Will be combined + with + [additional_extensions][google.cloud.security.privateca.v1.CertificateExtensionConstraints.additional_extensions] + to determine the full set of X.509 extensions. + additional_extensions (Sequence[google.cloud.security.privateca_v1.types.ObjectId]): + Optional. A set of + [ObjectIds][google.cloud.security.privateca.v1.ObjectId] + identifying custom X.509 extensions. Will be combined with + [known_extensions][google.cloud.security.privateca.v1.CertificateExtensionConstraints.known_extensions] + to determine the full set of X.509 extensions. + """ + class KnownCertificateExtension(proto.Enum): + r"""Describes well-known X.509 extensions that can appear in a + [Certificate][google.cloud.security.privateca.v1.Certificate], not + including the + [SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames] + extension. + """ + KNOWN_CERTIFICATE_EXTENSION_UNSPECIFIED = 0 + BASE_KEY_USAGE = 1 + EXTENDED_KEY_USAGE = 2 + CA_OPTIONS = 3 + POLICY_IDS = 4 + AIA_OCSP_SERVERS = 5 + + known_extensions = proto.RepeatedField( + proto.ENUM, + number=1, + enum=KnownCertificateExtension, + ) + additional_extensions = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='ObjectId', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/service.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/service.py new file mode 100644 index 0000000..b4b7f43 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/service.py @@ -0,0 +1,1656 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import proto # type: ignore + +from google.cloud.security.privateca_v1.types import resources +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.security.privateca.v1', + manifest={ + 'CreateCertificateRequest', + 'GetCertificateRequest', + 'ListCertificatesRequest', + 'ListCertificatesResponse', + 'RevokeCertificateRequest', + 'UpdateCertificateRequest', + 'ActivateCertificateAuthorityRequest', + 'CreateCertificateAuthorityRequest', + 'DisableCertificateAuthorityRequest', + 'EnableCertificateAuthorityRequest', + 'FetchCertificateAuthorityCsrRequest', + 'FetchCertificateAuthorityCsrResponse', + 'GetCertificateAuthorityRequest', + 'ListCertificateAuthoritiesRequest', + 'ListCertificateAuthoritiesResponse', + 'UndeleteCertificateAuthorityRequest', + 'DeleteCertificateAuthorityRequest', + 'UpdateCertificateAuthorityRequest', + 'CreateCaPoolRequest', + 'UpdateCaPoolRequest', + 'DeleteCaPoolRequest', + 'FetchCaCertsRequest', + 'FetchCaCertsResponse', + 'GetCaPoolRequest', + 'ListCaPoolsRequest', + 'ListCaPoolsResponse', + 'GetCertificateRevocationListRequest', + 'ListCertificateRevocationListsRequest', + 'ListCertificateRevocationListsResponse', + 'UpdateCertificateRevocationListRequest', + 'CreateCertificateTemplateRequest', + 'DeleteCertificateTemplateRequest', + 'GetCertificateTemplateRequest', + 'ListCertificateTemplatesRequest', + 'ListCertificateTemplatesResponse', + 'UpdateCertificateTemplateRequest', + 'OperationMetadata', + }, +) + + +class CreateCertificateRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.CreateCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificate]. + + Attributes: + parent (str): + Required. The resource name of the + [CaPool][google.cloud.security.privateca.v1.CaPool] + associated with the + [Certificate][google.cloud.security.privateca.v1.Certificate], + in the format ``projects/*/locations/*/caPools/*``. + certificate_id (str): + Optional. It must be unique within a location and match the + regular expression ``[a-zA-Z0-9_-]{1,63}``. This field is + required when using a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the Enterprise [CertificateAuthority.Tier][], but is + optional and its value is ignored otherwise. + certificate (google.cloud.security.privateca_v1.types.Certificate): + Required. A + [Certificate][google.cloud.security.privateca.v1.Certificate] + with initial field values. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + validate_only (bool): + Optional. If this is true, no + [Certificate][google.cloud.security.privateca.v1.Certificate] + resource will be persisted regardless of the + [CaPool][google.cloud.security.privateca.v1.CaPool]'s + [tier][google.cloud.security.privateca.v1.CaPool.tier], and + the returned + [Certificate][google.cloud.security.privateca.v1.Certificate] + will not contain the + [pem_certificate][google.cloud.security.privateca.v1.Certificate.pem_certificate] + field. + issuing_certificate_authority_id (str): + Optional. The resource ID of the + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + that should issue the certificate. This optional field will + ignore the load-balancing scheme of the Pool and directly + issue the certificate from the CA with the specified ID, + contained in the same + [CaPool][google.cloud.security.privateca.v1.CaPool] + referenced by ``parent``. Per-CA quota rules apply. If left + empty, a + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + will be chosen from the + [CaPool][google.cloud.security.privateca.v1.CaPool] by the + service. For example, to issue a + [Certificate][google.cloud.security.privateca.v1.Certificate] + from a Certificate Authority with resource name + "projects/my-project/locations/us-central1/caPools/my-pool/certificateAuthorities/my-ca", + you can set the + [parent][google.cloud.security.privateca.v1.CreateCertificateRequest.parent] + to + "projects/my-project/locations/us-central1/caPools/my-pool" + and the + [issuing_certificate_authority_id][google.cloud.security.privateca.v1.CreateCertificateRequest.issuing_certificate_authority_id] + to "my-ca". + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + certificate_id = proto.Field( + proto.STRING, + number=2, + ) + certificate = proto.Field( + proto.MESSAGE, + number=3, + message=resources.Certificate, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + validate_only = proto.Field( + proto.BOOL, + number=5, + ) + issuing_certificate_authority_id = proto.Field( + proto.STRING, + number=6, + ) + + +class GetCertificateRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.GetCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificate]. + + Attributes: + name (str): + Required. The + [name][google.cloud.security.privateca.v1.Certificate.name] + of the + [Certificate][google.cloud.security.privateca.v1.Certificate] + to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListCertificatesRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificates]. + + Attributes: + parent (str): + Required. The resource name of the location associated with + the + [Certificates][google.cloud.security.privateca.v1.Certificate], + in the format ``projects/*/locations/*/caPools/*``. + page_size (int): + Optional. Limit on the number of + [Certificates][google.cloud.security.privateca.v1.Certificate] + to include in the response. Further + [Certificates][google.cloud.security.privateca.v1.Certificate] + can subsequently be obtained by including the + [ListCertificatesResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificatesResponse.next_page_token] + in a subsequent request. If unspecified, the server will + pick an appropriate default. + page_token (str): + Optional. Pagination token, returned earlier via + [ListCertificatesResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificatesResponse.next_page_token]. + filter (str): + Optional. Only include resources that match the filter in + the response. For details on supported filters and syntax, + see `Certificates Filtering + documentation `__. + order_by (str): + Optional. Specify how the results should be sorted. For + details on supported fields and syntax, see `Certificates + Sorting + documentation `__. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCertificatesResponse(proto.Message): + r"""Response message for + [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificates]. + + Attributes: + certificates (Sequence[google.cloud.security.privateca_v1.types.Certificate]): + The list of + [Certificates][google.cloud.security.privateca.v1.Certificate]. + next_page_token (str): + A token to retrieve next page of results. Pass this value in + [ListCertificatesRequest.next_page_token][] to retrieve the + next page of results. + unreachable (Sequence[str]): + A list of locations (e.g. "us-west1") that + could not be reached. + """ + + @property + def raw_page(self): + return self + + certificates = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.Certificate, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class RevokeCertificateRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.RevokeCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.RevokeCertificate]. + + Attributes: + name (str): + Required. The resource name for this + [Certificate][google.cloud.security.privateca.v1.Certificate] + in the format + ``projects/*/locations/*/caPools/*/certificates/*``. + reason (google.cloud.security.privateca_v1.types.RevocationReason): + Required. The + [RevocationReason][google.cloud.security.privateca.v1.RevocationReason] + for revoking this certificate. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + reason = proto.Field( + proto.ENUM, + number=2, + enum=resources.RevocationReason, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class UpdateCertificateRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.UpdateCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificate]. + + Attributes: + certificate (google.cloud.security.privateca_v1.types.Certificate): + Required. + [Certificate][google.cloud.security.privateca.v1.Certificate] + with updated values. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be updated in + this request. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + certificate = proto.Field( + proto.MESSAGE, + number=1, + message=resources.Certificate, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class ActivateCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + pem_ca_certificate (str): + Required. The signed CA certificate issued from + [FetchCertificateAuthorityCsrResponse.pem_csr][google.cloud.security.privateca.v1.FetchCertificateAuthorityCsrResponse.pem_csr]. + subordinate_config (google.cloud.security.privateca_v1.types.SubordinateConfig): + Required. Must include information about the issuer of + 'pem_ca_certificate', and any further issuers until the + self-signed CA. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + pem_ca_certificate = proto.Field( + proto.STRING, + number=2, + ) + subordinate_config = proto.Field( + proto.MESSAGE, + number=3, + message=resources.SubordinateConfig, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class CreateCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.CreateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificateAuthority]. + + Attributes: + parent (str): + Required. The resource name of the + [CaPool][google.cloud.security.privateca.v1.CaPool] + associated with the + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority], + in the format ``projects/*/locations/*/caPools/*``. + certificate_authority_id (str): + Required. It must be unique within a location and match the + regular expression ``[a-zA-Z0-9_-]{1,63}`` + certificate_authority (google.cloud.security.privateca_v1.types.CertificateAuthority): + Required. A + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + with initial field values. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + certificate_authority_id = proto.Field( + proto.STRING, + number=2, + ) + certificate_authority = proto.Field( + proto.MESSAGE, + number=3, + message=resources.CertificateAuthority, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class DisableCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.DisableCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.DisableCertificateAuthority]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class EnableCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.EnableCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.EnableCertificateAuthority]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class FetchCertificateAuthorityCsrRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class FetchCertificateAuthorityCsrResponse(proto.Message): + r"""Response message for + [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. + + Attributes: + pem_csr (str): + Output only. The PEM-encoded signed + certificate signing request (CSR). + """ + + pem_csr = proto.Field( + proto.STRING, + number=1, + ) + + +class GetCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.GetCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateAuthority]. + + Attributes: + name (str): + Required. The + [name][google.cloud.security.privateca.v1.CertificateAuthority.name] + of the + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListCertificateAuthoritiesRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateAuthorities]. + + Attributes: + parent (str): + Required. The resource name of the + [CaPool][google.cloud.security.privateca.v1.CaPool] + associated with the + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority], + in the format ``projects/*/locations/*/caPools/*``. + page_size (int): + Optional. Limit on the number of + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] + to include in the response. Further + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] + can subsequently be obtained by including the + [ListCertificateAuthoritiesResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificateAuthoritiesResponse.next_page_token] + in a subsequent request. If unspecified, the server will + pick an appropriate default. + page_token (str): + Optional. Pagination token, returned earlier via + [ListCertificateAuthoritiesResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificateAuthoritiesResponse.next_page_token]. + filter (str): + Optional. Only include resources that match + the filter in the response. + order_by (str): + Optional. Specify how the results should be + sorted. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCertificateAuthoritiesResponse(proto.Message): + r"""Response message for + [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateAuthorities]. + + Attributes: + certificate_authorities (Sequence[google.cloud.security.privateca_v1.types.CertificateAuthority]): + The list of + [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. + next_page_token (str): + A token to retrieve next page of results. Pass this value in + [ListCertificateAuthoritiesRequest.next_page_token][] to + retrieve the next page of results. + unreachable (Sequence[str]): + A list of locations (e.g. "us-west1") that + could not be reached. + """ + + @property + def raw_page(self): + return self + + certificate_authorities = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.CertificateAuthority, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class UndeleteCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.UndeleteCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.UndeleteCertificateAuthority]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class DeleteCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.DeleteCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCertificateAuthority]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + ignore_active_certificates (bool): + Optional. This field allows the CA to be + deleted even if the CA has active certs. Active + certs include both unrevoked and unexpired + certs. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + ignore_active_certificates = proto.Field( + proto.BOOL, + number=4, + ) + + +class UpdateCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.UpdateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateAuthority]. + + Attributes: + certificate_authority (google.cloud.security.privateca_v1.types.CertificateAuthority): + Required. + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + with updated values. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be updated in + this request. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + certificate_authority = proto.Field( + proto.MESSAGE, + number=1, + message=resources.CertificateAuthority, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class CreateCaPoolRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.CreateCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCaPool]. + + Attributes: + parent (str): + Required. The resource name of the location associated with + the [CaPool][google.cloud.security.privateca.v1.CaPool], in + the format ``projects/*/locations/*``. + ca_pool_id (str): + Required. It must be unique within a location and match the + regular expression ``[a-zA-Z0-9_-]{1,63}`` + ca_pool (google.cloud.security.privateca_v1.types.CaPool): + Required. A + [CaPool][google.cloud.security.privateca.v1.CaPool] with + initial field values. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + ca_pool_id = proto.Field( + proto.STRING, + number=2, + ) + ca_pool = proto.Field( + proto.MESSAGE, + number=3, + message=resources.CaPool, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class UpdateCaPoolRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.UpdateCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCaPool]. + + Attributes: + ca_pool (google.cloud.security.privateca_v1.types.CaPool): + Required. + [CaPool][google.cloud.security.privateca.v1.CaPool] with + updated values. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be updated in + this request. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + ca_pool = proto.Field( + proto.MESSAGE, + number=1, + message=resources.CaPool, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class DeleteCaPoolRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.DeleteCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCaPool]. + + Attributes: + name (str): + Required. The resource name for this + [CaPool][google.cloud.security.privateca.v1.CaPool] in the + format ``projects/*/locations/*/caPools/*``. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class FetchCaCertsRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.FetchCaCerts][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCaCerts]. + + Attributes: + ca_pool (str): + Required. The resource name for the + [CaPool][google.cloud.security.privateca.v1.CaPool] in the + format ``projects/*/locations/*/caPools/*``. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + ca_pool = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class FetchCaCertsResponse(proto.Message): + r"""Response message for + [CertificateAuthorityService.FetchCaCerts][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCaCerts]. + + Attributes: + ca_certs (Sequence[google.cloud.security.privateca_v1.types.FetchCaCertsResponse.CertChain]): + The PEM encoded CA certificate chains of all + [ACTIVE][CertificateAuthority.State.ACTIVE] + [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + resources in this + [CaPool][google.cloud.security.privateca.v1.CaPool]. + """ + + class CertChain(proto.Message): + r""" + Attributes: + certificates (Sequence[str]): + The certificates that form the CA chain, from + leaf to root order. + """ + + certificates = proto.RepeatedField( + proto.STRING, + number=1, + ) + + ca_certs = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=CertChain, + ) + + +class GetCaPoolRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.GetCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCaPool]. + + Attributes: + name (str): + Required. The + [name][google.cloud.security.privateca.v1.CaPool.name] of + the [CaPool][google.cloud.security.privateca.v1.CaPool] to + get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListCaPoolsRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.ListCaPools][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCaPools]. + + Attributes: + parent (str): + Required. The resource name of the location associated with + the [CaPools][google.cloud.security.privateca.v1.CaPool], in + the format ``projects/*/locations/*``. + page_size (int): + Optional. Limit on the number of + [CaPools][google.cloud.security.privateca.v1.CaPool] to + include in the response. Further + [CaPools][google.cloud.security.privateca.v1.CaPool] can + subsequently be obtained by including the + [ListCaPoolsResponse.next_page_token][google.cloud.security.privateca.v1.ListCaPoolsResponse.next_page_token] + in a subsequent request. If unspecified, the server will + pick an appropriate default. + page_token (str): + Optional. Pagination token, returned earlier via + [ListCaPoolsResponse.next_page_token][google.cloud.security.privateca.v1.ListCaPoolsResponse.next_page_token]. + filter (str): + Optional. Only include resources that match + the filter in the response. + order_by (str): + Optional. Specify how the results should be + sorted. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCaPoolsResponse(proto.Message): + r"""Response message for + [CertificateAuthorityService.ListCaPools][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCaPools]. + + Attributes: + ca_pools (Sequence[google.cloud.security.privateca_v1.types.CaPool]): + The list of + [CaPools][google.cloud.security.privateca.v1.CaPool]. + next_page_token (str): + A token to retrieve next page of results. Pass this value in + [ListCertificateAuthoritiesRequest.next_page_token][] to + retrieve the next page of results. + unreachable (Sequence[str]): + A list of locations (e.g. "us-west1") that + could not be reached. + """ + + @property + def raw_page(self): + return self + + ca_pools = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.CaPool, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetCertificateRevocationListRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.GetCertificateRevocationList][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateRevocationList]. + + Attributes: + name (str): + Required. The + [name][google.cloud.security.privateca.v1.CertificateRevocationList.name] + of the + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] + to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListCertificateRevocationListsRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateRevocationLists]. + + Attributes: + parent (str): + Required. The resource name of the location associated with + the + [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList], + in the format + ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. + page_size (int): + Optional. Limit on the number of + [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList] + to include in the response. Further + [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList] + can subsequently be obtained by including the + [ListCertificateRevocationListsResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificateRevocationListsResponse.next_page_token] + in a subsequent request. If unspecified, the server will + pick an appropriate default. + page_token (str): + Optional. Pagination token, returned earlier via + [ListCertificateRevocationListsResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificateRevocationListsResponse.next_page_token]. + filter (str): + Optional. Only include resources that match + the filter in the response. + order_by (str): + Optional. Specify how the results should be + sorted. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCertificateRevocationListsResponse(proto.Message): + r"""Response message for + [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateRevocationLists]. + + Attributes: + certificate_revocation_lists (Sequence[google.cloud.security.privateca_v1.types.CertificateRevocationList]): + The list of + [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. + next_page_token (str): + A token to retrieve next page of results. Pass this value in + [ListCertificateRevocationListsRequest.next_page_token][] to + retrieve the next page of results. + unreachable (Sequence[str]): + A list of locations (e.g. "us-west1") that + could not be reached. + """ + + @property + def raw_page(self): + return self + + certificate_revocation_lists = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.CertificateRevocationList, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class UpdateCertificateRevocationListRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.UpdateCertificateRevocationList][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateRevocationList]. + + Attributes: + certificate_revocation_list (google.cloud.security.privateca_v1.types.CertificateRevocationList): + Required. + [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] + with updated values. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be updated in + this request. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + certificate_revocation_list = proto.Field( + proto.MESSAGE, + number=1, + message=resources.CertificateRevocationList, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class CreateCertificateTemplateRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.CreateCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificateTemplate]. + + Attributes: + parent (str): + Required. The resource name of the location associated with + the + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate], + in the format ``projects/*/locations/*``. + certificate_template_id (str): + Required. It must be unique within a location and match the + regular expression ``[a-zA-Z0-9_-]{1,63}`` + certificate_template (google.cloud.security.privateca_v1.types.CertificateTemplate): + Required. A + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + with initial field values. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + certificate_template_id = proto.Field( + proto.STRING, + number=2, + ) + certificate_template = proto.Field( + proto.MESSAGE, + number=3, + message=resources.CertificateTemplate, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class DeleteCertificateTemplateRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.DeleteCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCertificateTemplate]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + in the format + ``projects/*/locations/*/certificateTemplates/*``. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class GetCertificateTemplateRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.GetCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateTemplate]. + + Attributes: + name (str): + Required. The + [name][google.cloud.security.privateca.v1.CertificateTemplate.name] + of the + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListCertificateTemplatesRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.ListCertificateTemplates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateTemplates]. + + Attributes: + parent (str): + Required. The resource name of the location associated with + the + [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate], + in the format ``projects/*/locations/*``. + page_size (int): + Optional. Limit on the number of + [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate] + to include in the response. Further + [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate] + can subsequently be obtained by including the + [ListCertificateTemplatesResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificateTemplatesResponse.next_page_token] + in a subsequent request. If unspecified, the server will + pick an appropriate default. + page_token (str): + Optional. Pagination token, returned earlier via + [ListCertificateTemplatesResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificateTemplatesResponse.next_page_token]. + filter (str): + Optional. Only include resources that match + the filter in the response. + order_by (str): + Optional. Specify how the results should be + sorted. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCertificateTemplatesResponse(proto.Message): + r"""Response message for + [CertificateAuthorityService.ListCertificateTemplates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateTemplates]. + + Attributes: + certificate_templates (Sequence[google.cloud.security.privateca_v1.types.CertificateTemplate]): + The list of + [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. + next_page_token (str): + A token to retrieve next page of results. Pass this value in + [ListCertificateTemplatesRequest.next_page_token][] to + retrieve the next page of results. + unreachable (Sequence[str]): + A list of locations (e.g. "us-west1") that + could not be reached. + """ + + @property + def raw_page(self): + return self + + certificate_templates = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.CertificateTemplate, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class UpdateCertificateTemplateRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.UpdateCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateTemplate]. + + Attributes: + certificate_template (google.cloud.security.privateca_v1.types.CertificateTemplate): + Required. + [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + with updated values. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be updated in + this request. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + certificate_template = proto.Field( + proto.MESSAGE, + number=1, + message=resources.CertificateTemplate, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class OperationMetadata(proto.Message): + r"""Represents the metadata of the long-running operation. + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + target (str): + Output only. Server-defined resource path for + the target of the operation. + verb (str): + Output only. Name of the verb executed by the + operation. + status_message (str): + Output only. Human-readable status of the + operation, if any. + requested_cancellation (bool): + Output only. Identifies whether the user has requested + cancellation of the operation. Operations that have + successfully been cancelled have [Operation.error][] value + with a [google.rpc.Status.code][google.rpc.Status.code] of + 1, corresponding to ``Code.CANCELLED``. + api_version (str): + Output only. API version used to start the + operation. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + target = proto.Field( + proto.STRING, + number=3, + ) + verb = proto.Field( + proto.STRING, + number=4, + ) + status_message = proto.Field( + proto.STRING, + number=5, + ) + requested_cancellation = proto.Field( + proto.BOOL, + number=6, + ) + api_version = proto.Field( + proto.STRING, + number=7, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/mypy.ini b/owl-bot-staging/v1/mypy.ini new file mode 100644 index 0000000..4505b48 --- /dev/null +++ b/owl-bot-staging/v1/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.6 +namespace_packages = True diff --git a/owl-bot-staging/v1/noxfile.py b/owl-bot-staging/v1/noxfile.py new file mode 100644 index 0000000..6d766f1 --- /dev/null +++ b/owl-bot-staging/v1/noxfile.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") + + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", +] + +@nox.session(python=['3.6', '3.7', '3.8', '3.9']) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/cloud/security/privateca_v1/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python='3.7') +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python=['3.6', '3.7']) +def mypy(session): + """Run the type checker.""" + session.install('mypy') + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python='3.6') +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx<3.0.0", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/owl-bot-staging/v1/scripts/fixup_privateca_v1_keywords.py b/owl-bot-staging/v1/scripts/fixup_privateca_v1_keywords.py new file mode 100644 index 0000000..65447c5 --- /dev/null +++ b/owl-bot-staging/v1/scripts/fixup_privateca_v1_keywords.py @@ -0,0 +1,204 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class privatecaCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'activate_certificate_authority': ('name', 'pem_ca_certificate', 'subordinate_config', 'request_id', ), + 'create_ca_pool': ('parent', 'ca_pool_id', 'ca_pool', 'request_id', ), + 'create_certificate': ('parent', 'certificate', 'certificate_id', 'request_id', 'validate_only', 'issuing_certificate_authority_id', ), + 'create_certificate_authority': ('parent', 'certificate_authority_id', 'certificate_authority', 'request_id', ), + 'create_certificate_template': ('parent', 'certificate_template_id', 'certificate_template', 'request_id', ), + 'delete_ca_pool': ('name', 'request_id', ), + 'delete_certificate_authority': ('name', 'request_id', 'ignore_active_certificates', ), + 'delete_certificate_template': ('name', 'request_id', ), + 'disable_certificate_authority': ('name', 'request_id', ), + 'enable_certificate_authority': ('name', 'request_id', ), + 'fetch_ca_certs': ('ca_pool', 'request_id', ), + 'fetch_certificate_authority_csr': ('name', ), + 'get_ca_pool': ('name', ), + 'get_certificate': ('name', ), + 'get_certificate_authority': ('name', ), + 'get_certificate_revocation_list': ('name', ), + 'get_certificate_template': ('name', ), + 'list_ca_pools': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificate_authorities': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificate_revocation_lists': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificate_templates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'revoke_certificate': ('name', 'reason', 'request_id', ), + 'undelete_certificate_authority': ('name', 'request_id', ), + 'update_ca_pool': ('ca_pool', 'update_mask', 'request_id', ), + 'update_certificate': ('certificate', 'update_mask', 'request_id', ), + 'update_certificate_authority': ('certificate_authority', 'update_mask', 'request_id', ), + 'update_certificate_revocation_list': ('certificate_revocation_list', 'update_mask', 'request_id', ), + 'update_certificate_template': ('certificate_template', 'update_mask', 'request_id', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=privatecaCallTransformer(), +): + """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 privateca 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..9796ba8 --- /dev/null +++ b/owl-bot-staging/v1/setup.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import io +import os +import setuptools # type: ignore + +version = '0.1.0' + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, 'README.rst') +with io.open(readme_filename, encoding='utf-8') as readme_file: + readme = readme_file.read() + +setuptools.setup( + name='google-cloud-security-privateca', + version=version, + long_description=readme, + packages=setuptools.PEP420PackageFinder.find(), + namespace_packages=('google', 'google.cloud', 'google.cloud.security'), + platforms='Posix; MacOS X; Windows', + include_package_data=True, + install_requires=( + 'google-api-core[grpc] >= 1.22.2, < 2.0.0dev', + 'libcst >= 0.2.5', + 'proto-plus >= 1.15.0', + 'packaging >= 14.3', ), + python_requires='>=3.6', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Topic :: Internet', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + zip_safe=False, +) diff --git a/owl-bot-staging/v1/tests/__init__.py b/owl-bot-staging/v1/tests/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1/tests/unit/__init__.py b/owl-bot-staging/v1/tests/unit/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1/tests/unit/gapic/privateca_v1/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/privateca_v1/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/privateca_v1/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py b/owl-bot-staging/v1/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py new file mode 100644 index 0000000..9509255 --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py @@ -0,0 +1,8989 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +import mock +import packaging.version + +import grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import future +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import operation_async # type: ignore +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.security.privateca_v1.services.certificate_authority_service import CertificateAuthorityServiceAsyncClient +from google.cloud.security.privateca_v1.services.certificate_authority_service import CertificateAuthorityServiceClient +from google.cloud.security.privateca_v1.services.certificate_authority_service import pagers +from google.cloud.security.privateca_v1.services.certificate_authority_service import transports +from google.cloud.security.privateca_v1.services.certificate_authority_service.transports.base import _API_CORE_VERSION +from google.cloud.security.privateca_v1.services.certificate_authority_service.transports.base import _GOOGLE_AUTH_VERSION +from google.cloud.security.privateca_v1.types import resources +from google.cloud.security.privateca_v1.types import service +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import expr_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(None) is None + assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class", [ + CertificateAuthorityServiceClient, + CertificateAuthorityServiceAsyncClient, +]) +def test_certificate_authority_service_client_from_service_account_info(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'privateca.googleapis.com:443' + + +@pytest.mark.parametrize("client_class", [ + CertificateAuthorityServiceClient, + CertificateAuthorityServiceAsyncClient, +]) +def test_certificate_authority_service_client_from_service_account_file(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: + factory.return_value = creds + client = client_class.from_service_account_file("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'privateca.googleapis.com:443' + + +def test_certificate_authority_service_client_get_transport_class(): + transport = CertificateAuthorityServiceClient.get_transport_class() + available_transports = [ + transports.CertificateAuthorityServiceGrpcTransport, + ] + assert transport in available_transports + + transport = CertificateAuthorityServiceClient.get_transport_class("grpc") + assert transport == transports.CertificateAuthorityServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc"), + (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(CertificateAuthorityServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceClient)) +@mock.patch.object(CertificateAuthorityServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceAsyncClient)) +def test_certificate_authority_service_client_client_options(client_class, transport_class, transport_name): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(CertificateAuthorityServiceClient, '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(CertificateAuthorityServiceClient, 'get_transport_class') as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc", "true"), + (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc", "false"), + (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(CertificateAuthorityServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceClient)) +@mock.patch.object(CertificateAuthorityServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_certificate_authority_service_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc"), + (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_certificate_authority_service_client_client_options_scopes(client_class, transport_class, transport_name): + # Check the case scopes are provided. + options = client_options.ClientOptions( + scopes=["1", "2"], + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc"), + (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_certificate_authority_service_client_client_options_credentials_file(client_class, transport_class, transport_name): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_certificate_authority_service_client_client_options_from_dict(): + with mock.patch('google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = CertificateAuthorityServiceClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_create_certificate(transport: str = 'grpc', request_type=service.CreateCertificateRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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 = resources.Certificate( + name='name_value', + issuer_certificate_authority='issuer_certificate_authority_value', + certificate_template='certificate_template_value', + subject_mode=resources.SubjectRequestMode.DEFAULT, + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + pem_csr='pem_csr_value', + ) + 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] == service.CreateCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' + assert response.certificate_template == 'certificate_template_value' + assert response.subject_mode == resources.SubjectRequestMode.DEFAULT + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +def test_create_certificate_from_dict(): + test_create_certificate(request_type=dict) + + +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 = CertificateAuthorityServiceClient( + 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] == service.CreateCertificateRequest() + + +@pytest.mark.asyncio +async def test_create_certificate_async(transport: str = 'grpc_asyncio', request_type=service.CreateCertificateRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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(resources.Certificate( + name='name_value', + issuer_certificate_authority='issuer_certificate_authority_value', + certificate_template='certificate_template_value', + subject_mode=resources.SubjectRequestMode.DEFAULT, + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + )) + 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] == service.CreateCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' + assert response.certificate_template == 'certificate_template_value' + assert response.subject_mode == resources.SubjectRequestMode.DEFAULT + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +@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 = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.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 = resources.Certificate() + 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 = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.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(resources.Certificate()) + 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 = CertificateAuthorityServiceClient( + 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 = resources.Certificate() + # 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=resources.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] + assert args[0].parent == 'parent_value' + assert args[0].certificate == resources.Certificate(name='name_value') + assert args[0].certificate_id == 'certificate_id_value' + + +def test_create_certificate_flattened_error(): + client = CertificateAuthorityServiceClient( + 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( + service.CreateCertificateRequest(), + parent='parent_value', + certificate=resources.Certificate(name='name_value'), + certificate_id='certificate_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_certificate_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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 = resources.Certificate() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) + # 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=resources.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] + assert args[0].parent == 'parent_value' + assert args[0].certificate == resources.Certificate(name='name_value') + assert args[0].certificate_id == 'certificate_id_value' + + +@pytest.mark.asyncio +async def test_create_certificate_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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( + service.CreateCertificateRequest(), + parent='parent_value', + certificate=resources.Certificate(name='name_value'), + certificate_id='certificate_id_value', + ) + + +def test_get_certificate(transport: str = 'grpc', request_type=service.GetCertificateRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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 = resources.Certificate( + name='name_value', + issuer_certificate_authority='issuer_certificate_authority_value', + certificate_template='certificate_template_value', + subject_mode=resources.SubjectRequestMode.DEFAULT, + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + pem_csr='pem_csr_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] == service.GetCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' + assert response.certificate_template == 'certificate_template_value' + assert response.subject_mode == resources.SubjectRequestMode.DEFAULT + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +def test_get_certificate_from_dict(): + test_get_certificate(request_type=dict) + + +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 = CertificateAuthorityServiceClient( + 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] == service.GetCertificateRequest() + + +@pytest.mark.asyncio +async def test_get_certificate_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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(resources.Certificate( + name='name_value', + issuer_certificate_authority='issuer_certificate_authority_value', + certificate_template='certificate_template_value', + subject_mode=resources.SubjectRequestMode.DEFAULT, + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + )) + 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] == service.GetCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' + assert response.certificate_template == 'certificate_template_value' + assert response.subject_mode == resources.SubjectRequestMode.DEFAULT + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +@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 = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.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 = resources.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 = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.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(resources.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 = CertificateAuthorityServiceClient( + 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 = resources.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] + assert args[0].name == 'name_value' + + +def test_get_certificate_flattened_error(): + client = CertificateAuthorityServiceClient( + 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( + service.GetCertificateRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_certificate_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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 = resources.Certificate() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.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] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_certificate_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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( + service.GetCertificateRequest(), + name='name_value', + ) + + +def test_list_certificates(transport: str = 'grpc', request_type=service.ListCertificatesRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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 = service.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] == service.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_from_dict(): + test_list_certificates(request_type=dict) + + +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 = CertificateAuthorityServiceClient( + 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] == service.ListCertificatesRequest() + + +@pytest.mark.asyncio +async def test_list_certificates_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificatesRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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(service.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] == service.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 = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.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 = service.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 = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.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(service.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 = CertificateAuthorityServiceClient( + 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 = service.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] + assert args[0].parent == 'parent_value' + + +def test_list_certificates_flattened_error(): + client = CertificateAuthorityServiceClient( + 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( + service.ListCertificatesRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_certificates_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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 = service.ListCertificatesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.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] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_certificates_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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( + service.ListCertificatesRequest(), + parent='parent_value', + ) + + +def test_list_certificates_pager(): + client = CertificateAuthorityServiceClient( + 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: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + resources.Certificate(), + ], + next_page_token='abc', + ), + service.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + ], + next_page_token='ghi', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_certificates(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.Certificate) + for i in results) + +def test_list_certificates_pages(): + client = CertificateAuthorityServiceClient( + 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: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + resources.Certificate(), + ], + next_page_token='abc', + ), + service.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + ], + next_page_token='ghi', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.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 = CertificateAuthorityServiceAsyncClient( + 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 = ( + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + resources.Certificate(), + ], + next_page_token='abc', + ), + service.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + ], + next_page_token='ghi', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_certificates(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.Certificate) + for i in responses) + +@pytest.mark.asyncio +async def test_list_certificates_async_pages(): + client = CertificateAuthorityServiceAsyncClient( + 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 = ( + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + resources.Certificate(), + ], + next_page_token='abc', + ), + service.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + ], + next_page_token='ghi', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_certificates(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_revoke_certificate(transport: str = 'grpc', request_type=service.RevokeCertificateRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.revoke_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Certificate( + name='name_value', + issuer_certificate_authority='issuer_certificate_authority_value', + certificate_template='certificate_template_value', + subject_mode=resources.SubjectRequestMode.DEFAULT, + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + pem_csr='pem_csr_value', + ) + response = client.revoke_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] == service.RevokeCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' + assert response.certificate_template == 'certificate_template_value' + assert response.subject_mode == resources.SubjectRequestMode.DEFAULT + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +def test_revoke_certificate_from_dict(): + test_revoke_certificate(request_type=dict) + + +def test_revoke_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 = CertificateAuthorityServiceClient( + 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.revoke_certificate), + '__call__') as call: + client.revoke_certificate() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.RevokeCertificateRequest() + + +@pytest.mark.asyncio +async def test_revoke_certificate_async(transport: str = 'grpc_asyncio', request_type=service.RevokeCertificateRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.revoke_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate( + name='name_value', + issuer_certificate_authority='issuer_certificate_authority_value', + certificate_template='certificate_template_value', + subject_mode=resources.SubjectRequestMode.DEFAULT, + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + )) + response = await client.revoke_certificate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.RevokeCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' + assert response.certificate_template == 'certificate_template_value' + assert response.subject_mode == resources.SubjectRequestMode.DEFAULT + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +@pytest.mark.asyncio +async def test_revoke_certificate_async_from_dict(): + await test_revoke_certificate_async(request_type=dict) + + +def test_revoke_certificate_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.RevokeCertificateRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.revoke_certificate), + '__call__') as call: + call.return_value = resources.Certificate() + client.revoke_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_revoke_certificate_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.RevokeCertificateRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.revoke_certificate), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) + await client.revoke_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_revoke_certificate_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.revoke_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Certificate() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.revoke_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] + assert args[0].name == 'name_value' + + +def test_revoke_certificate_flattened_error(): + client = CertificateAuthorityServiceClient( + 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.revoke_certificate( + service.RevokeCertificateRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_revoke_certificate_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.revoke_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Certificate() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.revoke_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] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_revoke_certificate_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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.revoke_certificate( + service.RevokeCertificateRequest(), + name='name_value', + ) + + +def test_update_certificate(transport: str = 'grpc', request_type=service.UpdateCertificateRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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 = resources.Certificate( + name='name_value', + issuer_certificate_authority='issuer_certificate_authority_value', + certificate_template='certificate_template_value', + subject_mode=resources.SubjectRequestMode.DEFAULT, + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + pem_csr='pem_csr_value', + ) + 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] == service.UpdateCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' + assert response.certificate_template == 'certificate_template_value' + assert response.subject_mode == resources.SubjectRequestMode.DEFAULT + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +def test_update_certificate_from_dict(): + test_update_certificate(request_type=dict) + + +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 = CertificateAuthorityServiceClient( + 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] == service.UpdateCertificateRequest() + + +@pytest.mark.asyncio +async def test_update_certificate_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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(resources.Certificate( + name='name_value', + issuer_certificate_authority='issuer_certificate_authority_value', + certificate_template='certificate_template_value', + subject_mode=resources.SubjectRequestMode.DEFAULT, + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + )) + 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] == service.UpdateCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' + assert response.certificate_template == 'certificate_template_value' + assert response.subject_mode == resources.SubjectRequestMode.DEFAULT + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +@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 = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateRequest() + + request.certificate.name = 'certificate.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 = resources.Certificate() + 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=certificate.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_certificate_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateRequest() + + request.certificate.name = 'certificate.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(resources.Certificate()) + 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=certificate.name/value', + ) in kw['metadata'] + + +def test_update_certificate_flattened(): + client = CertificateAuthorityServiceClient( + 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 = resources.Certificate() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_certificate( + certificate=resources.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] + assert args[0].certificate == resources.Certificate(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_certificate_flattened_error(): + client = CertificateAuthorityServiceClient( + 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( + service.UpdateCertificateRequest(), + certificate=resources.Certificate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_certificate_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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 = resources.Certificate() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_certificate( + certificate=resources.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] + assert args[0].certificate == resources.Certificate(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_certificate_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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( + service.UpdateCertificateRequest(), + certificate=resources.Certificate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_activate_certificate_authority(transport: str = 'grpc', request_type=service.ActivateCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.activate_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.ActivateCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_activate_certificate_authority_from_dict(): + test_activate_certificate_authority(request_type=dict) + + +def test_activate_certificate_authority_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 = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + client.activate_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ActivateCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_activate_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.ActivateCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.activate_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ActivateCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_activate_certificate_authority_async_from_dict(): + await test_activate_certificate_authority_async(request_type=dict) + + +def test_activate_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ActivateCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.activate_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_activate_certificate_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ActivateCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.activate_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +def test_activate_certificate_authority_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.activate_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_activate_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.activate_certificate_authority( + service.ActivateCertificateAuthorityRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_activate_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.activate_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_activate_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.activate_certificate_authority( + service.ActivateCertificateAuthorityRequest(), + name='name_value', + ) + + +def test_create_certificate_authority(transport: str = 'grpc', request_type=service.CreateCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_certificate_authority_from_dict(): + test_create_certificate_authority(request_type=dict) + + +def test_create_certificate_authority_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 = CertificateAuthorityServiceClient( + 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_authority), + '__call__') as call: + client.create_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_create_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.CreateCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__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_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_certificate_authority_async_from_dict(): + await test_create_certificate_authority_async(request_type=dict) + + +def test_create_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateCertificateAuthorityRequest() + + 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_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_certificate_authority(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_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateCertificateAuthorityRequest() + + 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_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_certificate_authority(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_authority_flattened(): + client = CertificateAuthorityServiceClient( + 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_authority), + '__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_authority( + parent='parent_value', + certificate_authority=resources.CertificateAuthority(name='name_value'), + certificate_authority_id='certificate_authority_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') + assert args[0].certificate_authority_id == 'certificate_authority_id_value' + + +def test_create_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_authority( + service.CreateCertificateAuthorityRequest(), + parent='parent_value', + certificate_authority=resources.CertificateAuthority(name='name_value'), + certificate_authority_id='certificate_authority_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority), + '__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_authority( + parent='parent_value', + certificate_authority=resources.CertificateAuthority(name='name_value'), + certificate_authority_id='certificate_authority_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') + assert args[0].certificate_authority_id == 'certificate_authority_id_value' + + +@pytest.mark.asyncio +async def test_create_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority( + service.CreateCertificateAuthorityRequest(), + parent='parent_value', + certificate_authority=resources.CertificateAuthority(name='name_value'), + certificate_authority_id='certificate_authority_id_value', + ) + + +def test_disable_certificate_authority(transport: str = 'grpc', request_type=service.DisableCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.disable_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.disable_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.DisableCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_disable_certificate_authority_from_dict(): + test_disable_certificate_authority(request_type=dict) + + +def test_disable_certificate_authority_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 = CertificateAuthorityServiceClient( + 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.disable_certificate_authority), + '__call__') as call: + client.disable_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.DisableCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_disable_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.DisableCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.disable_certificate_authority), + '__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.disable_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.DisableCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_disable_certificate_authority_async_from_dict(): + await test_disable_certificate_authority_async(request_type=dict) + + +def test_disable_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DisableCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.disable_certificate_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.disable_certificate_authority(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_disable_certificate_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DisableCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.disable_certificate_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.disable_certificate_authority(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_disable_certificate_authority_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.disable_certificate_authority), + '__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.disable_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_disable_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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.disable_certificate_authority( + service.DisableCertificateAuthorityRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_disable_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.disable_certificate_authority), + '__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.disable_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_disable_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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.disable_certificate_authority( + service.DisableCertificateAuthorityRequest(), + name='name_value', + ) + + +def test_enable_certificate_authority(transport: str = 'grpc', request_type=service.EnableCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.enable_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.enable_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.EnableCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_enable_certificate_authority_from_dict(): + test_enable_certificate_authority(request_type=dict) + + +def test_enable_certificate_authority_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 = CertificateAuthorityServiceClient( + 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.enable_certificate_authority), + '__call__') as call: + client.enable_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.EnableCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_enable_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.EnableCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.enable_certificate_authority), + '__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.enable_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.EnableCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_enable_certificate_authority_async_from_dict(): + await test_enable_certificate_authority_async(request_type=dict) + + +def test_enable_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.EnableCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.enable_certificate_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.enable_certificate_authority(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_enable_certificate_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.EnableCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.enable_certificate_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.enable_certificate_authority(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_enable_certificate_authority_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.enable_certificate_authority), + '__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.enable_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_enable_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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.enable_certificate_authority( + service.EnableCertificateAuthorityRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_enable_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.enable_certificate_authority), + '__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.enable_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_enable_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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.enable_certificate_authority( + service.EnableCertificateAuthorityRequest(), + name='name_value', + ) + + +def test_fetch_certificate_authority_csr(transport: str = 'grpc', request_type=service.FetchCertificateAuthorityCsrRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.fetch_certificate_authority_csr), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.FetchCertificateAuthorityCsrResponse( + pem_csr='pem_csr_value', + ) + response = client.fetch_certificate_authority_csr(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.FetchCertificateAuthorityCsrRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.FetchCertificateAuthorityCsrResponse) + assert response.pem_csr == 'pem_csr_value' + + +def test_fetch_certificate_authority_csr_from_dict(): + test_fetch_certificate_authority_csr(request_type=dict) + + +def test_fetch_certificate_authority_csr_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 = CertificateAuthorityServiceClient( + 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.fetch_certificate_authority_csr), + '__call__') as call: + client.fetch_certificate_authority_csr() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.FetchCertificateAuthorityCsrRequest() + + +@pytest.mark.asyncio +async def test_fetch_certificate_authority_csr_async(transport: str = 'grpc_asyncio', request_type=service.FetchCertificateAuthorityCsrRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.fetch_certificate_authority_csr), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCertificateAuthorityCsrResponse( + pem_csr='pem_csr_value', + )) + response = await client.fetch_certificate_authority_csr(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.FetchCertificateAuthorityCsrRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.FetchCertificateAuthorityCsrResponse) + assert response.pem_csr == 'pem_csr_value' + + +@pytest.mark.asyncio +async def test_fetch_certificate_authority_csr_async_from_dict(): + await test_fetch_certificate_authority_csr_async(request_type=dict) + + +def test_fetch_certificate_authority_csr_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.FetchCertificateAuthorityCsrRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_certificate_authority_csr), + '__call__') as call: + call.return_value = service.FetchCertificateAuthorityCsrResponse() + client.fetch_certificate_authority_csr(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_fetch_certificate_authority_csr_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.FetchCertificateAuthorityCsrRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_certificate_authority_csr), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCertificateAuthorityCsrResponse()) + await client.fetch_certificate_authority_csr(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_fetch_certificate_authority_csr_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_certificate_authority_csr), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.FetchCertificateAuthorityCsrResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.fetch_certificate_authority_csr( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_fetch_certificate_authority_csr_flattened_error(): + client = CertificateAuthorityServiceClient( + 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.fetch_certificate_authority_csr( + service.FetchCertificateAuthorityCsrRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_fetch_certificate_authority_csr_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_certificate_authority_csr), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.FetchCertificateAuthorityCsrResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCertificateAuthorityCsrResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.fetch_certificate_authority_csr( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_fetch_certificate_authority_csr_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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.fetch_certificate_authority_csr( + service.FetchCertificateAuthorityCsrRequest(), + name='name_value', + ) + + +def test_get_certificate_authority(transport: str = 'grpc', request_type=service.GetCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateAuthority( + name='name_value', + type_=resources.CertificateAuthority.Type.SELF_SIGNED, + tier=resources.CaPool.Tier.ENTERPRISE, + state=resources.CertificateAuthority.State.ENABLED, + pem_ca_certificates=['pem_ca_certificates_value'], + gcs_bucket='gcs_bucket_value', + ) + response = client.get_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CertificateAuthority) + assert response.name == 'name_value' + assert response.type_ == resources.CertificateAuthority.Type.SELF_SIGNED + assert response.tier == resources.CaPool.Tier.ENTERPRISE + assert response.state == resources.CertificateAuthority.State.ENABLED + assert response.pem_ca_certificates == ['pem_ca_certificates_value'] + assert response.gcs_bucket == 'gcs_bucket_value' + + +def test_get_certificate_authority_from_dict(): + test_get_certificate_authority(request_type=dict) + + +def test_get_certificate_authority_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 = CertificateAuthorityServiceClient( + 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_authority), + '__call__') as call: + client.get_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_get_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateAuthority( + name='name_value', + type_=resources.CertificateAuthority.Type.SELF_SIGNED, + tier=resources.CaPool.Tier.ENTERPRISE, + state=resources.CertificateAuthority.State.ENABLED, + pem_ca_certificates=['pem_ca_certificates_value'], + gcs_bucket='gcs_bucket_value', + )) + response = await client.get_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CertificateAuthority) + assert response.name == 'name_value' + assert response.type_ == resources.CertificateAuthority.Type.SELF_SIGNED + assert response.tier == resources.CaPool.Tier.ENTERPRISE + assert response.state == resources.CertificateAuthority.State.ENABLED + assert response.pem_ca_certificates == ['pem_ca_certificates_value'] + assert response.gcs_bucket == 'gcs_bucket_value' + + +@pytest.mark.asyncio +async def test_get_certificate_authority_async_from_dict(): + await test_get_certificate_authority_async(request_type=dict) + + +def test_get_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCertificateAuthorityRequest() + + 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_authority), + '__call__') as call: + call.return_value = resources.CertificateAuthority() + client.get_certificate_authority(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_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCertificateAuthorityRequest() + + 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_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateAuthority()) + await client.get_certificate_authority(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_authority_flattened(): + client = CertificateAuthorityServiceClient( + 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateAuthority() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_authority( + service.GetCertificateAuthorityRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateAuthority() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateAuthority()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority( + service.GetCertificateAuthorityRequest(), + name='name_value', + ) + + +def test_list_certificate_authorities(transport: str = 'grpc', request_type=service.ListCertificateAuthoritiesRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authorities), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateAuthoritiesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_certificate_authorities(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateAuthoritiesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateAuthoritiesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificate_authorities_from_dict(): + test_list_certificate_authorities(request_type=dict) + + +def test_list_certificate_authorities_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 = CertificateAuthorityServiceClient( + 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_authorities), + '__call__') as call: + client.list_certificate_authorities() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateAuthoritiesRequest() + + +@pytest.mark.asyncio +async def test_list_certificate_authorities_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificateAuthoritiesRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authorities), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateAuthoritiesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_certificate_authorities(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateAuthoritiesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateAuthoritiesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_certificate_authorities_async_from_dict(): + await test_list_certificate_authorities_async(request_type=dict) + + +def test_list_certificate_authorities_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCertificateAuthoritiesRequest() + + 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_authorities), + '__call__') as call: + call.return_value = service.ListCertificateAuthoritiesResponse() + client.list_certificate_authorities(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_authorities_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCertificateAuthoritiesRequest() + + 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_authorities), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateAuthoritiesResponse()) + await client.list_certificate_authorities(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_authorities_flattened(): + client = CertificateAuthorityServiceClient( + 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_authorities), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateAuthoritiesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_certificate_authorities( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +def test_list_certificate_authorities_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_authorities( + service.ListCertificateAuthoritiesRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_certificate_authorities_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authorities), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateAuthoritiesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateAuthoritiesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_certificate_authorities( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_certificate_authorities_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authorities( + service.ListCertificateAuthoritiesRequest(), + parent='parent_value', + ) + + +def test_list_certificate_authorities_pager(): + client = CertificateAuthorityServiceClient( + 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_authorities), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + next_page_token='abc', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[], + next_page_token='def', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + ], + next_page_token='ghi', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_certificate_authorities(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.CertificateAuthority) + for i in results) + +def test_list_certificate_authorities_pages(): + client = CertificateAuthorityServiceClient( + 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_authorities), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + next_page_token='abc', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[], + next_page_token='def', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + ], + next_page_token='ghi', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + ), + RuntimeError, + ) + pages = list(client.list_certificate_authorities(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_authorities_async_pager(): + client = CertificateAuthorityServiceAsyncClient( + 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_authorities), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + next_page_token='abc', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[], + next_page_token='def', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + ], + next_page_token='ghi', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_certificate_authorities(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.CertificateAuthority) + for i in responses) + +@pytest.mark.asyncio +async def test_list_certificate_authorities_async_pages(): + client = CertificateAuthorityServiceAsyncClient( + 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_authorities), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + next_page_token='abc', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[], + next_page_token='def', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + ], + next_page_token='ghi', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_certificate_authorities(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_undelete_certificate_authority(transport: str = 'grpc', request_type=service.UndeleteCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.undelete_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.undelete_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.UndeleteCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_undelete_certificate_authority_from_dict(): + test_undelete_certificate_authority(request_type=dict) + + +def test_undelete_certificate_authority_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 = CertificateAuthorityServiceClient( + 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.undelete_certificate_authority), + '__call__') as call: + client.undelete_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UndeleteCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_undelete_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.UndeleteCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.undelete_certificate_authority), + '__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.undelete_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UndeleteCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_undelete_certificate_authority_async_from_dict(): + await test_undelete_certificate_authority_async(request_type=dict) + + +def test_undelete_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UndeleteCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undelete_certificate_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.undelete_certificate_authority(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_undelete_certificate_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UndeleteCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undelete_certificate_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.undelete_certificate_authority(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_undelete_certificate_authority_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undelete_certificate_authority), + '__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.undelete_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_undelete_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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.undelete_certificate_authority( + service.UndeleteCertificateAuthorityRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_undelete_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undelete_certificate_authority), + '__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.undelete_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_undelete_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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.undelete_certificate_authority( + service.UndeleteCertificateAuthorityRequest(), + name='name_value', + ) + + +def test_delete_certificate_authority(transport: str = 'grpc', request_type=service.DeleteCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_certificate_authority_from_dict(): + test_delete_certificate_authority(request_type=dict) + + +def test_delete_certificate_authority_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 = CertificateAuthorityServiceClient( + 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_authority), + '__call__') as call: + client.delete_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_delete_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.DeleteCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__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_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_certificate_authority_async_from_dict(): + await test_delete_certificate_authority_async(request_type=dict) + + +def test_delete_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DeleteCertificateAuthorityRequest() + + 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_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_certificate_authority(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_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DeleteCertificateAuthorityRequest() + + 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_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_certificate_authority(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_authority_flattened(): + client = CertificateAuthorityServiceClient( + 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_authority), + '__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_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_authority( + service.DeleteCertificateAuthorityRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority), + '__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_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority( + service.DeleteCertificateAuthorityRequest(), + name='name_value', + ) + + +def test_update_certificate_authority(transport: str = 'grpc', request_type=service.UpdateCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_certificate_authority_from_dict(): + test_update_certificate_authority(request_type=dict) + + +def test_update_certificate_authority_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 = CertificateAuthorityServiceClient( + 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_authority), + '__call__') as call: + client.update_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_update_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__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_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_certificate_authority_async_from_dict(): + await test_update_certificate_authority_async(request_type=dict) + + +def test_update_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateAuthorityRequest() + + request.certificate_authority.name = 'certificate_authority.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_certificate_authority(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_authority.name=certificate_authority.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_certificate_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateAuthorityRequest() + + request.certificate_authority.name = 'certificate_authority.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_certificate_authority(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_authority.name=certificate_authority.name/value', + ) in kw['metadata'] + + +def test_update_certificate_authority_flattened(): + client = CertificateAuthorityServiceClient( + 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_authority), + '__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_authority( + certificate_authority=resources.CertificateAuthority(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_authority( + service.UpdateCertificateAuthorityRequest(), + certificate_authority=resources.CertificateAuthority(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority), + '__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_authority( + certificate_authority=resources.CertificateAuthority(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority( + service.UpdateCertificateAuthorityRequest(), + certificate_authority=resources.CertificateAuthority(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_create_ca_pool(transport: str = 'grpc', request_type=service.CreateCaPoolRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_ca_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_ca_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCaPoolRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_ca_pool_from_dict(): + test_create_ca_pool(request_type=dict) + + +def test_create_ca_pool_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 = CertificateAuthorityServiceClient( + 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_ca_pool), + '__call__') as call: + client.create_ca_pool() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCaPoolRequest() + + +@pytest.mark.asyncio +async def test_create_ca_pool_async(transport: str = 'grpc_asyncio', request_type=service.CreateCaPoolRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_ca_pool), + '__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_ca_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCaPoolRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_ca_pool_async_from_dict(): + await test_create_ca_pool_async(request_type=dict) + + +def test_create_ca_pool_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateCaPoolRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ca_pool), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_ca_pool(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_ca_pool_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateCaPoolRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ca_pool), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_ca_pool(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_ca_pool_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ca_pool), + '__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_ca_pool( + parent='parent_value', + ca_pool=resources.CaPool(name='name_value'), + ca_pool_id='ca_pool_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].ca_pool == resources.CaPool(name='name_value') + assert args[0].ca_pool_id == 'ca_pool_id_value' + + +def test_create_ca_pool_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_ca_pool( + service.CreateCaPoolRequest(), + parent='parent_value', + ca_pool=resources.CaPool(name='name_value'), + ca_pool_id='ca_pool_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_ca_pool_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_ca_pool), + '__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_ca_pool( + parent='parent_value', + ca_pool=resources.CaPool(name='name_value'), + ca_pool_id='ca_pool_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].ca_pool == resources.CaPool(name='name_value') + assert args[0].ca_pool_id == 'ca_pool_id_value' + + +@pytest.mark.asyncio +async def test_create_ca_pool_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_ca_pool( + service.CreateCaPoolRequest(), + parent='parent_value', + ca_pool=resources.CaPool(name='name_value'), + ca_pool_id='ca_pool_id_value', + ) + + +def test_update_ca_pool(transport: str = 'grpc', request_type=service.UpdateCaPoolRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_ca_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_ca_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCaPoolRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_ca_pool_from_dict(): + test_update_ca_pool(request_type=dict) + + +def test_update_ca_pool_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 = CertificateAuthorityServiceClient( + 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_ca_pool), + '__call__') as call: + client.update_ca_pool() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCaPoolRequest() + + +@pytest.mark.asyncio +async def test_update_ca_pool_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCaPoolRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_ca_pool), + '__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_ca_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCaPoolRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_ca_pool_async_from_dict(): + await test_update_ca_pool_async(request_type=dict) + + +def test_update_ca_pool_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCaPoolRequest() + + request.ca_pool.name = 'ca_pool.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_ca_pool), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_ca_pool(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', + 'ca_pool.name=ca_pool.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_ca_pool_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCaPoolRequest() + + request.ca_pool.name = 'ca_pool.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_ca_pool), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_ca_pool(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', + 'ca_pool.name=ca_pool.name/value', + ) in kw['metadata'] + + +def test_update_ca_pool_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_ca_pool), + '__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_ca_pool( + ca_pool=resources.CaPool(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].ca_pool == resources.CaPool(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_ca_pool_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_ca_pool( + service.UpdateCaPoolRequest(), + ca_pool=resources.CaPool(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_ca_pool_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_ca_pool), + '__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_ca_pool( + ca_pool=resources.CaPool(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].ca_pool == resources.CaPool(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_ca_pool_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_ca_pool( + service.UpdateCaPoolRequest(), + ca_pool=resources.CaPool(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_get_ca_pool(transport: str = 'grpc', request_type=service.GetCaPoolRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_ca_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CaPool( + name='name_value', + tier=resources.CaPool.Tier.ENTERPRISE, + ) + response = client.get_ca_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCaPoolRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CaPool) + assert response.name == 'name_value' + assert response.tier == resources.CaPool.Tier.ENTERPRISE + + +def test_get_ca_pool_from_dict(): + test_get_ca_pool(request_type=dict) + + +def test_get_ca_pool_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 = CertificateAuthorityServiceClient( + 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_ca_pool), + '__call__') as call: + client.get_ca_pool() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCaPoolRequest() + + +@pytest.mark.asyncio +async def test_get_ca_pool_async(transport: str = 'grpc_asyncio', request_type=service.GetCaPoolRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_ca_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CaPool( + name='name_value', + tier=resources.CaPool.Tier.ENTERPRISE, + )) + response = await client.get_ca_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCaPoolRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CaPool) + assert response.name == 'name_value' + assert response.tier == resources.CaPool.Tier.ENTERPRISE + + +@pytest.mark.asyncio +async def test_get_ca_pool_async_from_dict(): + await test_get_ca_pool_async(request_type=dict) + + +def test_get_ca_pool_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCaPoolRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_ca_pool), + '__call__') as call: + call.return_value = resources.CaPool() + client.get_ca_pool(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_ca_pool_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCaPoolRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_ca_pool), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CaPool()) + await client.get_ca_pool(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_ca_pool_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_ca_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CaPool() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_ca_pool( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_ca_pool_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_ca_pool( + service.GetCaPoolRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_ca_pool_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_ca_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CaPool() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CaPool()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_ca_pool( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_ca_pool_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_ca_pool( + service.GetCaPoolRequest(), + name='name_value', + ) + + +def test_list_ca_pools(transport: str = 'grpc', request_type=service.ListCaPoolsRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_ca_pools), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCaPoolsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_ca_pools(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCaPoolsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCaPoolsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_ca_pools_from_dict(): + test_list_ca_pools(request_type=dict) + + +def test_list_ca_pools_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 = CertificateAuthorityServiceClient( + 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_ca_pools), + '__call__') as call: + client.list_ca_pools() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCaPoolsRequest() + + +@pytest.mark.asyncio +async def test_list_ca_pools_async(transport: str = 'grpc_asyncio', request_type=service.ListCaPoolsRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_ca_pools), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCaPoolsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_ca_pools(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCaPoolsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCaPoolsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_ca_pools_async_from_dict(): + await test_list_ca_pools_async(request_type=dict) + + +def test_list_ca_pools_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCaPoolsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ca_pools), + '__call__') as call: + call.return_value = service.ListCaPoolsResponse() + client.list_ca_pools(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_ca_pools_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCaPoolsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ca_pools), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCaPoolsResponse()) + await client.list_ca_pools(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_ca_pools_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ca_pools), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCaPoolsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_ca_pools( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +def test_list_ca_pools_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_ca_pools( + service.ListCaPoolsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_ca_pools_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ca_pools), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCaPoolsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCaPoolsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_ca_pools( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_ca_pools_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_ca_pools( + service.ListCaPoolsRequest(), + parent='parent_value', + ) + + +def test_list_ca_pools_pager(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ca_pools), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCaPoolsResponse( + ca_pools=[ + resources.CaPool(), + resources.CaPool(), + resources.CaPool(), + ], + next_page_token='abc', + ), + service.ListCaPoolsResponse( + ca_pools=[], + next_page_token='def', + ), + service.ListCaPoolsResponse( + ca_pools=[ + resources.CaPool(), + ], + next_page_token='ghi', + ), + service.ListCaPoolsResponse( + ca_pools=[ + resources.CaPool(), + resources.CaPool(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_ca_pools(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.CaPool) + for i in results) + +def test_list_ca_pools_pages(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ca_pools), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCaPoolsResponse( + ca_pools=[ + resources.CaPool(), + resources.CaPool(), + resources.CaPool(), + ], + next_page_token='abc', + ), + service.ListCaPoolsResponse( + ca_pools=[], + next_page_token='def', + ), + service.ListCaPoolsResponse( + ca_pools=[ + resources.CaPool(), + ], + next_page_token='ghi', + ), + service.ListCaPoolsResponse( + ca_pools=[ + resources.CaPool(), + resources.CaPool(), + ], + ), + RuntimeError, + ) + pages = list(client.list_ca_pools(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_ca_pools_async_pager(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ca_pools), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCaPoolsResponse( + ca_pools=[ + resources.CaPool(), + resources.CaPool(), + resources.CaPool(), + ], + next_page_token='abc', + ), + service.ListCaPoolsResponse( + ca_pools=[], + next_page_token='def', + ), + service.ListCaPoolsResponse( + ca_pools=[ + resources.CaPool(), + ], + next_page_token='ghi', + ), + service.ListCaPoolsResponse( + ca_pools=[ + resources.CaPool(), + resources.CaPool(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_ca_pools(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.CaPool) + for i in responses) + +@pytest.mark.asyncio +async def test_list_ca_pools_async_pages(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_ca_pools), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCaPoolsResponse( + ca_pools=[ + resources.CaPool(), + resources.CaPool(), + resources.CaPool(), + ], + next_page_token='abc', + ), + service.ListCaPoolsResponse( + ca_pools=[], + next_page_token='def', + ), + service.ListCaPoolsResponse( + ca_pools=[ + resources.CaPool(), + ], + next_page_token='ghi', + ), + service.ListCaPoolsResponse( + ca_pools=[ + resources.CaPool(), + resources.CaPool(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_ca_pools(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_delete_ca_pool(transport: str = 'grpc', request_type=service.DeleteCaPoolRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_ca_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_ca_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteCaPoolRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_ca_pool_from_dict(): + test_delete_ca_pool(request_type=dict) + + +def test_delete_ca_pool_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 = CertificateAuthorityServiceClient( + 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_ca_pool), + '__call__') as call: + client.delete_ca_pool() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteCaPoolRequest() + + +@pytest.mark.asyncio +async def test_delete_ca_pool_async(transport: str = 'grpc_asyncio', request_type=service.DeleteCaPoolRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_ca_pool), + '__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_ca_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteCaPoolRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_ca_pool_async_from_dict(): + await test_delete_ca_pool_async(request_type=dict) + + +def test_delete_ca_pool_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DeleteCaPoolRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ca_pool), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_ca_pool(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_ca_pool_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DeleteCaPoolRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ca_pool), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_ca_pool(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_ca_pool_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ca_pool), + '__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_ca_pool( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_ca_pool_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_ca_pool( + service.DeleteCaPoolRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_ca_pool_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_ca_pool), + '__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_ca_pool( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_ca_pool_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_ca_pool( + service.DeleteCaPoolRequest(), + name='name_value', + ) + + +def test_fetch_ca_certs(transport: str = 'grpc', request_type=service.FetchCaCertsRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.fetch_ca_certs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.FetchCaCertsResponse( + ) + response = client.fetch_ca_certs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.FetchCaCertsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.FetchCaCertsResponse) + + +def test_fetch_ca_certs_from_dict(): + test_fetch_ca_certs(request_type=dict) + + +def test_fetch_ca_certs_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 = CertificateAuthorityServiceClient( + 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.fetch_ca_certs), + '__call__') as call: + client.fetch_ca_certs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.FetchCaCertsRequest() + + +@pytest.mark.asyncio +async def test_fetch_ca_certs_async(transport: str = 'grpc_asyncio', request_type=service.FetchCaCertsRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.fetch_ca_certs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCaCertsResponse( + )) + response = await client.fetch_ca_certs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.FetchCaCertsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.FetchCaCertsResponse) + + +@pytest.mark.asyncio +async def test_fetch_ca_certs_async_from_dict(): + await test_fetch_ca_certs_async(request_type=dict) + + +def test_fetch_ca_certs_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.FetchCaCertsRequest() + + request.ca_pool = 'ca_pool/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_ca_certs), + '__call__') as call: + call.return_value = service.FetchCaCertsResponse() + client.fetch_ca_certs(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', + 'ca_pool=ca_pool/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_fetch_ca_certs_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.FetchCaCertsRequest() + + request.ca_pool = 'ca_pool/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_ca_certs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCaCertsResponse()) + await client.fetch_ca_certs(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', + 'ca_pool=ca_pool/value', + ) in kw['metadata'] + + +def test_fetch_ca_certs_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_ca_certs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.FetchCaCertsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.fetch_ca_certs( + ca_pool='ca_pool_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].ca_pool == 'ca_pool_value' + + +def test_fetch_ca_certs_flattened_error(): + client = CertificateAuthorityServiceClient( + 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.fetch_ca_certs( + service.FetchCaCertsRequest(), + ca_pool='ca_pool_value', + ) + + +@pytest.mark.asyncio +async def test_fetch_ca_certs_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_ca_certs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.FetchCaCertsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCaCertsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.fetch_ca_certs( + ca_pool='ca_pool_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].ca_pool == 'ca_pool_value' + + +@pytest.mark.asyncio +async def test_fetch_ca_certs_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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.fetch_ca_certs( + service.FetchCaCertsRequest(), + ca_pool='ca_pool_value', + ) + + +def test_get_certificate_revocation_list(transport: str = 'grpc', request_type=service.GetCertificateRevocationListRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_revocation_list), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateRevocationList( + name='name_value', + sequence_number=1601, + pem_crl='pem_crl_value', + access_url='access_url_value', + state=resources.CertificateRevocationList.State.ACTIVE, + revision_id='revision_id_value', + ) + response = client.get_certificate_revocation_list(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateRevocationListRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CertificateRevocationList) + assert response.name == 'name_value' + assert response.sequence_number == 1601 + assert response.pem_crl == 'pem_crl_value' + assert response.access_url == 'access_url_value' + assert response.state == resources.CertificateRevocationList.State.ACTIVE + assert response.revision_id == 'revision_id_value' + + +def test_get_certificate_revocation_list_from_dict(): + test_get_certificate_revocation_list(request_type=dict) + + +def test_get_certificate_revocation_list_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 = CertificateAuthorityServiceClient( + 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_revocation_list), + '__call__') as call: + client.get_certificate_revocation_list() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateRevocationListRequest() + + +@pytest.mark.asyncio +async def test_get_certificate_revocation_list_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateRevocationListRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_revocation_list), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateRevocationList( + name='name_value', + sequence_number=1601, + pem_crl='pem_crl_value', + access_url='access_url_value', + state=resources.CertificateRevocationList.State.ACTIVE, + revision_id='revision_id_value', + )) + response = await client.get_certificate_revocation_list(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateRevocationListRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CertificateRevocationList) + assert response.name == 'name_value' + assert response.sequence_number == 1601 + assert response.pem_crl == 'pem_crl_value' + assert response.access_url == 'access_url_value' + assert response.state == resources.CertificateRevocationList.State.ACTIVE + assert response.revision_id == 'revision_id_value' + + +@pytest.mark.asyncio +async def test_get_certificate_revocation_list_async_from_dict(): + await test_get_certificate_revocation_list_async(request_type=dict) + + +def test_get_certificate_revocation_list_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCertificateRevocationListRequest() + + 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_revocation_list), + '__call__') as call: + call.return_value = resources.CertificateRevocationList() + client.get_certificate_revocation_list(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_revocation_list_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCertificateRevocationListRequest() + + 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_revocation_list), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateRevocationList()) + await client.get_certificate_revocation_list(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_revocation_list_flattened(): + client = CertificateAuthorityServiceClient( + 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_revocation_list), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateRevocationList() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_certificate_revocation_list( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_certificate_revocation_list_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_revocation_list( + service.GetCertificateRevocationListRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_certificate_revocation_list_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_list), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateRevocationList() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateRevocationList()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_certificate_revocation_list( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_certificate_revocation_list_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_list( + service.GetCertificateRevocationListRequest(), + name='name_value', + ) + + +def test_list_certificate_revocation_lists(transport: str = 'grpc', request_type=service.ListCertificateRevocationListsRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_revocation_lists), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateRevocationListsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_certificate_revocation_lists(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateRevocationListsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateRevocationListsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificate_revocation_lists_from_dict(): + test_list_certificate_revocation_lists(request_type=dict) + + +def test_list_certificate_revocation_lists_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 = CertificateAuthorityServiceClient( + 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_revocation_lists), + '__call__') as call: + client.list_certificate_revocation_lists() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateRevocationListsRequest() + + +@pytest.mark.asyncio +async def test_list_certificate_revocation_lists_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificateRevocationListsRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_revocation_lists), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateRevocationListsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_certificate_revocation_lists(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateRevocationListsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateRevocationListsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_certificate_revocation_lists_async_from_dict(): + await test_list_certificate_revocation_lists_async(request_type=dict) + + +def test_list_certificate_revocation_lists_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCertificateRevocationListsRequest() + + 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_revocation_lists), + '__call__') as call: + call.return_value = service.ListCertificateRevocationListsResponse() + client.list_certificate_revocation_lists(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_revocation_lists_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCertificateRevocationListsRequest() + + 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_revocation_lists), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateRevocationListsResponse()) + await client.list_certificate_revocation_lists(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_revocation_lists_flattened(): + client = CertificateAuthorityServiceClient( + 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_revocation_lists), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateRevocationListsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_certificate_revocation_lists( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +def test_list_certificate_revocation_lists_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_revocation_lists( + service.ListCertificateRevocationListsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_certificate_revocation_lists_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_lists), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateRevocationListsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateRevocationListsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_certificate_revocation_lists( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_certificate_revocation_lists_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_lists( + service.ListCertificateRevocationListsRequest(), + parent='parent_value', + ) + + +def test_list_certificate_revocation_lists_pager(): + client = CertificateAuthorityServiceClient( + 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_revocation_lists), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + next_page_token='abc', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[], + next_page_token='def', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + ], + next_page_token='ghi', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_certificate_revocation_lists(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.CertificateRevocationList) + for i in results) + +def test_list_certificate_revocation_lists_pages(): + client = CertificateAuthorityServiceClient( + 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_revocation_lists), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + next_page_token='abc', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[], + next_page_token='def', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + ], + next_page_token='ghi', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + ), + RuntimeError, + ) + pages = list(client.list_certificate_revocation_lists(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_revocation_lists_async_pager(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_lists), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + next_page_token='abc', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[], + next_page_token='def', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + ], + next_page_token='ghi', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_certificate_revocation_lists(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.CertificateRevocationList) + for i in responses) + +@pytest.mark.asyncio +async def test_list_certificate_revocation_lists_async_pages(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_lists), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + next_page_token='abc', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[], + next_page_token='def', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + ], + next_page_token='ghi', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_certificate_revocation_lists(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_update_certificate_revocation_list(transport: str = 'grpc', request_type=service.UpdateCertificateRevocationListRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_revocation_list), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_certificate_revocation_list(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateRevocationListRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_certificate_revocation_list_from_dict(): + test_update_certificate_revocation_list(request_type=dict) + + +def test_update_certificate_revocation_list_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 = CertificateAuthorityServiceClient( + 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_revocation_list), + '__call__') as call: + client.update_certificate_revocation_list() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateRevocationListRequest() + + +@pytest.mark.asyncio +async def test_update_certificate_revocation_list_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateRevocationListRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_revocation_list), + '__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_revocation_list(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateRevocationListRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_certificate_revocation_list_async_from_dict(): + await test_update_certificate_revocation_list_async(request_type=dict) + + +def test_update_certificate_revocation_list_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateRevocationListRequest() + + request.certificate_revocation_list.name = 'certificate_revocation_list.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_revocation_list), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_certificate_revocation_list(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_revocation_list.name=certificate_revocation_list.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_certificate_revocation_list_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateRevocationListRequest() + + request.certificate_revocation_list.name = 'certificate_revocation_list.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_revocation_list), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_certificate_revocation_list(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_revocation_list.name=certificate_revocation_list.name/value', + ) in kw['metadata'] + + +def test_update_certificate_revocation_list_flattened(): + client = CertificateAuthorityServiceClient( + 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_revocation_list), + '__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_revocation_list( + certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].certificate_revocation_list == resources.CertificateRevocationList(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_certificate_revocation_list_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_revocation_list( + service.UpdateCertificateRevocationListRequest(), + certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_certificate_revocation_list_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_list), + '__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_revocation_list( + certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].certificate_revocation_list == resources.CertificateRevocationList(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_certificate_revocation_list_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_list( + service.UpdateCertificateRevocationListRequest(), + certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_create_certificate_template(transport: str = 'grpc', request_type=service.CreateCertificateTemplateRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_template), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_certificate_template(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCertificateTemplateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_certificate_template_from_dict(): + test_create_certificate_template(request_type=dict) + + +def test_create_certificate_template_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 = CertificateAuthorityServiceClient( + 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_template), + '__call__') as call: + client.create_certificate_template() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCertificateTemplateRequest() + + +@pytest.mark.asyncio +async def test_create_certificate_template_async(transport: str = 'grpc_asyncio', request_type=service.CreateCertificateTemplateRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_template), + '__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_template(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCertificateTemplateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_certificate_template_async_from_dict(): + await test_create_certificate_template_async(request_type=dict) + + +def test_create_certificate_template_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateCertificateTemplateRequest() + + 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_template), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_certificate_template(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_template_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateCertificateTemplateRequest() + + 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_template), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_certificate_template(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_template_flattened(): + client = CertificateAuthorityServiceClient( + 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_template), + '__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_template( + parent='parent_value', + certificate_template=resources.CertificateTemplate(name='name_value'), + certificate_template_id='certificate_template_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].certificate_template == resources.CertificateTemplate(name='name_value') + assert args[0].certificate_template_id == 'certificate_template_id_value' + + +def test_create_certificate_template_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_template( + service.CreateCertificateTemplateRequest(), + parent='parent_value', + certificate_template=resources.CertificateTemplate(name='name_value'), + certificate_template_id='certificate_template_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_certificate_template_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_template), + '__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_template( + parent='parent_value', + certificate_template=resources.CertificateTemplate(name='name_value'), + certificate_template_id='certificate_template_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].certificate_template == resources.CertificateTemplate(name='name_value') + assert args[0].certificate_template_id == 'certificate_template_id_value' + + +@pytest.mark.asyncio +async def test_create_certificate_template_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_template( + service.CreateCertificateTemplateRequest(), + parent='parent_value', + certificate_template=resources.CertificateTemplate(name='name_value'), + certificate_template_id='certificate_template_id_value', + ) + + +def test_delete_certificate_template(transport: str = 'grpc', request_type=service.DeleteCertificateTemplateRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_template), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_certificate_template(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteCertificateTemplateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_certificate_template_from_dict(): + test_delete_certificate_template(request_type=dict) + + +def test_delete_certificate_template_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 = CertificateAuthorityServiceClient( + 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_template), + '__call__') as call: + client.delete_certificate_template() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteCertificateTemplateRequest() + + +@pytest.mark.asyncio +async def test_delete_certificate_template_async(transport: str = 'grpc_asyncio', request_type=service.DeleteCertificateTemplateRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_template), + '__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_template(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteCertificateTemplateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_certificate_template_async_from_dict(): + await test_delete_certificate_template_async(request_type=dict) + + +def test_delete_certificate_template_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DeleteCertificateTemplateRequest() + + 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_template), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_certificate_template(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_template_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DeleteCertificateTemplateRequest() + + 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_template), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_certificate_template(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_template_flattened(): + client = CertificateAuthorityServiceClient( + 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_template), + '__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_template( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_certificate_template_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_template( + service.DeleteCertificateTemplateRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_certificate_template_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_template), + '__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_template( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_certificate_template_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_template( + service.DeleteCertificateTemplateRequest(), + name='name_value', + ) + + +def test_get_certificate_template(transport: str = 'grpc', request_type=service.GetCertificateTemplateRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_template), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateTemplate( + name='name_value', + description='description_value', + ) + response = client.get_certificate_template(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateTemplateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CertificateTemplate) + assert response.name == 'name_value' + assert response.description == 'description_value' + + +def test_get_certificate_template_from_dict(): + test_get_certificate_template(request_type=dict) + + +def test_get_certificate_template_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 = CertificateAuthorityServiceClient( + 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_template), + '__call__') as call: + client.get_certificate_template() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateTemplateRequest() + + +@pytest.mark.asyncio +async def test_get_certificate_template_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateTemplateRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_template), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateTemplate( + name='name_value', + description='description_value', + )) + response = await client.get_certificate_template(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateTemplateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CertificateTemplate) + assert response.name == 'name_value' + assert response.description == 'description_value' + + +@pytest.mark.asyncio +async def test_get_certificate_template_async_from_dict(): + await test_get_certificate_template_async(request_type=dict) + + +def test_get_certificate_template_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCertificateTemplateRequest() + + 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_template), + '__call__') as call: + call.return_value = resources.CertificateTemplate() + client.get_certificate_template(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_template_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCertificateTemplateRequest() + + 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_template), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateTemplate()) + await client.get_certificate_template(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_template_flattened(): + client = CertificateAuthorityServiceClient( + 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_template), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateTemplate() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_certificate_template( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_certificate_template_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_template( + service.GetCertificateTemplateRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_certificate_template_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_template), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateTemplate() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateTemplate()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_certificate_template( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_certificate_template_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_template( + service.GetCertificateTemplateRequest(), + name='name_value', + ) + + +def test_list_certificate_templates(transport: str = 'grpc', request_type=service.ListCertificateTemplatesRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_templates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateTemplatesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_certificate_templates(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateTemplatesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateTemplatesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificate_templates_from_dict(): + test_list_certificate_templates(request_type=dict) + + +def test_list_certificate_templates_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 = CertificateAuthorityServiceClient( + 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_templates), + '__call__') as call: + client.list_certificate_templates() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateTemplatesRequest() + + +@pytest.mark.asyncio +async def test_list_certificate_templates_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificateTemplatesRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_templates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateTemplatesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_certificate_templates(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateTemplatesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateTemplatesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_certificate_templates_async_from_dict(): + await test_list_certificate_templates_async(request_type=dict) + + +def test_list_certificate_templates_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCertificateTemplatesRequest() + + 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_templates), + '__call__') as call: + call.return_value = service.ListCertificateTemplatesResponse() + client.list_certificate_templates(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_templates_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCertificateTemplatesRequest() + + 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_templates), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateTemplatesResponse()) + await client.list_certificate_templates(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_templates_flattened(): + client = CertificateAuthorityServiceClient( + 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_templates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateTemplatesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_certificate_templates( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +def test_list_certificate_templates_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_templates( + service.ListCertificateTemplatesRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_certificate_templates_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_templates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateTemplatesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateTemplatesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_certificate_templates( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_certificate_templates_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_templates( + service.ListCertificateTemplatesRequest(), + parent='parent_value', + ) + + +def test_list_certificate_templates_pager(): + client = CertificateAuthorityServiceClient( + 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_templates), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateTemplatesResponse( + certificate_templates=[ + resources.CertificateTemplate(), + resources.CertificateTemplate(), + resources.CertificateTemplate(), + ], + next_page_token='abc', + ), + service.ListCertificateTemplatesResponse( + certificate_templates=[], + next_page_token='def', + ), + service.ListCertificateTemplatesResponse( + certificate_templates=[ + resources.CertificateTemplate(), + ], + next_page_token='ghi', + ), + service.ListCertificateTemplatesResponse( + certificate_templates=[ + resources.CertificateTemplate(), + resources.CertificateTemplate(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_certificate_templates(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.CertificateTemplate) + for i in results) + +def test_list_certificate_templates_pages(): + client = CertificateAuthorityServiceClient( + 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_templates), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateTemplatesResponse( + certificate_templates=[ + resources.CertificateTemplate(), + resources.CertificateTemplate(), + resources.CertificateTemplate(), + ], + next_page_token='abc', + ), + service.ListCertificateTemplatesResponse( + certificate_templates=[], + next_page_token='def', + ), + service.ListCertificateTemplatesResponse( + certificate_templates=[ + resources.CertificateTemplate(), + ], + next_page_token='ghi', + ), + service.ListCertificateTemplatesResponse( + certificate_templates=[ + resources.CertificateTemplate(), + resources.CertificateTemplate(), + ], + ), + RuntimeError, + ) + pages = list(client.list_certificate_templates(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_templates_async_pager(): + client = CertificateAuthorityServiceAsyncClient( + 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_templates), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateTemplatesResponse( + certificate_templates=[ + resources.CertificateTemplate(), + resources.CertificateTemplate(), + resources.CertificateTemplate(), + ], + next_page_token='abc', + ), + service.ListCertificateTemplatesResponse( + certificate_templates=[], + next_page_token='def', + ), + service.ListCertificateTemplatesResponse( + certificate_templates=[ + resources.CertificateTemplate(), + ], + next_page_token='ghi', + ), + service.ListCertificateTemplatesResponse( + certificate_templates=[ + resources.CertificateTemplate(), + resources.CertificateTemplate(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_certificate_templates(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.CertificateTemplate) + for i in responses) + +@pytest.mark.asyncio +async def test_list_certificate_templates_async_pages(): + client = CertificateAuthorityServiceAsyncClient( + 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_templates), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateTemplatesResponse( + certificate_templates=[ + resources.CertificateTemplate(), + resources.CertificateTemplate(), + resources.CertificateTemplate(), + ], + next_page_token='abc', + ), + service.ListCertificateTemplatesResponse( + certificate_templates=[], + next_page_token='def', + ), + service.ListCertificateTemplatesResponse( + certificate_templates=[ + resources.CertificateTemplate(), + ], + next_page_token='ghi', + ), + service.ListCertificateTemplatesResponse( + certificate_templates=[ + resources.CertificateTemplate(), + resources.CertificateTemplate(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_certificate_templates(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_update_certificate_template(transport: str = 'grpc', request_type=service.UpdateCertificateTemplateRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_template), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_certificate_template(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateTemplateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_certificate_template_from_dict(): + test_update_certificate_template(request_type=dict) + + +def test_update_certificate_template_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 = CertificateAuthorityServiceClient( + 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_template), + '__call__') as call: + client.update_certificate_template() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateTemplateRequest() + + +@pytest.mark.asyncio +async def test_update_certificate_template_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateTemplateRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_template), + '__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_template(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateTemplateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_certificate_template_async_from_dict(): + await test_update_certificate_template_async(request_type=dict) + + +def test_update_certificate_template_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateTemplateRequest() + + request.certificate_template.name = 'certificate_template.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_template), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_certificate_template(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_template.name=certificate_template.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_certificate_template_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateTemplateRequest() + + request.certificate_template.name = 'certificate_template.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_template), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_certificate_template(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_template.name=certificate_template.name/value', + ) in kw['metadata'] + + +def test_update_certificate_template_flattened(): + client = CertificateAuthorityServiceClient( + 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_template), + '__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_template( + certificate_template=resources.CertificateTemplate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].certificate_template == resources.CertificateTemplate(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_certificate_template_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_template( + service.UpdateCertificateTemplateRequest(), + certificate_template=resources.CertificateTemplate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_certificate_template_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_template), + '__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_template( + certificate_template=resources.CertificateTemplate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].certificate_template == resources.CertificateTemplate(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_certificate_template_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_template( + service.UpdateCertificateTemplateRequest(), + certificate_template=resources.CertificateTemplate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.CertificateAuthorityServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.CertificateAuthorityServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CertificateAuthorityServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.CertificateAuthorityServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CertificateAuthorityServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.CertificateAuthorityServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = CertificateAuthorityServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.CertificateAuthorityServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.CertificateAuthorityServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.CertificateAuthorityServiceGrpcTransport, + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, +]) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CertificateAuthorityServiceGrpcTransport, + ) + +def test_certificate_authority_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.CertificateAuthorityServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_certificate_authority_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.CertificateAuthorityServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_certificate', + 'get_certificate', + 'list_certificates', + 'revoke_certificate', + 'update_certificate', + 'activate_certificate_authority', + 'create_certificate_authority', + 'disable_certificate_authority', + 'enable_certificate_authority', + 'fetch_certificate_authority_csr', + 'get_certificate_authority', + 'list_certificate_authorities', + 'undelete_certificate_authority', + 'delete_certificate_authority', + 'update_certificate_authority', + 'create_ca_pool', + 'update_ca_pool', + 'get_ca_pool', + 'list_ca_pools', + 'delete_ca_pool', + 'fetch_ca_certs', + 'get_certificate_revocation_list', + 'list_certificate_revocation_lists', + 'update_certificate_revocation_list', + 'create_certificate_template', + 'delete_certificate_template', + 'get_certificate_template', + 'list_certificate_templates', + 'update_certificate_template', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + +@requires_google_auth_gte_1_25_0 +def test_certificate_authority_service_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CertificateAuthorityServiceTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_certificate_authority_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CertificateAuthorityServiceTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + quota_project_id="octopus", + ) + + +def test_certificate_authority_service_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CertificateAuthorityServiceTransport() + adc.assert_called_once() + + +@requires_google_auth_gte_1_25_0 +def test_certificate_authority_service_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + CertificateAuthorityServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_certificate_authority_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + CertificateAuthorityServiceClient() + adc.assert_called_once_with( + scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.CertificateAuthorityServiceGrpcTransport, + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_certificate_authority_service_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.CertificateAuthorityServiceGrpcTransport, + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_certificate_authority_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") + adc.assert_called_once_with(scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), + (transports.CertificateAuthorityServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +@requires_api_core_gte_1_26_0 +def test_certificate_authority_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class( + quota_project_id="octopus", + scopes=["1", "2"] + ) + + create_channel.assert_called_with( + "privateca.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="privateca.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), + (transports.CertificateAuthorityServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +@requires_api_core_lt_1_26_0 +def test_certificate_authority_service_transport_create_channel_old_api_core(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") + + create_channel.assert_called_with( + "privateca.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), + (transports.CertificateAuthorityServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +@requires_api_core_lt_1_26_0 +def test_certificate_authority_service_transport_create_channel_user_scopes(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( + "privateca.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.CertificateAuthorityServiceGrpcTransport, transports.CertificateAuthorityServiceGrpcAsyncIOTransport]) +def test_certificate_authority_service_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + 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_authority_service_host_no_port(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='privateca.googleapis.com'), + ) + assert client.transport._host == 'privateca.googleapis.com:443' + + +def test_certificate_authority_service_host_with_port(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='privateca.googleapis.com:8000'), + ) + assert client.transport._host == 'privateca.googleapis.com:8000' + +def test_certificate_authority_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CertificateAuthorityServiceGrpcTransport( + 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_authority_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CertificateAuthorityServiceGrpcAsyncIOTransport( + 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.CertificateAuthorityServiceGrpcTransport, transports.CertificateAuthorityServiceGrpcAsyncIOTransport]) +def test_certificate_authority_service_transport_channel_mtls_with_client_cert_source( + transport_class +): + with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + 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.CertificateAuthorityServiceGrpcTransport, transports.CertificateAuthorityServiceGrpcAsyncIOTransport]) +def test_certificate_authority_service_transport_channel_mtls_with_adc( + transport_class +): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + 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_authority_service_grpc_lro_client(): + client = CertificateAuthorityServiceClient( + 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_authority_service_grpc_lro_async_client(): + client = CertificateAuthorityServiceAsyncClient( + 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 = CertificateAuthorityServiceClient.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 = CertificateAuthorityServiceClient.ca_pool_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_ca_pool_path(path) + assert expected == actual + +def test_certificate_path(): + project = "cuttlefish" + location = "mussel" + ca_pool = "winkle" + certificate = "nautilus" + expected = "projects/{project}/locations/{location}/caPools/{ca_pool}/certificates/{certificate}".format(project=project, location=location, ca_pool=ca_pool, certificate=certificate, ) + actual = CertificateAuthorityServiceClient.certificate_path(project, location, ca_pool, certificate) + assert expected == actual + + +def test_parse_certificate_path(): + expected = { + "project": "scallop", + "location": "abalone", + "ca_pool": "squid", + "certificate": "clam", + } + path = CertificateAuthorityServiceClient.certificate_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_certificate_path(path) + assert expected == actual + +def test_certificate_authority_path(): + project = "whelk" + location = "octopus" + ca_pool = "oyster" + certificate_authority = "nudibranch" + expected = "projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}".format(project=project, location=location, ca_pool=ca_pool, certificate_authority=certificate_authority, ) + actual = CertificateAuthorityServiceClient.certificate_authority_path(project, location, ca_pool, certificate_authority) + assert expected == actual + + +def test_parse_certificate_authority_path(): + expected = { + "project": "cuttlefish", + "location": "mussel", + "ca_pool": "winkle", + "certificate_authority": "nautilus", + } + path = CertificateAuthorityServiceClient.certificate_authority_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_certificate_authority_path(path) + assert expected == actual + +def test_certificate_revocation_list_path(): + project = "scallop" + location = "abalone" + ca_pool = "squid" + certificate_authority = "clam" + certificate_revocation_list = "whelk" + expected = "projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list}".format(project=project, location=location, ca_pool=ca_pool, certificate_authority=certificate_authority, certificate_revocation_list=certificate_revocation_list, ) + actual = CertificateAuthorityServiceClient.certificate_revocation_list_path(project, location, ca_pool, certificate_authority, certificate_revocation_list) + assert expected == actual + + +def test_parse_certificate_revocation_list_path(): + expected = { + "project": "octopus", + "location": "oyster", + "ca_pool": "nudibranch", + "certificate_authority": "cuttlefish", + "certificate_revocation_list": "mussel", + } + path = CertificateAuthorityServiceClient.certificate_revocation_list_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_certificate_revocation_list_path(path) + assert expected == actual + +def test_certificate_template_path(): + project = "winkle" + location = "nautilus" + certificate_template = "scallop" + expected = "projects/{project}/locations/{location}/certificateTemplates/{certificate_template}".format(project=project, location=location, certificate_template=certificate_template, ) + actual = CertificateAuthorityServiceClient.certificate_template_path(project, location, certificate_template) + assert expected == actual + + +def test_parse_certificate_template_path(): + expected = { + "project": "abalone", + "location": "squid", + "certificate_template": "clam", + } + path = CertificateAuthorityServiceClient.certificate_template_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_certificate_template_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "whelk" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = CertificateAuthorityServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "octopus", + } + path = CertificateAuthorityServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "oyster" + expected = "folders/{folder}".format(folder=folder, ) + actual = CertificateAuthorityServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nudibranch", + } + path = CertificateAuthorityServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "cuttlefish" + expected = "organizations/{organization}".format(organization=organization, ) + actual = CertificateAuthorityServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "mussel", + } + path = CertificateAuthorityServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "winkle" + expected = "projects/{project}".format(project=project, ) + actual = CertificateAuthorityServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nautilus", + } + path = CertificateAuthorityServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.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 = CertificateAuthorityServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "squid", + "location": "clam", + } + path = CertificateAuthorityServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_withDEFAULT_CLIENT_INFO(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.CertificateAuthorityServiceTransport, '_prep_wrapped_messages') as prep: + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.CertificateAuthorityServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = CertificateAuthorityServiceClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) diff --git a/owl-bot-staging/v1beta1/MANIFEST.in b/owl-bot-staging/v1beta1/MANIFEST.in new file mode 100644 index 0000000..de196ee --- /dev/null +++ b/owl-bot-staging/v1beta1/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/security/privateca *.py +recursive-include google/cloud/security/privateca_v1beta1 *.py diff --git a/owl-bot-staging/v1beta1/README.rst b/owl-bot-staging/v1beta1/README.rst new file mode 100644 index 0000000..d1e676b --- /dev/null +++ b/owl-bot-staging/v1beta1/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Security Privateca 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 Security Privateca API. +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + python3 -m venv + source /bin/activate + /bin/pip install /path/to/library + + +Windows +^^^^^^^ + +.. code-block:: console + + python3 -m venv + \Scripts\activate + \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1beta1/docs/conf.py b/owl-bot-staging/v1beta1/docs/conf.py new file mode 100644 index 0000000..a29fc06 --- /dev/null +++ b/owl-bot-staging/v1beta1/docs/conf.py @@ -0,0 +1,376 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# google-cloud-security-privateca documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath("..")) + +__version__ = "0.1.0" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "1.6.3" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_flags = ["members"] +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# Allow markdown includes (so releases.md can include CHANGLEOG.md) +# http://www.sphinx-doc.org/en/master/markdown.html +source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = u"google-cloud-security-privateca" +copyright = u"2020, Google, LLC" +author = u"Google APIs" # TODO: autogenerate this bit + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Security 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-security-privateca-doc" + +# -- Options for warnings ------------------------------------------------------ + + +suppress_warnings = [ + # Temporarily suppress this to avoid "more than one target found for + # cross-reference" warning, which are intractable for us to avoid while in + # a mono-repo. + # See https://github.com/sphinx-doc/sphinx/blob + # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 + "ref.python" +] + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', + # Latex figure (float) alignment + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + master_doc, + "google-cloud-security-privateca.tex", + u"google-cloud-security-privateca Documentation", + author, + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + master_doc, + "google-cloud-security-privateca", + u"Google Cloud Security Privateca Documentation", + [author], + 1, + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "google-cloud-security-privateca", + u"google-cloud-security-privateca Documentation", + author, + "google-cloud-security-privateca", + "GAPIC library for Google Cloud Security Privateca API", + "APIs", + ) +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = { + "python": ("http://python.readthedocs.org/en/latest/", None), + "gax": ("https://gax-python.readthedocs.org/en/latest/", None), + "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), + "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), + "grpc": ("https://grpc.io/grpc/python/", None), + "requests": ("http://requests.kennethreitz.org/en/stable/", None), + "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), + "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), +} + + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = True +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/owl-bot-staging/v1beta1/docs/index.rst b/owl-bot-staging/v1beta1/docs/index.rst new file mode 100644 index 0000000..43f127e --- /dev/null +++ b/owl-bot-staging/v1beta1/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + privateca_v1beta1/services + privateca_v1beta1/types diff --git a/owl-bot-staging/v1beta1/docs/privateca_v1beta1/certificate_authority_service.rst b/owl-bot-staging/v1beta1/docs/privateca_v1beta1/certificate_authority_service.rst new file mode 100644 index 0000000..536a4c8 --- /dev/null +++ b/owl-bot-staging/v1beta1/docs/privateca_v1beta1/certificate_authority_service.rst @@ -0,0 +1,10 @@ +CertificateAuthorityService +--------------------------------------------- + +.. automodule:: google.cloud.security.privateca_v1beta1.services.certificate_authority_service + :members: + :inherited-members: + +.. automodule:: google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v1beta1/docs/privateca_v1beta1/services.rst b/owl-bot-staging/v1beta1/docs/privateca_v1beta1/services.rst new file mode 100644 index 0000000..bb5adb3 --- /dev/null +++ b/owl-bot-staging/v1beta1/docs/privateca_v1beta1/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Security Privateca v1beta1 API +======================================================== +.. toctree:: + :maxdepth: 2 + + certificate_authority_service diff --git a/owl-bot-staging/v1beta1/docs/privateca_v1beta1/types.rst b/owl-bot-staging/v1beta1/docs/privateca_v1beta1/types.rst new file mode 100644 index 0000000..4e6a2a6 --- /dev/null +++ b/owl-bot-staging/v1beta1/docs/privateca_v1beta1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Security Privateca v1beta1 API +===================================================== + +.. automodule:: google.cloud.security.privateca_v1beta1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca/__init__.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca/__init__.py new file mode 100644 index 0000000..3591c80 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca/__init__.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.security.privateca_v1beta1.services.certificate_authority_service.client import CertificateAuthorityServiceClient +from google.cloud.security.privateca_v1beta1.services.certificate_authority_service.async_client import CertificateAuthorityServiceAsyncClient + +from google.cloud.security.privateca_v1beta1.types.resources import Certificate +from google.cloud.security.privateca_v1beta1.types.resources import CertificateAuthority +from google.cloud.security.privateca_v1beta1.types.resources import CertificateConfig +from google.cloud.security.privateca_v1beta1.types.resources import CertificateDescription +from google.cloud.security.privateca_v1beta1.types.resources import CertificateRevocationList +from google.cloud.security.privateca_v1beta1.types.resources import KeyUsage +from google.cloud.security.privateca_v1beta1.types.resources import ObjectId +from google.cloud.security.privateca_v1beta1.types.resources import PublicKey +from google.cloud.security.privateca_v1beta1.types.resources import ReusableConfig +from google.cloud.security.privateca_v1beta1.types.resources import ReusableConfigValues +from google.cloud.security.privateca_v1beta1.types.resources import ReusableConfigWrapper +from google.cloud.security.privateca_v1beta1.types.resources import Subject +from google.cloud.security.privateca_v1beta1.types.resources import SubjectAltNames +from google.cloud.security.privateca_v1beta1.types.resources import SubordinateConfig +from google.cloud.security.privateca_v1beta1.types.resources import X509Extension +from google.cloud.security.privateca_v1beta1.types.resources import RevocationReason +from google.cloud.security.privateca_v1beta1.types.service import ActivateCertificateAuthorityRequest +from google.cloud.security.privateca_v1beta1.types.service import CreateCertificateAuthorityRequest +from google.cloud.security.privateca_v1beta1.types.service import CreateCertificateRequest +from google.cloud.security.privateca_v1beta1.types.service import DisableCertificateAuthorityRequest +from google.cloud.security.privateca_v1beta1.types.service import EnableCertificateAuthorityRequest +from google.cloud.security.privateca_v1beta1.types.service import FetchCertificateAuthorityCsrRequest +from google.cloud.security.privateca_v1beta1.types.service import FetchCertificateAuthorityCsrResponse +from google.cloud.security.privateca_v1beta1.types.service import GetCertificateAuthorityRequest +from google.cloud.security.privateca_v1beta1.types.service import GetCertificateRequest +from google.cloud.security.privateca_v1beta1.types.service import GetCertificateRevocationListRequest +from google.cloud.security.privateca_v1beta1.types.service import GetReusableConfigRequest +from google.cloud.security.privateca_v1beta1.types.service import ListCertificateAuthoritiesRequest +from google.cloud.security.privateca_v1beta1.types.service import ListCertificateAuthoritiesResponse +from google.cloud.security.privateca_v1beta1.types.service import ListCertificateRevocationListsRequest +from google.cloud.security.privateca_v1beta1.types.service import ListCertificateRevocationListsResponse +from google.cloud.security.privateca_v1beta1.types.service import ListCertificatesRequest +from google.cloud.security.privateca_v1beta1.types.service import ListCertificatesResponse +from google.cloud.security.privateca_v1beta1.types.service import ListReusableConfigsRequest +from google.cloud.security.privateca_v1beta1.types.service import ListReusableConfigsResponse +from google.cloud.security.privateca_v1beta1.types.service import OperationMetadata +from google.cloud.security.privateca_v1beta1.types.service import RestoreCertificateAuthorityRequest +from google.cloud.security.privateca_v1beta1.types.service import RevokeCertificateRequest +from google.cloud.security.privateca_v1beta1.types.service import ScheduleDeleteCertificateAuthorityRequest +from google.cloud.security.privateca_v1beta1.types.service import UpdateCertificateAuthorityRequest +from google.cloud.security.privateca_v1beta1.types.service import UpdateCertificateRequest +from google.cloud.security.privateca_v1beta1.types.service import UpdateCertificateRevocationListRequest + +__all__ = ('CertificateAuthorityServiceClient', + 'CertificateAuthorityServiceAsyncClient', + 'Certificate', + 'CertificateAuthority', + 'CertificateConfig', + 'CertificateDescription', + 'CertificateRevocationList', + 'KeyUsage', + 'ObjectId', + 'PublicKey', + 'ReusableConfig', + 'ReusableConfigValues', + 'ReusableConfigWrapper', + 'Subject', + 'SubjectAltNames', + 'SubordinateConfig', + 'X509Extension', + 'RevocationReason', + 'ActivateCertificateAuthorityRequest', + 'CreateCertificateAuthorityRequest', + 'CreateCertificateRequest', + 'DisableCertificateAuthorityRequest', + 'EnableCertificateAuthorityRequest', + 'FetchCertificateAuthorityCsrRequest', + 'FetchCertificateAuthorityCsrResponse', + 'GetCertificateAuthorityRequest', + 'GetCertificateRequest', + 'GetCertificateRevocationListRequest', + 'GetReusableConfigRequest', + 'ListCertificateAuthoritiesRequest', + 'ListCertificateAuthoritiesResponse', + 'ListCertificateRevocationListsRequest', + 'ListCertificateRevocationListsResponse', + 'ListCertificatesRequest', + 'ListCertificatesResponse', + 'ListReusableConfigsRequest', + 'ListReusableConfigsResponse', + 'OperationMetadata', + 'RestoreCertificateAuthorityRequest', + 'RevokeCertificateRequest', + 'ScheduleDeleteCertificateAuthorityRequest', + 'UpdateCertificateAuthorityRequest', + 'UpdateCertificateRequest', + 'UpdateCertificateRevocationListRequest', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca/py.typed b/owl-bot-staging/v1beta1/google/cloud/security/privateca/py.typed new file mode 100644 index 0000000..866f40f --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-security-privateca package uses inline types. diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/__init__.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/__init__.py new file mode 100644 index 0000000..34e03b7 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/__init__.py @@ -0,0 +1,108 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from .services.certificate_authority_service import CertificateAuthorityServiceClient +from .services.certificate_authority_service import CertificateAuthorityServiceAsyncClient + +from .types.resources import Certificate +from .types.resources import CertificateAuthority +from .types.resources import CertificateConfig +from .types.resources import CertificateDescription +from .types.resources import CertificateRevocationList +from .types.resources import KeyUsage +from .types.resources import ObjectId +from .types.resources import PublicKey +from .types.resources import ReusableConfig +from .types.resources import ReusableConfigValues +from .types.resources import ReusableConfigWrapper +from .types.resources import Subject +from .types.resources import SubjectAltNames +from .types.resources import SubordinateConfig +from .types.resources import X509Extension +from .types.resources import RevocationReason +from .types.service import ActivateCertificateAuthorityRequest +from .types.service import CreateCertificateAuthorityRequest +from .types.service import CreateCertificateRequest +from .types.service import DisableCertificateAuthorityRequest +from .types.service import EnableCertificateAuthorityRequest +from .types.service import FetchCertificateAuthorityCsrRequest +from .types.service import FetchCertificateAuthorityCsrResponse +from .types.service import GetCertificateAuthorityRequest +from .types.service import GetCertificateRequest +from .types.service import GetCertificateRevocationListRequest +from .types.service import GetReusableConfigRequest +from .types.service import ListCertificateAuthoritiesRequest +from .types.service import ListCertificateAuthoritiesResponse +from .types.service import ListCertificateRevocationListsRequest +from .types.service import ListCertificateRevocationListsResponse +from .types.service import ListCertificatesRequest +from .types.service import ListCertificatesResponse +from .types.service import ListReusableConfigsRequest +from .types.service import ListReusableConfigsResponse +from .types.service import OperationMetadata +from .types.service import RestoreCertificateAuthorityRequest +from .types.service import RevokeCertificateRequest +from .types.service import ScheduleDeleteCertificateAuthorityRequest +from .types.service import UpdateCertificateAuthorityRequest +from .types.service import UpdateCertificateRequest +from .types.service import UpdateCertificateRevocationListRequest + +__all__ = ( + 'CertificateAuthorityServiceAsyncClient', +'ActivateCertificateAuthorityRequest', +'Certificate', +'CertificateAuthority', +'CertificateAuthorityServiceClient', +'CertificateConfig', +'CertificateDescription', +'CertificateRevocationList', +'CreateCertificateAuthorityRequest', +'CreateCertificateRequest', +'DisableCertificateAuthorityRequest', +'EnableCertificateAuthorityRequest', +'FetchCertificateAuthorityCsrRequest', +'FetchCertificateAuthorityCsrResponse', +'GetCertificateAuthorityRequest', +'GetCertificateRequest', +'GetCertificateRevocationListRequest', +'GetReusableConfigRequest', +'KeyUsage', +'ListCertificateAuthoritiesRequest', +'ListCertificateAuthoritiesResponse', +'ListCertificateRevocationListsRequest', +'ListCertificateRevocationListsResponse', +'ListCertificatesRequest', +'ListCertificatesResponse', +'ListReusableConfigsRequest', +'ListReusableConfigsResponse', +'ObjectId', +'OperationMetadata', +'PublicKey', +'RestoreCertificateAuthorityRequest', +'ReusableConfig', +'ReusableConfigValues', +'ReusableConfigWrapper', +'RevocationReason', +'RevokeCertificateRequest', +'ScheduleDeleteCertificateAuthorityRequest', +'Subject', +'SubjectAltNames', +'SubordinateConfig', +'UpdateCertificateAuthorityRequest', +'UpdateCertificateRequest', +'UpdateCertificateRevocationListRequest', +'X509Extension', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/gapic_metadata.json b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/gapic_metadata.json new file mode 100644 index 0000000..3406d51 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/gapic_metadata.json @@ -0,0 +1,223 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.security.privateca_v1beta1", + "protoPackage": "google.cloud.security.privateca.v1beta1", + "schema": "1.0", + "services": { + "CertificateAuthorityService": { + "clients": { + "grpc": { + "libraryClient": "CertificateAuthorityServiceClient", + "rpcs": { + "ActivateCertificateAuthority": { + "methods": [ + "activate_certificate_authority" + ] + }, + "CreateCertificate": { + "methods": [ + "create_certificate" + ] + }, + "CreateCertificateAuthority": { + "methods": [ + "create_certificate_authority" + ] + }, + "DisableCertificateAuthority": { + "methods": [ + "disable_certificate_authority" + ] + }, + "EnableCertificateAuthority": { + "methods": [ + "enable_certificate_authority" + ] + }, + "FetchCertificateAuthorityCsr": { + "methods": [ + "fetch_certificate_authority_csr" + ] + }, + "GetCertificate": { + "methods": [ + "get_certificate" + ] + }, + "GetCertificateAuthority": { + "methods": [ + "get_certificate_authority" + ] + }, + "GetCertificateRevocationList": { + "methods": [ + "get_certificate_revocation_list" + ] + }, + "GetReusableConfig": { + "methods": [ + "get_reusable_config" + ] + }, + "ListCertificateAuthorities": { + "methods": [ + "list_certificate_authorities" + ] + }, + "ListCertificateRevocationLists": { + "methods": [ + "list_certificate_revocation_lists" + ] + }, + "ListCertificates": { + "methods": [ + "list_certificates" + ] + }, + "ListReusableConfigs": { + "methods": [ + "list_reusable_configs" + ] + }, + "RestoreCertificateAuthority": { + "methods": [ + "restore_certificate_authority" + ] + }, + "RevokeCertificate": { + "methods": [ + "revoke_certificate" + ] + }, + "ScheduleDeleteCertificateAuthority": { + "methods": [ + "schedule_delete_certificate_authority" + ] + }, + "UpdateCertificate": { + "methods": [ + "update_certificate" + ] + }, + "UpdateCertificateAuthority": { + "methods": [ + "update_certificate_authority" + ] + }, + "UpdateCertificateRevocationList": { + "methods": [ + "update_certificate_revocation_list" + ] + } + } + }, + "grpc-async": { + "libraryClient": "CertificateAuthorityServiceAsyncClient", + "rpcs": { + "ActivateCertificateAuthority": { + "methods": [ + "activate_certificate_authority" + ] + }, + "CreateCertificate": { + "methods": [ + "create_certificate" + ] + }, + "CreateCertificateAuthority": { + "methods": [ + "create_certificate_authority" + ] + }, + "DisableCertificateAuthority": { + "methods": [ + "disable_certificate_authority" + ] + }, + "EnableCertificateAuthority": { + "methods": [ + "enable_certificate_authority" + ] + }, + "FetchCertificateAuthorityCsr": { + "methods": [ + "fetch_certificate_authority_csr" + ] + }, + "GetCertificate": { + "methods": [ + "get_certificate" + ] + }, + "GetCertificateAuthority": { + "methods": [ + "get_certificate_authority" + ] + }, + "GetCertificateRevocationList": { + "methods": [ + "get_certificate_revocation_list" + ] + }, + "GetReusableConfig": { + "methods": [ + "get_reusable_config" + ] + }, + "ListCertificateAuthorities": { + "methods": [ + "list_certificate_authorities" + ] + }, + "ListCertificateRevocationLists": { + "methods": [ + "list_certificate_revocation_lists" + ] + }, + "ListCertificates": { + "methods": [ + "list_certificates" + ] + }, + "ListReusableConfigs": { + "methods": [ + "list_reusable_configs" + ] + }, + "RestoreCertificateAuthority": { + "methods": [ + "restore_certificate_authority" + ] + }, + "RevokeCertificate": { + "methods": [ + "revoke_certificate" + ] + }, + "ScheduleDeleteCertificateAuthority": { + "methods": [ + "schedule_delete_certificate_authority" + ] + }, + "UpdateCertificate": { + "methods": [ + "update_certificate" + ] + }, + "UpdateCertificateAuthority": { + "methods": [ + "update_certificate_authority" + ] + }, + "UpdateCertificateRevocationList": { + "methods": [ + "update_certificate_revocation_list" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/py.typed b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/py.typed new file mode 100644 index 0000000..866f40f --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-security-privateca package uses inline types. diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/__init__.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/__init__.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/__init__.py new file mode 100644 index 0000000..33b4459 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from .client import CertificateAuthorityServiceClient +from .async_client import CertificateAuthorityServiceAsyncClient + +__all__ = ( + 'CertificateAuthorityServiceClient', + 'CertificateAuthorityServiceAsyncClient', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py new file mode 100644 index 0000000..bd45800 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py @@ -0,0 +1,2001 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +import functools +import re +from typing import Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import pagers +from google.cloud.security.privateca_v1beta1.types import resources +from google.cloud.security.privateca_v1beta1.types import service +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport +from .client import CertificateAuthorityServiceClient + + +class CertificateAuthorityServiceAsyncClient: + """[Certificate Authority + Service][google.cloud.security.privateca.v1beta1.CertificateAuthorityService] + manages private certificate authorities and issued certificates. + """ + + _client: CertificateAuthorityServiceClient + + DEFAULT_ENDPOINT = CertificateAuthorityServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = CertificateAuthorityServiceClient.DEFAULT_MTLS_ENDPOINT + + certificate_path = staticmethod(CertificateAuthorityServiceClient.certificate_path) + parse_certificate_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_path) + certificate_authority_path = staticmethod(CertificateAuthorityServiceClient.certificate_authority_path) + parse_certificate_authority_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_authority_path) + certificate_revocation_list_path = staticmethod(CertificateAuthorityServiceClient.certificate_revocation_list_path) + parse_certificate_revocation_list_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_revocation_list_path) + reusable_config_path = staticmethod(CertificateAuthorityServiceClient.reusable_config_path) + parse_reusable_config_path = staticmethod(CertificateAuthorityServiceClient.parse_reusable_config_path) + common_billing_account_path = staticmethod(CertificateAuthorityServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(CertificateAuthorityServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(CertificateAuthorityServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(CertificateAuthorityServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(CertificateAuthorityServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(CertificateAuthorityServiceClient.parse_common_organization_path) + common_project_path = staticmethod(CertificateAuthorityServiceClient.common_project_path) + parse_common_project_path = staticmethod(CertificateAuthorityServiceClient.parse_common_project_path) + common_location_path = staticmethod(CertificateAuthorityServiceClient.common_location_path) + parse_common_location_path = staticmethod(CertificateAuthorityServiceClient.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: + CertificateAuthorityServiceAsyncClient: The constructed client. + """ + return CertificateAuthorityServiceClient.from_service_account_info.__func__(CertificateAuthorityServiceAsyncClient, 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: + CertificateAuthorityServiceAsyncClient: The constructed client. + """ + return CertificateAuthorityServiceClient.from_service_account_file.__func__(CertificateAuthorityServiceAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> CertificateAuthorityServiceTransport: + """Returns the transport used by the client instance. + + Returns: + CertificateAuthorityServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(CertificateAuthorityServiceClient).get_transport_class, type(CertificateAuthorityServiceClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, CertificateAuthorityServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the certificate authority service client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.CertificateAuthorityServiceTransport]): 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 = CertificateAuthorityServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def create_certificate(self, + request: service.CreateCertificateRequest = None, + *, + parent: str = None, + certificate: resources.Certificate = None, + certificate_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Create a new + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + in a given Project, Location from a particular + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.CreateCertificateRequest`): + The request object. Request message for + [CertificateAuthorityService.CreateCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.CreateCertificate]. + parent (:class:`str`): + Required. The resource name of the location and + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + associated with the + [Certificate][google.cloud.security.privateca.v1beta1.Certificate], + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate (:class:`google.cloud.security.privateca_v1beta1.types.Certificate`): + Required. A + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + with initial field values. + + This corresponds to the ``certificate`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_id (:class:`str`): + Optional. It must be unique within a location and match + the regular expression ``[a-zA-Z0-9_-]{1,63}``. This + field is required when using a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the Enterprise + [CertificateAuthority.Tier][google.cloud.security.privateca.v1beta1.CertificateAuthority.Tier], + but is optional and its value is ignored otherwise. + + 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.cloud.security.privateca_v1beta1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, 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 = service.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_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_certificate(self, + request: service.GetCertificateRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Returns a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.GetCertificateRequest`): + The request object. Request message for + [CertificateAuthorityService.GetCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificate]. + name (:class:`str`): + Required. The + [name][google.cloud.security.privateca.v1beta1.Certificate.name] + of the + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + to get. + + 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.security.privateca_v1beta1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.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_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_certificates(self, + request: service.ListCertificatesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificatesAsyncPager: + r"""Lists + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.ListCertificatesRequest`): + The request object. Request message for + [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificates]. + parent (:class:`str`): + Required. The resource name of the location associated + with the + [Certificates][google.cloud.security.privateca.v1beta1.Certificate], + in the format + ``projects/*/locations/*/certificateauthorities/*``. + + 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificatesAsyncPager: + Response message for + [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificates]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.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_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCertificatesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def revoke_certificate(self, + request: service.RevokeCertificateRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Revoke a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.RevokeCertificateRequest`): + The request object. Request message for + [CertificateAuthorityService.RevokeCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.RevokeCertificate]. + name (:class:`str`): + Required. The resource name for this + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + in the format + ``projects/*/locations/*/certificateAuthorities/*/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.security.privateca_v1beta1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.RevokeCertificateRequest(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.revoke_certificate, + 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 update_certificate(self, + request: service.UpdateCertificateRequest = None, + *, + certificate: resources.Certificate = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Update a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + Currently, the only field you can update is the + [labels][google.cloud.security.privateca.v1beta1.Certificate.labels] + field. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.UpdateCertificateRequest`): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificate]. + certificate (:class:`google.cloud.security.privateca_v1beta1.types.Certificate`): + Required. + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + with updated values. + + 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. A list of fields to be + updated in this request. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.security.privateca_v1beta1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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 = service.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_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(( + ("certificate.name", request.certificate.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def activate_certificate_authority(self, + request: service.ActivateCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Activate a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + that is in state + [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. + After the parent Certificate Authority signs a certificate + signing request from + [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr], + this method can complete the activation process. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.ActivateCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. + name (:class:`str`): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.ActivateCertificateAuthorityRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.activate_certificate_authority, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_certificate_authority(self, + request: service.CreateCertificateAuthorityRequest = None, + *, + parent: str = None, + certificate_authority: resources.CertificateAuthority = None, + certificate_authority_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Create a new + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in a given Project and Location. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.CreateCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.CreateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.CreateCertificateAuthority]. + parent (:class:`str`): + Required. The resource name of the location associated + with the + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority], + 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_authority (:class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority`): + Required. A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + with initial field values. + + This corresponds to the ``certificate_authority`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_authority_id (:class:`str`): + Required. It must be unique within a location and match + the regular expression ``[a-zA-Z0-9_-]{1,63}`` + + This corresponds to the ``certificate_authority_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.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate_authority, certificate_authority_id]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.CreateCertificateAuthorityRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate_authority is not None: + request.certificate_authority = certificate_authority + if certificate_authority_id is not None: + request.certificate_authority_id = certificate_authority_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_authority, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def disable_certificate_authority(self, + request: service.DisableCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Disable a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.DisableCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.DisableCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.DisableCertificateAuthority]. + name (:class:`str`): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.DisableCertificateAuthorityRequest(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.disable_certificate_authority, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def enable_certificate_authority(self, + request: service.EnableCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Enable a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.EnableCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.EnableCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.EnableCertificateAuthority]. + name (:class:`str`): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.EnableCertificateAuthorityRequest(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.enable_certificate_authority, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def fetch_certificate_authority_csr(self, + request: service.FetchCertificateAuthorityCsrRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.FetchCertificateAuthorityCsrResponse: + r"""Fetch a certificate signing request (CSR) from a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + that is in state + [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. + The CSR must then be signed by the desired parent Certificate + Authority, which could be another + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + resource, or could be an on-prem certificate authority. See also + [ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.FetchCertificateAuthorityCsrRequest`): + The request object. Request message for + [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. + name (:class:`str`): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + 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.security.privateca_v1beta1.types.FetchCertificateAuthorityCsrResponse: + Response message for + [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.FetchCertificateAuthorityCsrRequest(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.fetch_certificate_authority_csr, + 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_certificate_authority(self, + request: service.GetCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CertificateAuthority: + r"""Returns a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.GetCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.GetCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificateAuthority]. + name (:class:`str`): + Required. The + [name][google.cloud.security.privateca.v1beta1.CertificateAuthority.name] + of the + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + to get. + + 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.security.privateca_v1beta1.types.CertificateAuthority: + A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.GetCertificateAuthorityRequest(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_authority, + 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_certificate_authorities(self, + request: service.ListCertificateAuthoritiesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateAuthoritiesAsyncPager: + r"""Lists + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesRequest`): + The request object. Request message for + [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateAuthorities]. + parent (:class:`str`): + Required. The resource name of the location associated + with the + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority], + 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesAsyncPager: + Response message for + [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateAuthorities]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.ListCertificateAuthoritiesRequest(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_authorities, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCertificateAuthoritiesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def restore_certificate_authority(self, + request: service.RestoreCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Restore a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + that is scheduled for deletion. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.RestoreCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.RestoreCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.RestoreCertificateAuthority]. + name (:class:`str`): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.RestoreCertificateAuthorityRequest(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.restore_certificate_authority, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def schedule_delete_certificate_authority(self, + request: service.ScheduleDeleteCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Schedule a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + for deletion. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.ScheduleDeleteCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.ScheduleDeleteCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ScheduleDeleteCertificateAuthority]. + name (:class:`str`): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.ScheduleDeleteCertificateAuthorityRequest(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.schedule_delete_certificate_authority, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_certificate_authority(self, + request: service.UpdateCertificateAuthorityRequest = None, + *, + certificate_authority: resources.CertificateAuthority = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Update a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.UpdateCertificateAuthorityRequest`): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificateAuthority]. + certificate_authority (:class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority`): + Required. + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + with updated values. + + This corresponds to the ``certificate_authority`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. A list of fields to be + updated in this request. + + 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.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_authority, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.UpdateCertificateAuthorityRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_authority is not None: + request.certificate_authority = certificate_authority + 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_authority, + 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(( + ("certificate_authority.name", request.certificate_authority.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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_certificate_revocation_list(self, + request: service.GetCertificateRevocationListRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CertificateRevocationList: + r"""Returns a + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.GetCertificateRevocationListRequest`): + The request object. Request message for + [CertificateAuthorityService.GetCertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificateRevocationList]. + name (:class:`str`): + Required. The + [name][google.cloud.security.privateca.v1beta1.CertificateRevocationList.name] + of the + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] + to get. + + 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.security.privateca_v1beta1.types.CertificateRevocationList: + A [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] corresponds to a signed X.509 certificate + Revocation List (CRL). A CRL contains the serial + numbers of certificates that should no longer be + trusted. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.GetCertificateRevocationListRequest(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_revocation_list, + 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_certificate_revocation_lists(self, + request: service.ListCertificateRevocationListsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateRevocationListsAsyncPager: + r"""Lists + [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsRequest`): + The request object. Request message for + [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateRevocationLists]. + parent (:class:`str`): + Required. The resource name of the location associated + with the + [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList], + in the format + ``projects/*/locations/*/certificateauthorities/*``. + + 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateRevocationListsAsyncPager: + Response message for + [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateRevocationLists]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.ListCertificateRevocationListsRequest(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_revocation_lists, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListCertificateRevocationListsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_certificate_revocation_list(self, + request: service.UpdateCertificateRevocationListRequest = None, + *, + certificate_revocation_list: resources.CertificateRevocationList = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Update a + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.UpdateCertificateRevocationListRequest`): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificateRevocationList]. + certificate_revocation_list (:class:`google.cloud.security.privateca_v1beta1.types.CertificateRevocationList`): + Required. + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] + with updated values. + + This corresponds to the ``certificate_revocation_list`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. A list of fields to be + updated in this request. + + 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.security.privateca_v1beta1.types.CertificateRevocationList` A [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] corresponds to a signed X.509 certificate + Revocation List (CRL). A CRL contains the serial + numbers of certificates that should no longer be + trusted. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_revocation_list, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.UpdateCertificateRevocationListRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_revocation_list is not None: + request.certificate_revocation_list = certificate_revocation_list + 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_revocation_list, + 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(( + ("certificate_revocation_list.name", request.certificate_revocation_list.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, + resources.CertificateRevocationList, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_reusable_config(self, + request: service.GetReusableConfigRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.ReusableConfig: + r"""Returns a + [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.GetReusableConfigRequest`): + The request object. Request message for + [CertificateAuthorityService.GetReusableConfig][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetReusableConfig]. + name (:class:`str`): + Required. The [name][ReusableConfigs.name] of the + [ReusableConfigs][] to get. + + 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.security.privateca_v1beta1.types.ReusableConfig: + A [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] refers to a managed [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues]. Those, in + turn, are used to describe certain fields of an X.509 + certificate, such as the key usage fields, fields + specific to CA certificates, certificate policy + extensions and custom extensions. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.GetReusableConfigRequest(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_reusable_config, + 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_reusable_configs(self, + request: service.ListReusableConfigsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListReusableConfigsAsyncPager: + r"""Lists + [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig]. + + Args: + request (:class:`google.cloud.security.privateca_v1beta1.types.ListReusableConfigsRequest`): + The request object. Request message for + [CertificateAuthorityService.ListReusableConfigs][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListReusableConfigs]. + parent (:class:`str`): + Required. The resource name of the location associated + with the + [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig], + 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListReusableConfigsAsyncPager: + Response message for + [CertificateAuthorityService.ListReusableConfigs][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListReusableConfigs]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = service.ListReusableConfigsRequest(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_reusable_configs, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListReusableConfigsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-security-privateca", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "CertificateAuthorityServiceAsyncClient", +) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py new file mode 100644 index 0000000..ae58472 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py @@ -0,0 +1,2215 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +from distutils import util +import os +import re +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +import pkg_resources + +from google.api_core import client_options as client_options_lib # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import pagers +from google.cloud.security.privateca_v1beta1.types import resources +from google.cloud.security.privateca_v1beta1.types import service +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import CertificateAuthorityServiceGrpcTransport +from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport + + +class CertificateAuthorityServiceClientMeta(type): + """Metaclass for the CertificateAuthorityService 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[CertificateAuthorityServiceTransport]] + _transport_registry["grpc"] = CertificateAuthorityServiceGrpcTransport + _transport_registry["grpc_asyncio"] = CertificateAuthorityServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[CertificateAuthorityServiceTransport]: + """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 CertificateAuthorityServiceClient(metaclass=CertificateAuthorityServiceClientMeta): + """[Certificate Authority + Service][google.cloud.security.privateca.v1beta1.CertificateAuthorityService] + manages private certificate authorities and issued certificates. + """ + + @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 = "privateca.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: + CertificateAuthorityServiceClient: 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: + CertificateAuthorityServiceClient: 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) -> CertificateAuthorityServiceTransport: + """Returns the transport used by the client instance. + + Returns: + CertificateAuthorityServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def certificate_path(project: str,location: str,certificate_authority: str,certificate: str,) -> str: + """Returns a fully-qualified certificate string.""" + return "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}/certificates/{certificate}".format(project=project, location=location, certificate_authority=certificate_authority, 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.+?)/certificateAuthorities/(?P.+?)/certificates/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def certificate_authority_path(project: str,location: str,certificate_authority: str,) -> str: + """Returns a fully-qualified certificate_authority string.""" + return "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}".format(project=project, location=location, certificate_authority=certificate_authority, ) + + @staticmethod + def parse_certificate_authority_path(path: str) -> Dict[str,str]: + """Parses a certificate_authority path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificateAuthorities/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def certificate_revocation_list_path(project: str,location: str,certificate_authority: str,certificate_revocation_list: str,) -> str: + """Returns a fully-qualified certificate_revocation_list string.""" + return "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list}".format(project=project, location=location, certificate_authority=certificate_authority, certificate_revocation_list=certificate_revocation_list, ) + + @staticmethod + def parse_certificate_revocation_list_path(path: str) -> Dict[str,str]: + """Parses a certificate_revocation_list path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificateAuthorities/(?P.+?)/certificateRevocationLists/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def reusable_config_path(project: str,location: str,reusable_config: str,) -> str: + """Returns a fully-qualified reusable_config string.""" + return "projects/{project}/locations/{location}/reusableConfigs/{reusable_config}".format(project=project, location=location, reusable_config=reusable_config, ) + + @staticmethod + def parse_reusable_config_path(path: str) -> Dict[str,str]: + """Parses a reusable_config path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/reusableConfigs/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_billing_account_path(billing_account: str, ) -> str: + """Returns a fully-qualified billing_account string.""" + return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str,str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str, ) -> str: + """Returns a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder, ) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str,str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str, ) -> str: + """Returns a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization, ) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str,str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str, ) -> str: + """Returns a fully-qualified project string.""" + return "projects/{project}".format(project=project, ) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str,str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_location_path(project: str, location: str, ) -> str: + """Returns a fully-qualified location string.""" + return "projects/{project}/locations/{location}".format(project=project, location=location, ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str,str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, CertificateAuthorityServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the certificate authority service client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, CertificateAuthorityServiceTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = client_options_lib.from_dict(client_options) + if client_options is None: + client_options = client_options_lib.ClientOptions() + + # Create SSL credentials for mutual TLS if needed. + use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) + + client_cert_source_func = None + is_mtls = False + if use_client_cert: + if client_options.client_cert_source: + is_mtls = True + client_cert_source_func = client_options.client_cert_source + else: + is_mtls = mtls.has_default_client_cert_source() + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + else: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_mtls_env == "never": + api_endpoint = self.DEFAULT_ENDPOINT + elif use_mtls_env == "always": + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + elif use_mtls_env == "auto": + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT + else: + raise MutualTLSChannelError( + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, CertificateAuthorityServiceTransport): + # transport is a CertificateAuthorityServiceTransport instance. + if credentials or client_options.credentials_file: + raise ValueError("When providing a transport instance, " + "provide its credentials directly.") + if client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = transport + else: + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=api_endpoint, + scopes=client_options.scopes, + client_cert_source_for_mtls=client_cert_source_func, + quota_project_id=client_options.quota_project_id, + client_info=client_info, + ) + + def create_certificate(self, + request: service.CreateCertificateRequest = None, + *, + parent: str = None, + certificate: resources.Certificate = None, + certificate_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Create a new + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + in a given Project, Location from a particular + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.CreateCertificateRequest): + The request object. Request message for + [CertificateAuthorityService.CreateCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.CreateCertificate]. + parent (str): + Required. The resource name of the location and + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + associated with the + [Certificate][google.cloud.security.privateca.v1beta1.Certificate], + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate (google.cloud.security.privateca_v1beta1.types.Certificate): + Required. A + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + with initial field values. + + This corresponds to the ``certificate`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_id (str): + Optional. It must be unique within a location and match + the regular expression ``[a-zA-Z0-9_-]{1,63}``. This + field is required when using a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the Enterprise + [CertificateAuthority.Tier][google.cloud.security.privateca.v1beta1.CertificateAuthority.Tier], + but is optional and its value is ignored otherwise. + + 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.cloud.security.privateca_v1beta1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, 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 service.CreateCertificateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateCertificateRequest): + request = service.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, + ) + + # Done; return the response. + return response + + def get_certificate(self, + request: service.GetCertificateRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Returns a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.GetCertificateRequest): + The request object. Request message for + [CertificateAuthorityService.GetCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificate]. + name (str): + Required. The + [name][google.cloud.security.privateca.v1beta1.Certificate.name] + of the + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + to get. + + 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.security.privateca_v1beta1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetCertificateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetCertificateRequest): + request = service.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 list_certificates(self, + request: service.ListCertificatesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificatesPager: + r"""Lists + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.ListCertificatesRequest): + The request object. Request message for + [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificates]. + parent (str): + Required. The resource name of the location associated + with the + [Certificates][google.cloud.security.privateca.v1beta1.Certificate], + in the format + ``projects/*/locations/*/certificateauthorities/*``. + + 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificatesPager: + Response message for + [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificates]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.ListCertificatesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListCertificatesRequest): + request = service.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 revoke_certificate(self, + request: service.RevokeCertificateRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Revoke a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.RevokeCertificateRequest): + The request object. Request message for + [CertificateAuthorityService.RevokeCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.RevokeCertificate]. + name (str): + Required. The resource name for this + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + in the format + ``projects/*/locations/*/certificateAuthorities/*/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.security.privateca_v1beta1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.RevokeCertificateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.RevokeCertificateRequest): + request = service.RevokeCertificateRequest(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.revoke_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 update_certificate(self, + request: service.UpdateCertificateRequest = None, + *, + certificate: resources.Certificate = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Certificate: + r"""Update a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + Currently, the only field you can update is the + [labels][google.cloud.security.privateca.v1beta1.Certificate.labels] + field. + + Args: + request (google.cloud.security.privateca_v1beta1.types.UpdateCertificateRequest): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificate]. + certificate (google.cloud.security.privateca_v1beta1.types.Certificate): + Required. + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + with updated values. + + 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. A list of fields to be + updated in this request. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.security.privateca_v1beta1.types.Certificate: + A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([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 service.UpdateCertificateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateCertificateRequest): + request = service.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, + ) + + # Done; return the response. + return response + + def activate_certificate_authority(self, + request: service.ActivateCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Activate a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + that is in state + [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. + After the parent Certificate Authority signs a certificate + signing request from + [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr], + this method can complete the activation process. + + Args: + request (google.cloud.security.privateca_v1beta1.types.ActivateCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.ActivateCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ActivateCertificateAuthorityRequest): + request = service.ActivateCertificateAuthorityRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.activate_certificate_authority] + + # 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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_certificate_authority(self, + request: service.CreateCertificateAuthorityRequest = None, + *, + parent: str = None, + certificate_authority: resources.CertificateAuthority = None, + certificate_authority_id: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Create a new + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in a given Project and Location. + + Args: + request (google.cloud.security.privateca_v1beta1.types.CreateCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.CreateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.CreateCertificateAuthority]. + parent (str): + Required. The resource name of the location associated + with the + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority], + 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_authority (google.cloud.security.privateca_v1beta1.types.CertificateAuthority): + Required. A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + with initial field values. + + This corresponds to the ``certificate_authority`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + certificate_authority_id (str): + Required. It must be unique within a location and match + the regular expression ``[a-zA-Z0-9_-]{1,63}`` + + This corresponds to the ``certificate_authority_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.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, certificate_authority, certificate_authority_id]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.CreateCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateCertificateAuthorityRequest): + request = service.CreateCertificateAuthorityRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if certificate_authority is not None: + request.certificate_authority = certificate_authority + if certificate_authority_id is not None: + request.certificate_authority_id = certificate_authority_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_certificate_authority] + + # 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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def disable_certificate_authority(self, + request: service.DisableCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Disable a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.DisableCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.DisableCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.DisableCertificateAuthority]. + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.DisableCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.DisableCertificateAuthorityRequest): + request = service.DisableCertificateAuthorityRequest(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.disable_certificate_authority] + + # 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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def enable_certificate_authority(self, + request: service.EnableCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Enable a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.EnableCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.EnableCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.EnableCertificateAuthority]. + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.EnableCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.EnableCertificateAuthorityRequest): + request = service.EnableCertificateAuthorityRequest(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.enable_certificate_authority] + + # 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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def fetch_certificate_authority_csr(self, + request: service.FetchCertificateAuthorityCsrRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.FetchCertificateAuthorityCsrResponse: + r"""Fetch a certificate signing request (CSR) from a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + that is in state + [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. + The CSR must then be signed by the desired parent Certificate + Authority, which could be another + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + resource, or could be an on-prem certificate authority. See also + [ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.FetchCertificateAuthorityCsrRequest): + The request object. Request message for + [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + 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.security.privateca_v1beta1.types.FetchCertificateAuthorityCsrResponse: + Response message for + [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.FetchCertificateAuthorityCsrRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.FetchCertificateAuthorityCsrRequest): + request = service.FetchCertificateAuthorityCsrRequest(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.fetch_certificate_authority_csr] + + # 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_certificate_authority(self, + request: service.GetCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CertificateAuthority: + r"""Returns a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.GetCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.GetCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificateAuthority]. + name (str): + Required. The + [name][google.cloud.security.privateca.v1beta1.CertificateAuthority.name] + of the + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + to get. + + 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.security.privateca_v1beta1.types.CertificateAuthority: + A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetCertificateAuthorityRequest): + request = service.GetCertificateAuthorityRequest(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_authority] + + # 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_certificate_authorities(self, + request: service.ListCertificateAuthoritiesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateAuthoritiesPager: + r"""Lists + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesRequest): + The request object. Request message for + [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateAuthorities]. + parent (str): + Required. The resource name of the location associated + with the + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority], + 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesPager: + Response message for + [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateAuthorities]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.ListCertificateAuthoritiesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListCertificateAuthoritiesRequest): + request = service.ListCertificateAuthoritiesRequest(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_authorities] + + # 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.ListCertificateAuthoritiesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def restore_certificate_authority(self, + request: service.RestoreCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Restore a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + that is scheduled for deletion. + + Args: + request (google.cloud.security.privateca_v1beta1.types.RestoreCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.RestoreCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.RestoreCertificateAuthority]. + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.RestoreCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.RestoreCertificateAuthorityRequest): + request = service.RestoreCertificateAuthorityRequest(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.restore_certificate_authority] + + # 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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def schedule_delete_certificate_authority(self, + request: service.ScheduleDeleteCertificateAuthorityRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Schedule a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + for deletion. + + Args: + request (google.cloud.security.privateca_v1beta1.types.ScheduleDeleteCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.ScheduleDeleteCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ScheduleDeleteCertificateAuthority]. + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.ScheduleDeleteCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ScheduleDeleteCertificateAuthorityRequest): + request = service.ScheduleDeleteCertificateAuthorityRequest(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.schedule_delete_certificate_authority] + + # 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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_certificate_authority(self, + request: service.UpdateCertificateAuthorityRequest = None, + *, + certificate_authority: resources.CertificateAuthority = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Update a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.UpdateCertificateAuthorityRequest): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificateAuthority]. + certificate_authority (google.cloud.security.privateca_v1beta1.types.CertificateAuthority): + Required. + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + with updated values. + + This corresponds to the ``certificate_authority`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be + updated in this request. + + 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.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. + A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_authority, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.UpdateCertificateAuthorityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateCertificateAuthorityRequest): + request = service.UpdateCertificateAuthorityRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_authority is not None: + request.certificate_authority = certificate_authority + 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_authority] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("certificate_authority.name", request.certificate_authority.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, + resources.CertificateAuthority, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_certificate_revocation_list(self, + request: service.GetCertificateRevocationListRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.CertificateRevocationList: + r"""Returns a + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.GetCertificateRevocationListRequest): + The request object. Request message for + [CertificateAuthorityService.GetCertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificateRevocationList]. + name (str): + Required. The + [name][google.cloud.security.privateca.v1beta1.CertificateRevocationList.name] + of the + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] + to get. + + 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.security.privateca_v1beta1.types.CertificateRevocationList: + A [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] corresponds to a signed X.509 certificate + Revocation List (CRL). A CRL contains the serial + numbers of certificates that should no longer be + trusted. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetCertificateRevocationListRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetCertificateRevocationListRequest): + request = service.GetCertificateRevocationListRequest(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_revocation_list] + + # 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_certificate_revocation_lists(self, + request: service.ListCertificateRevocationListsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCertificateRevocationListsPager: + r"""Lists + [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsRequest): + The request object. Request message for + [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateRevocationLists]. + parent (str): + Required. The resource name of the location associated + with the + [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList], + in the format + ``projects/*/locations/*/certificateauthorities/*``. + + 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateRevocationListsPager: + Response message for + [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateRevocationLists]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.ListCertificateRevocationListsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListCertificateRevocationListsRequest): + request = service.ListCertificateRevocationListsRequest(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_revocation_lists] + + # 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.ListCertificateRevocationListsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_certificate_revocation_list(self, + request: service.UpdateCertificateRevocationListRequest = None, + *, + certificate_revocation_list: resources.CertificateRevocationList = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Update a + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.UpdateCertificateRevocationListRequest): + The request object. Request message for + [CertificateAuthorityService.UpdateCertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificateRevocationList]. + certificate_revocation_list (google.cloud.security.privateca_v1beta1.types.CertificateRevocationList): + Required. + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] + with updated values. + + This corresponds to the ``certificate_revocation_list`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be + updated in this request. + + 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.security.privateca_v1beta1.types.CertificateRevocationList` A [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] corresponds to a signed X.509 certificate + Revocation List (CRL). A CRL contains the serial + numbers of certificates that should no longer be + trusted. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([certificate_revocation_list, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.UpdateCertificateRevocationListRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateCertificateRevocationListRequest): + request = service.UpdateCertificateRevocationListRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if certificate_revocation_list is not None: + request.certificate_revocation_list = certificate_revocation_list + 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_revocation_list] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("certificate_revocation_list.name", request.certificate_revocation_list.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, + resources.CertificateRevocationList, + metadata_type=service.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_reusable_config(self, + request: service.GetReusableConfigRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.ReusableConfig: + r"""Returns a + [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.GetReusableConfigRequest): + The request object. Request message for + [CertificateAuthorityService.GetReusableConfig][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetReusableConfig]. + name (str): + Required. The [name][ReusableConfigs.name] of the + [ReusableConfigs][] to get. + + 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.security.privateca_v1beta1.types.ReusableConfig: + A [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] refers to a managed [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues]. Those, in + turn, are used to describe certain fields of an X.509 + certificate, such as the key usage fields, fields + specific to CA certificates, certificate policy + extensions and custom extensions. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.GetReusableConfigRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetReusableConfigRequest): + request = service.GetReusableConfigRequest(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_reusable_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 list_reusable_configs(self, + request: service.ListReusableConfigsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListReusableConfigsPager: + r"""Lists + [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig]. + + Args: + request (google.cloud.security.privateca_v1beta1.types.ListReusableConfigsRequest): + The request object. Request message for + [CertificateAuthorityService.ListReusableConfigs][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListReusableConfigs]. + parent (str): + Required. The resource name of the location associated + with the + [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig], + 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListReusableConfigsPager: + Response message for + [CertificateAuthorityService.ListReusableConfigs][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListReusableConfigs]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a service.ListReusableConfigsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListReusableConfigsRequest): + request = service.ListReusableConfigsRequest(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_reusable_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.ListReusableConfigsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-security-privateca", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "CertificateAuthorityServiceClient", +) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py new file mode 100644 index 0000000..2765ec9 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py @@ -0,0 +1,507 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional + +from google.cloud.security.privateca_v1beta1.types import resources +from google.cloud.security.privateca_v1beta1.types import service + + +class ListCertificatesPager: + """A pager for iterating through ``list_certificates`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1beta1.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.security.privateca_v1beta1.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[..., service.ListCertificatesResponse], + request: service.ListCertificatesRequest, + response: service.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.security.privateca_v1beta1.types.ListCertificatesRequest): + The initial request object. + response (google.cloud.security.privateca_v1beta1.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 = service.ListCertificatesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.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) -> Iterable[resources.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.security.privateca_v1beta1.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.security.privateca_v1beta1.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[service.ListCertificatesResponse]], + request: service.ListCertificatesRequest, + response: service.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.security.privateca_v1beta1.types.ListCertificatesRequest): + The initial request object. + response (google.cloud.security.privateca_v1beta1.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 = service.ListCertificatesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.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) -> AsyncIterable[resources.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 ListCertificateAuthoritiesPager: + """A pager for iterating through ``list_certificate_authorities`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``certificate_authorities`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCertificateAuthorities`` requests and continue to iterate + through the ``certificate_authorities`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., service.ListCertificateAuthoritiesResponse], + request: service.ListCertificateAuthoritiesRequest, + response: service.ListCertificateAuthoritiesResponse, + *, + 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.security.privateca_v1beta1.types.ListCertificateAuthoritiesRequest): + The initial request object. + response (google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListCertificateAuthoritiesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.ListCertificateAuthoritiesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.CertificateAuthority]: + for page in self.pages: + yield from page.certificate_authorities + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateAuthoritiesAsyncPager: + """A pager for iterating through ``list_certificate_authorities`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``certificate_authorities`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCertificateAuthorities`` requests and continue to iterate + through the ``certificate_authorities`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., Awaitable[service.ListCertificateAuthoritiesResponse]], + request: service.ListCertificateAuthoritiesRequest, + response: service.ListCertificateAuthoritiesResponse, + *, + 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.security.privateca_v1beta1.types.ListCertificateAuthoritiesRequest): + The initial request object. + response (google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListCertificateAuthoritiesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.ListCertificateAuthoritiesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.CertificateAuthority]: + async def async_generator(): + async for page in self.pages: + for response in page.certificate_authorities: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateRevocationListsPager: + """A pager for iterating through ``list_certificate_revocation_lists`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``certificate_revocation_lists`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCertificateRevocationLists`` requests and continue to iterate + through the ``certificate_revocation_lists`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., service.ListCertificateRevocationListsResponse], + request: service.ListCertificateRevocationListsRequest, + response: service.ListCertificateRevocationListsResponse, + *, + 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.security.privateca_v1beta1.types.ListCertificateRevocationListsRequest): + The initial request object. + response (google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListCertificateRevocationListsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.ListCertificateRevocationListsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.CertificateRevocationList]: + for page in self.pages: + yield from page.certificate_revocation_lists + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCertificateRevocationListsAsyncPager: + """A pager for iterating through ``list_certificate_revocation_lists`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``certificate_revocation_lists`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCertificateRevocationLists`` requests and continue to iterate + through the ``certificate_revocation_lists`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., Awaitable[service.ListCertificateRevocationListsResponse]], + request: service.ListCertificateRevocationListsRequest, + response: service.ListCertificateRevocationListsResponse, + *, + 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.security.privateca_v1beta1.types.ListCertificateRevocationListsRequest): + The initial request object. + response (google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListCertificateRevocationListsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.ListCertificateRevocationListsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.CertificateRevocationList]: + async def async_generator(): + async for page in self.pages: + for response in page.certificate_revocation_lists: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListReusableConfigsPager: + """A pager for iterating through ``list_reusable_configs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1beta1.types.ListReusableConfigsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``reusable_configs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListReusableConfigs`` requests and continue to iterate + through the ``reusable_configs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1beta1.types.ListReusableConfigsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., service.ListReusableConfigsResponse], + request: service.ListReusableConfigsRequest, + response: service.ListReusableConfigsResponse, + *, + 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.security.privateca_v1beta1.types.ListReusableConfigsRequest): + The initial request object. + response (google.cloud.security.privateca_v1beta1.types.ListReusableConfigsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListReusableConfigsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[service.ListReusableConfigsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[resources.ReusableConfig]: + for page in self.pages: + yield from page.reusable_configs + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListReusableConfigsAsyncPager: + """A pager for iterating through ``list_reusable_configs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.security.privateca_v1beta1.types.ListReusableConfigsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``reusable_configs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListReusableConfigs`` requests and continue to iterate + through the ``reusable_configs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.security.privateca_v1beta1.types.ListReusableConfigsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., Awaitable[service.ListReusableConfigsResponse]], + request: service.ListReusableConfigsRequest, + response: service.ListReusableConfigsResponse, + *, + 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.security.privateca_v1beta1.types.ListReusableConfigsRequest): + The initial request object. + response (google.cloud.security.privateca_v1beta1.types.ListReusableConfigsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = service.ListReusableConfigsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[service.ListReusableConfigsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[resources.ReusableConfig]: + async def async_generator(): + async for page in self.pages: + for response in page.reusable_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/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/__init__.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/__init__.py new file mode 100644 index 0000000..8a08053 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +from typing import Dict, Type + +from .base import CertificateAuthorityServiceTransport +from .grpc import CertificateAuthorityServiceGrpcTransport +from .grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[CertificateAuthorityServiceTransport]] +_transport_registry['grpc'] = CertificateAuthorityServiceGrpcTransport +_transport_registry['grpc_asyncio'] = CertificateAuthorityServiceGrpcAsyncIOTransport + +__all__ = ( + 'CertificateAuthorityServiceTransport', + 'CertificateAuthorityServiceGrpcTransport', + 'CertificateAuthorityServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py new file mode 100644 index 0000000..a6deba5 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py @@ -0,0 +1,456 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version +import pkg_resources + +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore + +from google.cloud.security.privateca_v1beta1.types import resources +from google.cloud.security.privateca_v1beta1.types import service +from google.longrunning import operations_pb2 # type: ignore + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + 'google-cloud-security-privateca', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + + +class CertificateAuthorityServiceTransport(abc.ABC): + """Abstract transport class for CertificateAuthorityService.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'privateca.googleapis.com' + def __init__( + self, *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + **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. + """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ':' not in host: + host += ':443' + self._host = host + + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + + # Save the scopes. + self._scopes = scopes or self.AUTH_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) + + # Save the credentials. + self._credentials = credentials + + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.create_certificate: gapic_v1.method.wrap_method( + self.create_certificate, + default_timeout=None, + client_info=client_info, + ), + self.get_certificate: gapic_v1.method.wrap_method( + self.get_certificate, + default_timeout=None, + client_info=client_info, + ), + self.list_certificates: gapic_v1.method.wrap_method( + self.list_certificates, + default_timeout=None, + client_info=client_info, + ), + self.revoke_certificate: gapic_v1.method.wrap_method( + self.revoke_certificate, + default_timeout=None, + client_info=client_info, + ), + self.update_certificate: gapic_v1.method.wrap_method( + self.update_certificate, + default_timeout=None, + client_info=client_info, + ), + self.activate_certificate_authority: gapic_v1.method.wrap_method( + self.activate_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.create_certificate_authority: gapic_v1.method.wrap_method( + self.create_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.disable_certificate_authority: gapic_v1.method.wrap_method( + self.disable_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.enable_certificate_authority: gapic_v1.method.wrap_method( + self.enable_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.fetch_certificate_authority_csr: gapic_v1.method.wrap_method( + self.fetch_certificate_authority_csr, + default_timeout=None, + client_info=client_info, + ), + self.get_certificate_authority: gapic_v1.method.wrap_method( + self.get_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.list_certificate_authorities: gapic_v1.method.wrap_method( + self.list_certificate_authorities, + default_timeout=None, + client_info=client_info, + ), + self.restore_certificate_authority: gapic_v1.method.wrap_method( + self.restore_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.schedule_delete_certificate_authority: gapic_v1.method.wrap_method( + self.schedule_delete_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.update_certificate_authority: gapic_v1.method.wrap_method( + self.update_certificate_authority, + default_timeout=None, + client_info=client_info, + ), + self.get_certificate_revocation_list: gapic_v1.method.wrap_method( + self.get_certificate_revocation_list, + default_timeout=None, + client_info=client_info, + ), + self.list_certificate_revocation_lists: gapic_v1.method.wrap_method( + self.list_certificate_revocation_lists, + default_timeout=None, + client_info=client_info, + ), + self.update_certificate_revocation_list: gapic_v1.method.wrap_method( + self.update_certificate_revocation_list, + default_timeout=None, + client_info=client_info, + ), + self.get_reusable_config: gapic_v1.method.wrap_method( + self.get_reusable_config, + default_timeout=None, + client_info=client_info, + ), + self.list_reusable_configs: gapic_v1.method.wrap_method( + self.list_reusable_configs, + default_timeout=None, + client_info=client_info, + ), + } + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def create_certificate(self) -> Callable[ + [service.CreateCertificateRequest], + Union[ + resources.Certificate, + Awaitable[resources.Certificate] + ]]: + raise NotImplementedError() + + @property + def get_certificate(self) -> Callable[ + [service.GetCertificateRequest], + Union[ + resources.Certificate, + Awaitable[resources.Certificate] + ]]: + raise NotImplementedError() + + @property + def list_certificates(self) -> Callable[ + [service.ListCertificatesRequest], + Union[ + service.ListCertificatesResponse, + Awaitable[service.ListCertificatesResponse] + ]]: + raise NotImplementedError() + + @property + def revoke_certificate(self) -> Callable[ + [service.RevokeCertificateRequest], + Union[ + resources.Certificate, + Awaitable[resources.Certificate] + ]]: + raise NotImplementedError() + + @property + def update_certificate(self) -> Callable[ + [service.UpdateCertificateRequest], + Union[ + resources.Certificate, + Awaitable[resources.Certificate] + ]]: + raise NotImplementedError() + + @property + def activate_certificate_authority(self) -> Callable[ + [service.ActivateCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_certificate_authority(self) -> Callable[ + [service.CreateCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def disable_certificate_authority(self) -> Callable[ + [service.DisableCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def enable_certificate_authority(self) -> Callable[ + [service.EnableCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def fetch_certificate_authority_csr(self) -> Callable[ + [service.FetchCertificateAuthorityCsrRequest], + Union[ + service.FetchCertificateAuthorityCsrResponse, + Awaitable[service.FetchCertificateAuthorityCsrResponse] + ]]: + raise NotImplementedError() + + @property + def get_certificate_authority(self) -> Callable[ + [service.GetCertificateAuthorityRequest], + Union[ + resources.CertificateAuthority, + Awaitable[resources.CertificateAuthority] + ]]: + raise NotImplementedError() + + @property + def list_certificate_authorities(self) -> Callable[ + [service.ListCertificateAuthoritiesRequest], + Union[ + service.ListCertificateAuthoritiesResponse, + Awaitable[service.ListCertificateAuthoritiesResponse] + ]]: + raise NotImplementedError() + + @property + def restore_certificate_authority(self) -> Callable[ + [service.RestoreCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def schedule_delete_certificate_authority(self) -> Callable[ + [service.ScheduleDeleteCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_certificate_authority(self) -> Callable[ + [service.UpdateCertificateAuthorityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_certificate_revocation_list(self) -> Callable[ + [service.GetCertificateRevocationListRequest], + Union[ + resources.CertificateRevocationList, + Awaitable[resources.CertificateRevocationList] + ]]: + raise NotImplementedError() + + @property + def list_certificate_revocation_lists(self) -> Callable[ + [service.ListCertificateRevocationListsRequest], + Union[ + service.ListCertificateRevocationListsResponse, + Awaitable[service.ListCertificateRevocationListsResponse] + ]]: + raise NotImplementedError() + + @property + def update_certificate_revocation_list(self) -> Callable[ + [service.UpdateCertificateRevocationListRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_reusable_config(self) -> Callable[ + [service.GetReusableConfigRequest], + Union[ + resources.ReusableConfig, + Awaitable[resources.ReusableConfig] + ]]: + raise NotImplementedError() + + @property + def list_reusable_configs(self) -> Callable[ + [service.ListReusableConfigsRequest], + Union[ + service.ListReusableConfigsResponse, + Awaitable[service.ListReusableConfigsResponse] + ]]: + raise NotImplementedError() + + +__all__ = ( + 'CertificateAuthorityServiceTransport', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py new file mode 100644 index 0000000..9ab03ab --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py @@ -0,0 +1,814 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.security.privateca_v1beta1.types import resources +from google.cloud.security.privateca_v1beta1.types import service +from google.longrunning import operations_pb2 # type: ignore +from .base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO + + +class CertificateAuthorityServiceGrpcTransport(CertificateAuthorityServiceTransport): + """gRPC backend transport for CertificateAuthorityService. + + [Certificate Authority + Service][google.cloud.security.privateca.v1beta1.CertificateAuthorityService] + manages private certificate authorities and issued certificates. + + 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 = 'privateca.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'privateca.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_certificate(self) -> Callable[ + [service.CreateCertificateRequest], + resources.Certificate]: + r"""Return a callable for the create certificate method over gRPC. + + Create a new + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + in a given Project, Location from a particular + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Returns: + Callable[[~.CreateCertificateRequest], + ~.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 'create_certificate' not in self._stubs: + self._stubs['create_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificate', + request_serializer=service.CreateCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['create_certificate'] + + @property + def get_certificate(self) -> Callable[ + [service.GetCertificateRequest], + resources.Certificate]: + r"""Return a callable for the get certificate method over gRPC. + + Returns a + [Certificate][google.cloud.security.privateca.v1beta1.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.security.privateca.v1beta1.CertificateAuthorityService/GetCertificate', + request_serializer=service.GetCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['get_certificate'] + + @property + def list_certificates(self) -> Callable[ + [service.ListCertificatesRequest], + service.ListCertificatesResponse]: + r"""Return a callable for the list certificates method over gRPC. + + Lists + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + 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.security.privateca.v1beta1.CertificateAuthorityService/ListCertificates', + request_serializer=service.ListCertificatesRequest.serialize, + response_deserializer=service.ListCertificatesResponse.deserialize, + ) + return self._stubs['list_certificates'] + + @property + def revoke_certificate(self) -> Callable[ + [service.RevokeCertificateRequest], + resources.Certificate]: + r"""Return a callable for the revoke certificate method over gRPC. + + Revoke a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + + Returns: + Callable[[~.RevokeCertificateRequest], + ~.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 'revoke_certificate' not in self._stubs: + self._stubs['revoke_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RevokeCertificate', + request_serializer=service.RevokeCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['revoke_certificate'] + + @property + def update_certificate(self) -> Callable[ + [service.UpdateCertificateRequest], + resources.Certificate]: + r"""Return a callable for the update certificate method over gRPC. + + Update a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + Currently, the only field you can update is the + [labels][google.cloud.security.privateca.v1beta1.Certificate.labels] + field. + + Returns: + Callable[[~.UpdateCertificateRequest], + ~.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 'update_certificate' not in self._stubs: + self._stubs['update_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificate', + request_serializer=service.UpdateCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['update_certificate'] + + @property + def activate_certificate_authority(self) -> Callable[ + [service.ActivateCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the activate certificate authority method over gRPC. + + Activate a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + that is in state + [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. + After the parent Certificate Authority signs a certificate + signing request from + [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr], + this method can complete the activation process. + + Returns: + Callable[[~.ActivateCertificateAuthorityRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'activate_certificate_authority' not in self._stubs: + self._stubs['activate_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ActivateCertificateAuthority', + request_serializer=service.ActivateCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['activate_certificate_authority'] + + @property + def create_certificate_authority(self) -> Callable[ + [service.CreateCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the create certificate authority method over gRPC. + + Create a new + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in a given Project and Location. + + Returns: + Callable[[~.CreateCertificateAuthorityRequest], + ~.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_authority' not in self._stubs: + self._stubs['create_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificateAuthority', + request_serializer=service.CreateCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate_authority'] + + @property + def disable_certificate_authority(self) -> Callable[ + [service.DisableCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the disable certificate authority method over gRPC. + + Disable a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Returns: + Callable[[~.DisableCertificateAuthorityRequest], + ~.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 'disable_certificate_authority' not in self._stubs: + self._stubs['disable_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/DisableCertificateAuthority', + request_serializer=service.DisableCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['disable_certificate_authority'] + + @property + def enable_certificate_authority(self) -> Callable[ + [service.EnableCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the enable certificate authority method over gRPC. + + Enable a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Returns: + Callable[[~.EnableCertificateAuthorityRequest], + ~.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 'enable_certificate_authority' not in self._stubs: + self._stubs['enable_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/EnableCertificateAuthority', + request_serializer=service.EnableCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['enable_certificate_authority'] + + @property + def fetch_certificate_authority_csr(self) -> Callable[ + [service.FetchCertificateAuthorityCsrRequest], + service.FetchCertificateAuthorityCsrResponse]: + r"""Return a callable for the fetch certificate authority + csr method over gRPC. + + Fetch a certificate signing request (CSR) from a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + that is in state + [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. + The CSR must then be signed by the desired parent Certificate + Authority, which could be another + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + resource, or could be an on-prem certificate authority. See also + [ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. + + Returns: + Callable[[~.FetchCertificateAuthorityCsrRequest], + ~.FetchCertificateAuthorityCsrResponse]: + 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 'fetch_certificate_authority_csr' not in self._stubs: + self._stubs['fetch_certificate_authority_csr'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/FetchCertificateAuthorityCsr', + request_serializer=service.FetchCertificateAuthorityCsrRequest.serialize, + response_deserializer=service.FetchCertificateAuthorityCsrResponse.deserialize, + ) + return self._stubs['fetch_certificate_authority_csr'] + + @property + def get_certificate_authority(self) -> Callable[ + [service.GetCertificateAuthorityRequest], + resources.CertificateAuthority]: + r"""Return a callable for the get certificate authority method over gRPC. + + Returns a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Returns: + Callable[[~.GetCertificateAuthorityRequest], + ~.CertificateAuthority]: + 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_authority' not in self._stubs: + self._stubs['get_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificateAuthority', + request_serializer=service.GetCertificateAuthorityRequest.serialize, + response_deserializer=resources.CertificateAuthority.deserialize, + ) + return self._stubs['get_certificate_authority'] + + @property + def list_certificate_authorities(self) -> Callable[ + [service.ListCertificateAuthoritiesRequest], + service.ListCertificateAuthoritiesResponse]: + r"""Return a callable for the list certificate authorities method over gRPC. + + Lists + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Returns: + Callable[[~.ListCertificateAuthoritiesRequest], + ~.ListCertificateAuthoritiesResponse]: + 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_authorities' not in self._stubs: + self._stubs['list_certificate_authorities'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificateAuthorities', + request_serializer=service.ListCertificateAuthoritiesRequest.serialize, + response_deserializer=service.ListCertificateAuthoritiesResponse.deserialize, + ) + return self._stubs['list_certificate_authorities'] + + @property + def restore_certificate_authority(self) -> Callable[ + [service.RestoreCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the restore certificate authority method over gRPC. + + Restore a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + that is scheduled for deletion. + + Returns: + Callable[[~.RestoreCertificateAuthorityRequest], + ~.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 'restore_certificate_authority' not in self._stubs: + self._stubs['restore_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RestoreCertificateAuthority', + request_serializer=service.RestoreCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['restore_certificate_authority'] + + @property + def schedule_delete_certificate_authority(self) -> Callable[ + [service.ScheduleDeleteCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the schedule delete certificate + authority method over gRPC. + + Schedule a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + for deletion. + + Returns: + Callable[[~.ScheduleDeleteCertificateAuthorityRequest], + ~.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 'schedule_delete_certificate_authority' not in self._stubs: + self._stubs['schedule_delete_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ScheduleDeleteCertificateAuthority', + request_serializer=service.ScheduleDeleteCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['schedule_delete_certificate_authority'] + + @property + def update_certificate_authority(self) -> Callable[ + [service.UpdateCertificateAuthorityRequest], + operations_pb2.Operation]: + r"""Return a callable for the update certificate authority method over gRPC. + + Update a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Returns: + Callable[[~.UpdateCertificateAuthorityRequest], + ~.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_authority' not in self._stubs: + self._stubs['update_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateAuthority', + request_serializer=service.UpdateCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_authority'] + + @property + def get_certificate_revocation_list(self) -> Callable[ + [service.GetCertificateRevocationListRequest], + resources.CertificateRevocationList]: + r"""Return a callable for the get certificate revocation + list method over gRPC. + + Returns a + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + + Returns: + Callable[[~.GetCertificateRevocationListRequest], + ~.CertificateRevocationList]: + 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_revocation_list' not in self._stubs: + self._stubs['get_certificate_revocation_list'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificateRevocationList', + request_serializer=service.GetCertificateRevocationListRequest.serialize, + response_deserializer=resources.CertificateRevocationList.deserialize, + ) + return self._stubs['get_certificate_revocation_list'] + + @property + def list_certificate_revocation_lists(self) -> Callable[ + [service.ListCertificateRevocationListsRequest], + service.ListCertificateRevocationListsResponse]: + r"""Return a callable for the list certificate revocation + lists method over gRPC. + + Lists + [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + + Returns: + Callable[[~.ListCertificateRevocationListsRequest], + ~.ListCertificateRevocationListsResponse]: + 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_revocation_lists' not in self._stubs: + self._stubs['list_certificate_revocation_lists'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificateRevocationLists', + request_serializer=service.ListCertificateRevocationListsRequest.serialize, + response_deserializer=service.ListCertificateRevocationListsResponse.deserialize, + ) + return self._stubs['list_certificate_revocation_lists'] + + @property + def update_certificate_revocation_list(self) -> Callable[ + [service.UpdateCertificateRevocationListRequest], + operations_pb2.Operation]: + r"""Return a callable for the update certificate revocation + list method over gRPC. + + Update a + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + + Returns: + Callable[[~.UpdateCertificateRevocationListRequest], + ~.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_revocation_list' not in self._stubs: + self._stubs['update_certificate_revocation_list'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateRevocationList', + request_serializer=service.UpdateCertificateRevocationListRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_revocation_list'] + + @property + def get_reusable_config(self) -> Callable[ + [service.GetReusableConfigRequest], + resources.ReusableConfig]: + r"""Return a callable for the get reusable config method over gRPC. + + Returns a + [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig]. + + Returns: + Callable[[~.GetReusableConfigRequest], + ~.ReusableConfig]: + 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_reusable_config' not in self._stubs: + self._stubs['get_reusable_config'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetReusableConfig', + request_serializer=service.GetReusableConfigRequest.serialize, + response_deserializer=resources.ReusableConfig.deserialize, + ) + return self._stubs['get_reusable_config'] + + @property + def list_reusable_configs(self) -> Callable[ + [service.ListReusableConfigsRequest], + service.ListReusableConfigsResponse]: + r"""Return a callable for the list reusable configs method over gRPC. + + Lists + [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig]. + + Returns: + Callable[[~.ListReusableConfigsRequest], + ~.ListReusableConfigsResponse]: + 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_reusable_configs' not in self._stubs: + self._stubs['list_reusable_configs'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListReusableConfigs', + request_serializer=service.ListReusableConfigsRequest.serialize, + response_deserializer=service.ListReusableConfigsResponse.deserialize, + ) + return self._stubs['list_reusable_configs'] + + +__all__ = ( + 'CertificateAuthorityServiceGrpcTransport', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py new file mode 100644 index 0000000..c3515ff --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py @@ -0,0 +1,818 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.security.privateca_v1beta1.types import resources +from google.cloud.security.privateca_v1beta1.types import service +from google.longrunning import operations_pb2 # type: ignore +from .base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import CertificateAuthorityServiceGrpcTransport + + +class CertificateAuthorityServiceGrpcAsyncIOTransport(CertificateAuthorityServiceTransport): + """gRPC AsyncIO backend transport for CertificateAuthorityService. + + [Certificate Authority + Service][google.cloud.security.privateca.v1beta1.CertificateAuthorityService] + manages private certificate authorities and issued certificates. + + 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 = 'privateca.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, + **kwargs + ) + + def __init__(self, *, + host: str = 'privateca.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or applicatin default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_certificate(self) -> Callable[ + [service.CreateCertificateRequest], + Awaitable[resources.Certificate]]: + r"""Return a callable for the create certificate method over gRPC. + + Create a new + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + in a given Project, Location from a particular + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Returns: + Callable[[~.CreateCertificateRequest], + 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 'create_certificate' not in self._stubs: + self._stubs['create_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificate', + request_serializer=service.CreateCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['create_certificate'] + + @property + def get_certificate(self) -> Callable[ + [service.GetCertificateRequest], + Awaitable[resources.Certificate]]: + r"""Return a callable for the get certificate method over gRPC. + + Returns a + [Certificate][google.cloud.security.privateca.v1beta1.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.security.privateca.v1beta1.CertificateAuthorityService/GetCertificate', + request_serializer=service.GetCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['get_certificate'] + + @property + def list_certificates(self) -> Callable[ + [service.ListCertificatesRequest], + Awaitable[service.ListCertificatesResponse]]: + r"""Return a callable for the list certificates method over gRPC. + + Lists + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + 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.security.privateca.v1beta1.CertificateAuthorityService/ListCertificates', + request_serializer=service.ListCertificatesRequest.serialize, + response_deserializer=service.ListCertificatesResponse.deserialize, + ) + return self._stubs['list_certificates'] + + @property + def revoke_certificate(self) -> Callable[ + [service.RevokeCertificateRequest], + Awaitable[resources.Certificate]]: + r"""Return a callable for the revoke certificate method over gRPC. + + Revoke a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + + Returns: + Callable[[~.RevokeCertificateRequest], + 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 'revoke_certificate' not in self._stubs: + self._stubs['revoke_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RevokeCertificate', + request_serializer=service.RevokeCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['revoke_certificate'] + + @property + def update_certificate(self) -> Callable[ + [service.UpdateCertificateRequest], + Awaitable[resources.Certificate]]: + r"""Return a callable for the update certificate method over gRPC. + + Update a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + Currently, the only field you can update is the + [labels][google.cloud.security.privateca.v1beta1.Certificate.labels] + field. + + Returns: + Callable[[~.UpdateCertificateRequest], + 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 'update_certificate' not in self._stubs: + self._stubs['update_certificate'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificate', + request_serializer=service.UpdateCertificateRequest.serialize, + response_deserializer=resources.Certificate.deserialize, + ) + return self._stubs['update_certificate'] + + @property + def activate_certificate_authority(self) -> Callable[ + [service.ActivateCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the activate certificate authority method over gRPC. + + Activate a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + that is in state + [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. + After the parent Certificate Authority signs a certificate + signing request from + [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr], + this method can complete the activation process. + + Returns: + Callable[[~.ActivateCertificateAuthorityRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'activate_certificate_authority' not in self._stubs: + self._stubs['activate_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ActivateCertificateAuthority', + request_serializer=service.ActivateCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['activate_certificate_authority'] + + @property + def create_certificate_authority(self) -> Callable[ + [service.CreateCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create certificate authority method over gRPC. + + Create a new + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in a given Project and Location. + + Returns: + Callable[[~.CreateCertificateAuthorityRequest], + 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_authority' not in self._stubs: + self._stubs['create_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificateAuthority', + request_serializer=service.CreateCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_certificate_authority'] + + @property + def disable_certificate_authority(self) -> Callable[ + [service.DisableCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the disable certificate authority method over gRPC. + + Disable a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Returns: + Callable[[~.DisableCertificateAuthorityRequest], + 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 'disable_certificate_authority' not in self._stubs: + self._stubs['disable_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/DisableCertificateAuthority', + request_serializer=service.DisableCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['disable_certificate_authority'] + + @property + def enable_certificate_authority(self) -> Callable[ + [service.EnableCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the enable certificate authority method over gRPC. + + Enable a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Returns: + Callable[[~.EnableCertificateAuthorityRequest], + 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 'enable_certificate_authority' not in self._stubs: + self._stubs['enable_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/EnableCertificateAuthority', + request_serializer=service.EnableCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['enable_certificate_authority'] + + @property + def fetch_certificate_authority_csr(self) -> Callable[ + [service.FetchCertificateAuthorityCsrRequest], + Awaitable[service.FetchCertificateAuthorityCsrResponse]]: + r"""Return a callable for the fetch certificate authority + csr method over gRPC. + + Fetch a certificate signing request (CSR) from a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + that is in state + [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] + and is of type + [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. + The CSR must then be signed by the desired parent Certificate + Authority, which could be another + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + resource, or could be an on-prem certificate authority. See also + [ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. + + Returns: + Callable[[~.FetchCertificateAuthorityCsrRequest], + Awaitable[~.FetchCertificateAuthorityCsrResponse]]: + 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 'fetch_certificate_authority_csr' not in self._stubs: + self._stubs['fetch_certificate_authority_csr'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/FetchCertificateAuthorityCsr', + request_serializer=service.FetchCertificateAuthorityCsrRequest.serialize, + response_deserializer=service.FetchCertificateAuthorityCsrResponse.deserialize, + ) + return self._stubs['fetch_certificate_authority_csr'] + + @property + def get_certificate_authority(self) -> Callable[ + [service.GetCertificateAuthorityRequest], + Awaitable[resources.CertificateAuthority]]: + r"""Return a callable for the get certificate authority method over gRPC. + + Returns a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Returns: + Callable[[~.GetCertificateAuthorityRequest], + Awaitable[~.CertificateAuthority]]: + 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_authority' not in self._stubs: + self._stubs['get_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificateAuthority', + request_serializer=service.GetCertificateAuthorityRequest.serialize, + response_deserializer=resources.CertificateAuthority.deserialize, + ) + return self._stubs['get_certificate_authority'] + + @property + def list_certificate_authorities(self) -> Callable[ + [service.ListCertificateAuthoritiesRequest], + Awaitable[service.ListCertificateAuthoritiesResponse]]: + r"""Return a callable for the list certificate authorities method over gRPC. + + Lists + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Returns: + Callable[[~.ListCertificateAuthoritiesRequest], + Awaitable[~.ListCertificateAuthoritiesResponse]]: + 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_authorities' not in self._stubs: + self._stubs['list_certificate_authorities'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificateAuthorities', + request_serializer=service.ListCertificateAuthoritiesRequest.serialize, + response_deserializer=service.ListCertificateAuthoritiesResponse.deserialize, + ) + return self._stubs['list_certificate_authorities'] + + @property + def restore_certificate_authority(self) -> Callable[ + [service.RestoreCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the restore certificate authority method over gRPC. + + Restore a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + that is scheduled for deletion. + + Returns: + Callable[[~.RestoreCertificateAuthorityRequest], + 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 'restore_certificate_authority' not in self._stubs: + self._stubs['restore_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RestoreCertificateAuthority', + request_serializer=service.RestoreCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['restore_certificate_authority'] + + @property + def schedule_delete_certificate_authority(self) -> Callable[ + [service.ScheduleDeleteCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the schedule delete certificate + authority method over gRPC. + + Schedule a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + for deletion. + + Returns: + Callable[[~.ScheduleDeleteCertificateAuthorityRequest], + 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 'schedule_delete_certificate_authority' not in self._stubs: + self._stubs['schedule_delete_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ScheduleDeleteCertificateAuthority', + request_serializer=service.ScheduleDeleteCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['schedule_delete_certificate_authority'] + + @property + def update_certificate_authority(self) -> Callable[ + [service.UpdateCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update certificate authority method over gRPC. + + Update a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Returns: + Callable[[~.UpdateCertificateAuthorityRequest], + 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_authority' not in self._stubs: + self._stubs['update_certificate_authority'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateAuthority', + request_serializer=service.UpdateCertificateAuthorityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_authority'] + + @property + def get_certificate_revocation_list(self) -> Callable[ + [service.GetCertificateRevocationListRequest], + Awaitable[resources.CertificateRevocationList]]: + r"""Return a callable for the get certificate revocation + list method over gRPC. + + Returns a + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + + Returns: + Callable[[~.GetCertificateRevocationListRequest], + Awaitable[~.CertificateRevocationList]]: + 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_revocation_list' not in self._stubs: + self._stubs['get_certificate_revocation_list'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificateRevocationList', + request_serializer=service.GetCertificateRevocationListRequest.serialize, + response_deserializer=resources.CertificateRevocationList.deserialize, + ) + return self._stubs['get_certificate_revocation_list'] + + @property + def list_certificate_revocation_lists(self) -> Callable[ + [service.ListCertificateRevocationListsRequest], + Awaitable[service.ListCertificateRevocationListsResponse]]: + r"""Return a callable for the list certificate revocation + lists method over gRPC. + + Lists + [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + + Returns: + Callable[[~.ListCertificateRevocationListsRequest], + Awaitable[~.ListCertificateRevocationListsResponse]]: + 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_revocation_lists' not in self._stubs: + self._stubs['list_certificate_revocation_lists'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificateRevocationLists', + request_serializer=service.ListCertificateRevocationListsRequest.serialize, + response_deserializer=service.ListCertificateRevocationListsResponse.deserialize, + ) + return self._stubs['list_certificate_revocation_lists'] + + @property + def update_certificate_revocation_list(self) -> Callable[ + [service.UpdateCertificateRevocationListRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update certificate revocation + list method over gRPC. + + Update a + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + + Returns: + Callable[[~.UpdateCertificateRevocationListRequest], + 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_revocation_list' not in self._stubs: + self._stubs['update_certificate_revocation_list'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateRevocationList', + request_serializer=service.UpdateCertificateRevocationListRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_certificate_revocation_list'] + + @property + def get_reusable_config(self) -> Callable[ + [service.GetReusableConfigRequest], + Awaitable[resources.ReusableConfig]]: + r"""Return a callable for the get reusable config method over gRPC. + + Returns a + [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig]. + + Returns: + Callable[[~.GetReusableConfigRequest], + Awaitable[~.ReusableConfig]]: + 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_reusable_config' not in self._stubs: + self._stubs['get_reusable_config'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetReusableConfig', + request_serializer=service.GetReusableConfigRequest.serialize, + response_deserializer=resources.ReusableConfig.deserialize, + ) + return self._stubs['get_reusable_config'] + + @property + def list_reusable_configs(self) -> Callable[ + [service.ListReusableConfigsRequest], + Awaitable[service.ListReusableConfigsResponse]]: + r"""Return a callable for the list reusable configs method over gRPC. + + Lists + [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig]. + + Returns: + Callable[[~.ListReusableConfigsRequest], + Awaitable[~.ListReusableConfigsResponse]]: + 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_reusable_configs' not in self._stubs: + self._stubs['list_reusable_configs'] = self.grpc_channel.unary_unary( + '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListReusableConfigs', + request_serializer=service.ListReusableConfigsRequest.serialize, + response_deserializer=service.ListReusableConfigsResponse.deserialize, + ) + return self._stubs['list_reusable_configs'] + + +__all__ = ( + 'CertificateAuthorityServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/__init__.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/__init__.py new file mode 100644 index 0000000..30b7963 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/__init__.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 .resources import ( + Certificate, + CertificateAuthority, + CertificateConfig, + CertificateDescription, + CertificateRevocationList, + KeyUsage, + ObjectId, + PublicKey, + ReusableConfig, + ReusableConfigValues, + ReusableConfigWrapper, + Subject, + SubjectAltNames, + SubordinateConfig, + X509Extension, + RevocationReason, +) +from .service import ( + ActivateCertificateAuthorityRequest, + CreateCertificateAuthorityRequest, + CreateCertificateRequest, + DisableCertificateAuthorityRequest, + EnableCertificateAuthorityRequest, + FetchCertificateAuthorityCsrRequest, + FetchCertificateAuthorityCsrResponse, + GetCertificateAuthorityRequest, + GetCertificateRequest, + GetCertificateRevocationListRequest, + GetReusableConfigRequest, + ListCertificateAuthoritiesRequest, + ListCertificateAuthoritiesResponse, + ListCertificateRevocationListsRequest, + ListCertificateRevocationListsResponse, + ListCertificatesRequest, + ListCertificatesResponse, + ListReusableConfigsRequest, + ListReusableConfigsResponse, + OperationMetadata, + RestoreCertificateAuthorityRequest, + RevokeCertificateRequest, + ScheduleDeleteCertificateAuthorityRequest, + UpdateCertificateAuthorityRequest, + UpdateCertificateRequest, + UpdateCertificateRevocationListRequest, +) + +__all__ = ( + 'Certificate', + 'CertificateAuthority', + 'CertificateConfig', + 'CertificateDescription', + 'CertificateRevocationList', + 'KeyUsage', + 'ObjectId', + 'PublicKey', + 'ReusableConfig', + 'ReusableConfigValues', + 'ReusableConfigWrapper', + 'Subject', + 'SubjectAltNames', + 'SubordinateConfig', + 'X509Extension', + 'RevocationReason', + 'ActivateCertificateAuthorityRequest', + 'CreateCertificateAuthorityRequest', + 'CreateCertificateRequest', + 'DisableCertificateAuthorityRequest', + 'EnableCertificateAuthorityRequest', + 'FetchCertificateAuthorityCsrRequest', + 'FetchCertificateAuthorityCsrResponse', + 'GetCertificateAuthorityRequest', + 'GetCertificateRequest', + 'GetCertificateRevocationListRequest', + 'GetReusableConfigRequest', + 'ListCertificateAuthoritiesRequest', + 'ListCertificateAuthoritiesResponse', + 'ListCertificateRevocationListsRequest', + 'ListCertificateRevocationListsResponse', + 'ListCertificatesRequest', + 'ListCertificatesResponse', + 'ListReusableConfigsRequest', + 'ListReusableConfigsResponse', + 'OperationMetadata', + 'RestoreCertificateAuthorityRequest', + 'RevokeCertificateRequest', + 'ScheduleDeleteCertificateAuthorityRequest', + 'UpdateCertificateAuthorityRequest', + 'UpdateCertificateRequest', + 'UpdateCertificateRevocationListRequest', +) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/resources.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/resources.py new file mode 100644 index 0000000..ec1ccf3 --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/resources.py @@ -0,0 +1,1687 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import proto # type: ignore + +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.security.privateca.v1beta1', + manifest={ + 'RevocationReason', + 'CertificateAuthority', + 'CertificateRevocationList', + 'Certificate', + 'ReusableConfig', + 'ReusableConfigValues', + 'ReusableConfigWrapper', + 'SubordinateConfig', + 'PublicKey', + 'CertificateConfig', + 'CertificateDescription', + 'ObjectId', + 'X509Extension', + 'KeyUsage', + 'Subject', + 'SubjectAltNames', + }, +) + + +class RevocationReason(proto.Enum): + r"""A + [RevocationReason][google.cloud.security.privateca.v1beta1.RevocationReason] + indicates whether a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + has been revoked, and the reason for revocation. These correspond to + standard revocation reasons from RFC 5280. Note that the enum labels + and values in this definition are not the same ASN.1 values defined + in RFC 5280. These values will be translated to the correct ASN.1 + values when a CRL is created. + """ + REVOCATION_REASON_UNSPECIFIED = 0 + KEY_COMPROMISE = 1 + CERTIFICATE_AUTHORITY_COMPROMISE = 2 + AFFILIATION_CHANGED = 3 + SUPERSEDED = 4 + CESSATION_OF_OPERATION = 5 + CERTIFICATE_HOLD = 6 + PRIVILEGE_WITHDRAWN = 7 + ATTRIBUTE_AUTHORITY_COMPROMISE = 8 + + +class CertificateAuthority(proto.Message): + r"""A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + represents an individual Certificate Authority. A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can be used to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + Attributes: + name (str): + Output only. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + type_ (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.Type): + Required. Immutable. The + [Type][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type] + of this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + tier (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.Tier): + Required. Immutable. The + [Tier][google.cloud.security.privateca.v1beta1.CertificateAuthority.Tier] + of this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + config (google.cloud.security.privateca_v1beta1.types.CertificateConfig): + Required. Immutable. The config used to + create a self-signed X.509 certificate or CSR. + lifetime (google.protobuf.duration_pb2.Duration): + Required. The desired lifetime of the CA certificate. Used + to create the "not_before_time" and "not_after_time" fields + inside an X.509 certificate. + key_spec (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.KeyVersionSpec): + Required. Immutable. Used when issuing certificates for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + If this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + is a self-signed CertificateAuthority, this key is also used + to sign the self-signed CA certificate. Otherwise, it is + used to sign a CSR. + certificate_policy (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.CertificateAuthorityPolicy): + Optional. The + [CertificateAuthorityPolicy][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy] + to enforce when issuing + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + from this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + issuing_options (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.IssuingOptions): + Optional. The + [IssuingOptions][google.cloud.security.privateca.v1beta1.CertificateAuthority.IssuingOptions] + to follow when issuing + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + from this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + subordinate_config (google.cloud.security.privateca_v1beta1.types.SubordinateConfig): + Optional. If this is a subordinate + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority], + this field will be set with the subordinate configuration, + which describes its issuers. This may be updated, but this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + must continue to validate. + state (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.State): + Output only. The + [State][google.cloud.security.privateca.v1beta1.CertificateAuthority.State] + for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + pem_ca_certificates (Sequence[str]): + Output only. This + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]'s + certificate chain, including the current + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]'s + certificate. Ordered such that the root issuer is the final + element (consistent with RFC 5246). For a self-signed CA, + this will only list the current + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]'s + certificate. + ca_certificate_descriptions (Sequence[google.cloud.security.privateca_v1beta1.types.CertificateDescription]): + Output only. A structured description of this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]'s + CA certificate and its issuers. Ordered as self-to-root. + gcs_bucket (str): + Immutable. The name of a Cloud Storage bucket where this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + will publish content, such as the CA certificate and CRLs. + This must be a bucket name, without any prefixes (such as + ``gs://``) or suffixes (such as ``.googleapis.com``). For + example, to use a bucket named ``my-bucket``, you would + simply specify ``my-bucket``. If not specified, a managed + bucket will be created. + access_urls (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.AccessUrls): + Output only. URLs for accessing content + published by this CA, such as the CA certificate + and CRLs. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + was updated. + delete_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + will be deleted, if scheduled for deletion. + labels (Sequence[google.cloud.security.privateca_v1beta1.types.CertificateAuthority.LabelsEntry]): + Optional. Labels with user-defined metadata. + """ + class Type(proto.Enum): + r"""The type of a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority], + indicating its issuing chain. + """ + TYPE_UNSPECIFIED = 0 + SELF_SIGNED = 1 + SUBORDINATE = 2 + + class Tier(proto.Enum): + r"""The tier of a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority], + indicating its supported functionality and/or billing SKU. + """ + TIER_UNSPECIFIED = 0 + ENTERPRISE = 1 + DEVOPS = 2 + + class State(proto.Enum): + r"""The state of a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority], + indicating if it can be used. + """ + STATE_UNSPECIFIED = 0 + ENABLED = 1 + DISABLED = 2 + PENDING_ACTIVATION = 3 + PENDING_DELETION = 4 + + class SignHashAlgorithm(proto.Enum): + r"""The algorithm of a Cloud KMS CryptoKeyVersion of a + [CryptoKey][google.cloud.kms.v1.CryptoKey] with the + [CryptoKeyPurpose][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose] + value ``ASYMMETRIC_SIGN``. These values correspond to the + [CryptoKeyVersionAlgorithm][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionAlgorithm] + values. For RSA signing algorithms, the PSS algorithms should be + preferred, use PKCS1 algorithms if required for compatibility. For + further recommandations, see + https://cloud.google.com/kms/docs/algorithms#algorithm_recommendations. + """ + SIGN_HASH_ALGORITHM_UNSPECIFIED = 0 + RSA_PSS_2048_SHA256 = 1 + RSA_PSS_3072_SHA256 = 2 + RSA_PSS_4096_SHA256 = 3 + RSA_PKCS1_2048_SHA256 = 6 + RSA_PKCS1_3072_SHA256 = 7 + RSA_PKCS1_4096_SHA256 = 8 + EC_P256_SHA256 = 4 + EC_P384_SHA384 = 5 + + class IssuingOptions(proto.Message): + r"""Options that affect all certificates issued by a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Attributes: + include_ca_cert_url (bool): + Required. When true, includes a URL to the + issuing CA certificate in the "authority + information access" X.509 extension. + include_crl_access_url (bool): + Required. When true, includes a URL to the CRL corresponding + to certificates issued from a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + CRLs will expire 7 days from their creation. However, we + will rebuild daily. CRLs are also rebuilt shortly after a + certificate is revoked. + """ + + include_ca_cert_url = proto.Field( + proto.BOOL, + number=1, + ) + include_crl_access_url = proto.Field( + proto.BOOL, + number=2, + ) + + class CertificateAuthorityPolicy(proto.Message): + r"""The issuing policy for a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + will not be successfully issued from this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + if they violate the policy. + + Attributes: + allowed_config_list (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.CertificateAuthorityPolicy.AllowedConfigList): + Optional. All + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + issued by the + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + must match at least one listed + [ReusableConfigWrapper][google.cloud.security.privateca.v1beta1.ReusableConfigWrapper] + in the list. + overwrite_config_values (google.cloud.security.privateca_v1beta1.types.ReusableConfigWrapper): + Optional. All + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + issued by the + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + will use the provided configuration values, overwriting any + requested configuration values. + allowed_locations_and_organizations (Sequence[google.cloud.security.privateca_v1beta1.types.Subject]): + Optional. If any + [Subject][google.cloud.security.privateca.v1beta1.Subject] + is specified here, then all + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + issued by the + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + must match at least one listed + [Subject][google.cloud.security.privateca.v1beta1.Subject]. + If a + [Subject][google.cloud.security.privateca.v1beta1.Subject] + has an empty field, any value will be allowed for that + field. + allowed_common_names (Sequence[str]): + Optional. If any value is specified here, then all + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + issued by the + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + must match at least one listed value. If no value is + specified, all values will be allowed for this fied. Glob + patterns are also supported. + allowed_sans (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames): + Optional. If a + [AllowedSubjectAltNames][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames] + is specified here, then all + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + issued by the + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + must match + [AllowedSubjectAltNames][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames]. + If no value or an empty value is specified, any value will + be allowed for the + [SubjectAltNames][google.cloud.security.privateca.v1beta1.SubjectAltNames] + field. + maximum_lifetime (google.protobuf.duration_pb2.Duration): + Optional. The maximum lifetime allowed by the + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + Note that if the any part if the issuing chain expires + before a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]'s + requested maximum_lifetime, the effective lifetime will be + explicitly truncated. + allowed_issuance_modes (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.CertificateAuthorityPolicy.IssuanceModes): + Optional. If specified, then only methods allowed in the + [IssuanceModes][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.IssuanceModes] + may be used to issue + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + """ + + class AllowedConfigList(proto.Message): + r""" + Attributes: + allowed_config_values (Sequence[google.cloud.security.privateca_v1beta1.types.ReusableConfigWrapper]): + Required. All + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + issued by the + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + must match at least one listed + [ReusableConfigWrapper][google.cloud.security.privateca.v1beta1.ReusableConfigWrapper]. + If a + [ReusableConfigWrapper][google.cloud.security.privateca.v1beta1.ReusableConfigWrapper] + has an empty field, any value will be allowed for that + field. + """ + + allowed_config_values = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='ReusableConfigWrapper', + ) + + class AllowedSubjectAltNames(proto.Message): + r"""[AllowedSubjectAltNames][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames] + specifies the allowed values for + [SubjectAltNames][google.cloud.security.privateca.v1beta1.SubjectAltNames] + by the + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + when issuing + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + + Attributes: + allowed_dns_names (Sequence[str]): + Optional. Contains valid, fully-qualified host names. Glob + patterns are also supported. To allow an explicit wildcard + certificate, escape with backlash (i.e. "*"). E.g. for + globbed entries: '*bar.com' will allow foo.bar.com, but not + *.bar.com, unless the + [allow_globbing_dns_wildcards][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames.allow_globbing_dns_wildcards] + field is set. E.g. for wildcard entries: '*.bar.com' will + allow '*.bar.com', but not 'foo.bar.com'. + allowed_uris (Sequence[str]): + Optional. Contains valid RFC 3986 URIs. Glob patterns are + also supported. To match across path seperators (i.e. '/') + use the double star glob pattern (i.e. '**'). + allowed_email_addresses (Sequence[str]): + Optional. Contains valid RFC 2822 E-mail + addresses. Glob patterns are also supported. + allowed_ips (Sequence[str]): + Optional. Contains valid 32-bit IPv4 + addresses and subnet ranges or RFC 4291 IPv6 + addresses and subnet ranges. Subnet ranges are + specified using the '/' notation (e.g. + 10.0.0.0/8, 2001:700:300:1800::/64). Glob + patterns are supported only for ip address + entries (i.e. not for subnet ranges). + allow_globbing_dns_wildcards (bool): + Optional. Specifies if glob patterns used for + [allowed_dns_names][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames.allowed_dns_names] + allows wildcard certificates. + allow_custom_sans (bool): + Optional. Specifies if to allow custom + X509Extension values. + """ + + allowed_dns_names = proto.RepeatedField( + proto.STRING, + number=1, + ) + allowed_uris = proto.RepeatedField( + proto.STRING, + number=2, + ) + allowed_email_addresses = proto.RepeatedField( + proto.STRING, + number=3, + ) + allowed_ips = proto.RepeatedField( + proto.STRING, + number=4, + ) + allow_globbing_dns_wildcards = proto.Field( + proto.BOOL, + number=5, + ) + allow_custom_sans = proto.Field( + proto.BOOL, + number=6, + ) + + class IssuanceModes(proto.Message): + r"""[IssuanceModes][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.IssuanceModes] + specifies the allowed ways in which + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + may be requested from this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Attributes: + allow_csr_based_issuance (bool): + Required. When true, allows callers to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + by specifying a CSR. + allow_config_based_issuance (bool): + Required. When true, allows callers to create + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + by specifying a + [CertificateConfig][google.cloud.security.privateca.v1beta1.CertificateConfig]. + """ + + allow_csr_based_issuance = proto.Field( + proto.BOOL, + number=1, + ) + allow_config_based_issuance = proto.Field( + proto.BOOL, + number=2, + ) + + allowed_config_list = proto.Field( + proto.MESSAGE, + number=1, + oneof='config_policy', + message='CertificateAuthority.CertificateAuthorityPolicy.AllowedConfigList', + ) + overwrite_config_values = proto.Field( + proto.MESSAGE, + number=2, + oneof='config_policy', + message='ReusableConfigWrapper', + ) + allowed_locations_and_organizations = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='Subject', + ) + allowed_common_names = proto.RepeatedField( + proto.STRING, + number=4, + ) + allowed_sans = proto.Field( + proto.MESSAGE, + number=5, + message='CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames', + ) + maximum_lifetime = proto.Field( + proto.MESSAGE, + number=6, + message=duration_pb2.Duration, + ) + allowed_issuance_modes = proto.Field( + proto.MESSAGE, + number=8, + message='CertificateAuthority.CertificateAuthorityPolicy.IssuanceModes', + ) + + class AccessUrls(proto.Message): + r"""URLs where a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + will publish content. + + Attributes: + ca_certificate_access_url (str): + The URL where this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]'s + CA certificate is published. This will only be set for CAs + that have been activated. + crl_access_url (str): + The URL where this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]'s + CRLs are published. This will only be set for CAs that have + been activated. + """ + + ca_certificate_access_url = proto.Field( + proto.STRING, + number=1, + ) + crl_access_url = proto.Field( + proto.STRING, + number=2, + ) + + class KeyVersionSpec(proto.Message): + r"""A Cloud KMS key configuration that a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + will use. + + Attributes: + cloud_kms_key_version (str): + Required. The resource name for an existing Cloud KMS + CryptoKeyVersion in the format + ``projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*``. + This option enables full flexibility in the key's + capabilities and properties. + algorithm (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.SignHashAlgorithm): + Required. The algorithm to use for creating a managed Cloud + KMS key for a for a simplified experience. All managed keys + will be have their + [ProtectionLevel][google.cloud.kms.v1.ProtectionLevel] as + ``HSM``. + """ + + cloud_kms_key_version = proto.Field( + proto.STRING, + number=1, + oneof='KeyVersion', + ) + algorithm = proto.Field( + proto.ENUM, + number=2, + oneof='KeyVersion', + enum='CertificateAuthority.SignHashAlgorithm', + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + type_ = proto.Field( + proto.ENUM, + number=2, + enum=Type, + ) + tier = proto.Field( + proto.ENUM, + number=3, + enum=Tier, + ) + config = proto.Field( + proto.MESSAGE, + number=4, + message='CertificateConfig', + ) + lifetime = proto.Field( + proto.MESSAGE, + number=5, + message=duration_pb2.Duration, + ) + key_spec = proto.Field( + proto.MESSAGE, + number=6, + message=KeyVersionSpec, + ) + certificate_policy = proto.Field( + proto.MESSAGE, + number=7, + message=CertificateAuthorityPolicy, + ) + issuing_options = proto.Field( + proto.MESSAGE, + number=8, + message=IssuingOptions, + ) + subordinate_config = proto.Field( + proto.MESSAGE, + number=19, + message='SubordinateConfig', + ) + state = proto.Field( + proto.ENUM, + number=10, + enum=State, + ) + pem_ca_certificates = proto.RepeatedField( + proto.STRING, + number=9, + ) + ca_certificate_descriptions = proto.RepeatedField( + proto.MESSAGE, + number=12, + message='CertificateDescription', + ) + gcs_bucket = proto.Field( + proto.STRING, + number=13, + ) + access_urls = proto.Field( + proto.MESSAGE, + number=14, + message=AccessUrls, + ) + create_time = proto.Field( + proto.MESSAGE, + number=15, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=16, + message=timestamp_pb2.Timestamp, + ) + delete_time = proto.Field( + proto.MESSAGE, + number=17, + message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=18, + ) + + +class CertificateRevocationList(proto.Message): + r"""A + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] + corresponds to a signed X.509 certificate Revocation List (CRL). A + CRL contains the serial numbers of certificates that should no + longer be trusted. + + Attributes: + name (str): + Output only. The resource path for this + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] + in the format + ``projects/*/locations/*/certificateAuthorities/*/ certificateRevocationLists/*``. + sequence_number (int): + Output only. The CRL sequence number that appears in + pem_crl. + revoked_certificates (Sequence[google.cloud.security.privateca_v1beta1.types.CertificateRevocationList.RevokedCertificate]): + Output only. The revoked serial numbers that appear in + pem_crl. + pem_crl (str): + Output only. The PEM-encoded X.509 CRL. + access_url (str): + Output only. The location where 'pem_crl' can be accessed. + state (google.cloud.security.privateca_v1beta1.types.CertificateRevocationList.State): + Output only. The + [State][google.cloud.security.privateca.v1beta1.CertificateRevocationList.State] + for this + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] + was updated. + labels (Sequence[google.cloud.security.privateca_v1beta1.types.CertificateRevocationList.LabelsEntry]): + Optional. Labels with user-defined metadata. + """ + class State(proto.Enum): + r"""The state of a + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList], + indicating if it is current. + """ + STATE_UNSPECIFIED = 0 + ACTIVE = 1 + SUPERSEDED = 2 + + class RevokedCertificate(proto.Message): + r"""Describes a revoked + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + + Attributes: + certificate (str): + The resource path for the + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + in the format + ``projects/*/locations/*/certificateAuthorities/*/certificates/*``. + hex_serial_number (str): + The serial number of the + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + revocation_reason (google.cloud.security.privateca_v1beta1.types.RevocationReason): + The reason the + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + was revoked. + """ + + certificate = proto.Field( + proto.STRING, + number=1, + ) + hex_serial_number = proto.Field( + proto.STRING, + number=2, + ) + revocation_reason = proto.Field( + proto.ENUM, + number=3, + enum='RevocationReason', + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + sequence_number = proto.Field( + proto.INT64, + number=2, + ) + revoked_certificates = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=RevokedCertificate, + ) + pem_crl = proto.Field( + proto.STRING, + number=4, + ) + access_url = proto.Field( + proto.STRING, + number=5, + ) + state = proto.Field( + proto.ENUM, + number=6, + enum=State, + ) + create_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=9, + ) + + +class Certificate(proto.Message): + r"""A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + corresponds to a signed X.509 certificate issued by a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + + Attributes: + name (str): + Output only. The resource path for this + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + in the format + ``projects/*/locations/*/certificateAuthorities/*/certificates/*``. + pem_csr (str): + Immutable. A pem-encoded X.509 certificate + signing request (CSR). + config (google.cloud.security.privateca_v1beta1.types.CertificateConfig): + Immutable. A description of the certificate + and key that does not require X.509 or ASN.1. + lifetime (google.protobuf.duration_pb2.Duration): + Required. Immutable. The desired lifetime of a certificate. + Used to create the "not_before_time" and "not_after_time" + fields inside an X.509 certificate. Note that the lifetime + may be truncated if it would extend past the life of any + certificate authority in the issuing chain. + revocation_details (google.cloud.security.privateca_v1beta1.types.Certificate.RevocationDetails): + Output only. Details regarding the revocation of this + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + This + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + is considered revoked if and only if this field is present. + pem_certificate (str): + Output only. The pem-encoded, signed X.509 + certificate. + certificate_description (google.cloud.security.privateca_v1beta1.types.CertificateDescription): + Output only. A structured description of the + issued X.509 certificate. + pem_certificate_chain (Sequence[str]): + Output only. The chain that may be used to + verify the X.509 certificate. Expected to be in + issuer-to-root order according to RFC 5246. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + was updated. + labels (Sequence[google.cloud.security.privateca_v1beta1.types.Certificate.LabelsEntry]): + Optional. Labels with user-defined metadata. + """ + + class RevocationDetails(proto.Message): + r"""Describes fields that are relavent to the revocation of a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. + + Attributes: + revocation_state (google.cloud.security.privateca_v1beta1.types.RevocationReason): + Indicates why a + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + was revoked. + revocation_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which this + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + was revoked. + """ + + revocation_state = proto.Field( + proto.ENUM, + number=1, + enum='RevocationReason', + ) + revocation_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + pem_csr = proto.Field( + proto.STRING, + number=2, + oneof='certificate_config', + ) + config = proto.Field( + proto.MESSAGE, + number=3, + oneof='certificate_config', + message='CertificateConfig', + ) + lifetime = proto.Field( + proto.MESSAGE, + number=4, + message=duration_pb2.Duration, + ) + revocation_details = proto.Field( + proto.MESSAGE, + number=5, + message=RevocationDetails, + ) + pem_certificate = proto.Field( + proto.STRING, + number=6, + ) + certificate_description = proto.Field( + proto.MESSAGE, + number=7, + message='CertificateDescription', + ) + pem_certificate_chain = proto.RepeatedField( + proto.STRING, + number=8, + ) + create_time = proto.Field( + proto.MESSAGE, + number=9, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=10, + message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=11, + ) + + +class ReusableConfig(proto.Message): + r"""A + [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] + refers to a managed + [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues]. + Those, in turn, are used to describe certain fields of an X.509 + certificate, such as the key usage fields, fields specific to CA + certificates, certificate policy extensions and custom extensions. + + Attributes: + name (str): + Output only. The resource path for this + [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] + in the format ``projects/*/locations/*/reusableConfigs/*``. + values (google.cloud.security.privateca_v1beta1.types.ReusableConfigValues): + Required. The config values. + description (str): + Optional. A human-readable description of + scenarios these ReusableConfigValues may be + compatible with. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this + [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] + was updated. + labels (Sequence[google.cloud.security.privateca_v1beta1.types.ReusableConfig.LabelsEntry]): + Optional. Labels with user-defined metadata. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + values = proto.Field( + proto.MESSAGE, + number=2, + message='ReusableConfigValues', + ) + description = proto.Field( + proto.STRING, + number=3, + ) + create_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=6, + ) + + +class ReusableConfigValues(proto.Message): + r"""A + [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues] + is used to describe certain fields of an X.509 certificate, such as + the key usage fields, fields specific to CA certificates, + certificate policy extensions and custom extensions. + + Attributes: + key_usage (google.cloud.security.privateca_v1beta1.types.KeyUsage): + Optional. Indicates the intended use for keys + that correspond to a certificate. + ca_options (google.cloud.security.privateca_v1beta1.types.ReusableConfigValues.CaOptions): + Optional. Describes options in this + [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues] + that are relevant in a CA certificate. + policy_ids (Sequence[google.cloud.security.privateca_v1beta1.types.ObjectId]): + Optional. Describes the X.509 certificate + policy object identifiers, per + https://tools.ietf.org/html/rfc5280#section-4.2.1.4. + aia_ocsp_servers (Sequence[str]): + Optional. Describes Online Certificate Status + Protocol (OCSP) endpoint addresses that appear + in the "Authority Information Access" extension + in the certificate. + additional_extensions (Sequence[google.cloud.security.privateca_v1beta1.types.X509Extension]): + Optional. Describes custom X.509 extensions. + """ + + class CaOptions(proto.Message): + r"""Describes values that are relevant in a CA certificate. + Attributes: + is_ca (google.protobuf.wrappers_pb2.BoolValue): + Optional. Refers to the "CA" X.509 extension, + which is a boolean value. When this value is + missing, the extension will be omitted from the + CA certificate. + max_issuer_path_length (google.protobuf.wrappers_pb2.Int32Value): + Optional. Refers to the path length + restriction X.509 extension. For a CA + certificate, this value describes the depth of + subordinate CA certificates that are allowed. + If this value is less than 0, the request will + fail. If this value is missing, the max path + length will be omitted from the CA certificate. + """ + + is_ca = proto.Field( + proto.MESSAGE, + number=1, + message=wrappers_pb2.BoolValue, + ) + max_issuer_path_length = proto.Field( + proto.MESSAGE, + number=2, + message=wrappers_pb2.Int32Value, + ) + + key_usage = proto.Field( + proto.MESSAGE, + number=1, + message='KeyUsage', + ) + ca_options = proto.Field( + proto.MESSAGE, + number=2, + message=CaOptions, + ) + policy_ids = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='ObjectId', + ) + aia_ocsp_servers = proto.RepeatedField( + proto.STRING, + number=4, + ) + additional_extensions = proto.RepeatedField( + proto.MESSAGE, + number=5, + message='X509Extension', + ) + + +class ReusableConfigWrapper(proto.Message): + r"""A + [ReusableConfigWrapper][google.cloud.security.privateca.v1beta1.ReusableConfigWrapper] + describes values that may assist in creating an X.509 certificate, + or a reference to a pre-defined set of values. + + Attributes: + reusable_config (str): + Required. A resource path to a + [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] + in the format ``projects/*/locations/*/reusableConfigs/*``. + reusable_config_values (google.cloud.security.privateca_v1beta1.types.ReusableConfigValues): + Required. A user-specified inline + [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues]. + """ + + reusable_config = proto.Field( + proto.STRING, + number=1, + oneof='config_values', + ) + reusable_config_values = proto.Field( + proto.MESSAGE, + number=2, + oneof='config_values', + message='ReusableConfigValues', + ) + + +class SubordinateConfig(proto.Message): + r"""Describes a subordinate CA's issuers. This is either a resource path + to a known issuing + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority], + or a PEM issuer certificate chain. + + Attributes: + certificate_authority (str): + Required. This can refer to a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the same project that was used to create a subordinate + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + This field is used for information and usability purposes + only. The resource name is in the format + ``projects/*/locations/*/certificateAuthorities/*``. + pem_issuer_chain (google.cloud.security.privateca_v1beta1.types.SubordinateConfig.SubordinateConfigChain): + Required. Contains the PEM certificate chain for the issuers + of this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority], + but not pem certificate for this CA itself. + """ + + class SubordinateConfigChain(proto.Message): + r"""This message describes a subordinate CA's issuer certificate + chain. This wrapper exists for compatibility reasons. + + Attributes: + pem_certificates (Sequence[str]): + Required. Expected to be in leaf-to-root + order according to RFC 5246. + """ + + pem_certificates = proto.RepeatedField( + proto.STRING, + number=1, + ) + + certificate_authority = proto.Field( + proto.STRING, + number=1, + oneof='subordinate_config', + ) + pem_issuer_chain = proto.Field( + proto.MESSAGE, + number=2, + oneof='subordinate_config', + message=SubordinateConfigChain, + ) + + +class PublicKey(proto.Message): + r"""A [PublicKey][google.cloud.security.privateca.v1beta1.PublicKey] + describes a public key. + + Attributes: + type_ (google.cloud.security.privateca_v1beta1.types.PublicKey.KeyType): + Required. The type of public key. + key (bytes): + Required. A public key. Padding and encoding + varies by 'KeyType' and is described along with + the KeyType values. + """ + class KeyType(proto.Enum): + r"""Types of public keys that are supported. At a minimum, we support + RSA and ECDSA, for the key sizes or curves listed: + https://cloud.google.com/kms/docs/algorithms#asymmetric_signing_algorithms + """ + KEY_TYPE_UNSPECIFIED = 0 + PEM_RSA_KEY = 1 + PEM_EC_KEY = 2 + + type_ = proto.Field( + proto.ENUM, + number=1, + enum=KeyType, + ) + key = proto.Field( + proto.BYTES, + number=2, + ) + + +class CertificateConfig(proto.Message): + r"""A + [CertificateConfig][google.cloud.security.privateca.v1beta1.CertificateConfig] + describes an X.509 certificate or CSR that is to be created, as an + alternative to using ASN.1. + + Attributes: + subject_config (google.cloud.security.privateca_v1beta1.types.CertificateConfig.SubjectConfig): + Required. Specifies some of the values in a + certificate that are related to the subject. + reusable_config (google.cloud.security.privateca_v1beta1.types.ReusableConfigWrapper): + Required. Describes how some of the technical + fields in a certificate should be populated. + public_key (google.cloud.security.privateca_v1beta1.types.PublicKey): + Optional. The public key that corresponds to this config. + This is, for example, used when issuing + [Certificates][google.cloud.security.privateca.v1beta1.Certificate], + but not when creating a self-signed + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + or + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + CSR. + """ + + class SubjectConfig(proto.Message): + r"""These values are used to create the distinguished name and + subject alternative name fields in an X.509 certificate. + + Attributes: + subject (google.cloud.security.privateca_v1beta1.types.Subject): + Required. Contains distinguished name fields + such as the location and organization. + common_name (str): + Optional. The "common name" of the + distinguished name. + subject_alt_name (google.cloud.security.privateca_v1beta1.types.SubjectAltNames): + Optional. The subject alternative name + fields. + """ + + subject = proto.Field( + proto.MESSAGE, + number=1, + message='Subject', + ) + common_name = proto.Field( + proto.STRING, + number=2, + ) + subject_alt_name = proto.Field( + proto.MESSAGE, + number=3, + message='SubjectAltNames', + ) + + subject_config = proto.Field( + proto.MESSAGE, + number=1, + message=SubjectConfig, + ) + reusable_config = proto.Field( + proto.MESSAGE, + number=2, + message='ReusableConfigWrapper', + ) + public_key = proto.Field( + proto.MESSAGE, + number=3, + message='PublicKey', + ) + + +class CertificateDescription(proto.Message): + r"""A + [CertificateDescription][google.cloud.security.privateca.v1beta1.CertificateDescription] + describes an X.509 certificate or CSR that has been issued, as an + alternative to using ASN.1 / X.509. + + Attributes: + subject_description (google.cloud.security.privateca_v1beta1.types.CertificateDescription.SubjectDescription): + Describes some of the values in a certificate + that are related to the subject and lifetime. + config_values (google.cloud.security.privateca_v1beta1.types.ReusableConfigValues): + Describes some of the technical fields in a + certificate. + public_key (google.cloud.security.privateca_v1beta1.types.PublicKey): + The public key that corresponds to an issued + certificate. + subject_key_id (google.cloud.security.privateca_v1beta1.types.CertificateDescription.KeyId): + Provides a means of identifiying certificates + that contain a particular public key, per + https://tools.ietf.org/html/rfc5280#section-4.2.1.2. + authority_key_id (google.cloud.security.privateca_v1beta1.types.CertificateDescription.KeyId): + Identifies the subject_key_id of the parent certificate, per + https://tools.ietf.org/html/rfc5280#section-4.2.1.1 + crl_distribution_points (Sequence[str]): + Describes a list of locations to obtain CRL + information, i.e. the DistributionPoint.fullName + described by + https://tools.ietf.org/html/rfc5280#section-4.2.1.13 + aia_issuing_certificate_urls (Sequence[str]): + Describes lists of issuer CA certificate URLs + that appear in the "Authority Information + Access" extension in the certificate. + cert_fingerprint (google.cloud.security.privateca_v1beta1.types.CertificateDescription.CertificateFingerprint): + The hash of the x.509 certificate. + """ + + class SubjectDescription(proto.Message): + r"""These values describe fields in an issued X.509 certificate + such as the distinguished name, subject alternative names, + serial number, and lifetime. + + Attributes: + subject (google.cloud.security.privateca_v1beta1.types.Subject): + Contains distinguished name fields such as + the location and organization. + common_name (str): + The "common name" of the distinguished name. + subject_alt_name (google.cloud.security.privateca_v1beta1.types.SubjectAltNames): + The subject alternative name fields. + hex_serial_number (str): + The serial number encoded in lowercase + hexadecimal. + lifetime (google.protobuf.duration_pb2.Duration): + For convenience, the actual lifetime of an issued + certificate. Corresponds to 'not_after_time' - + 'not_before_time'. + not_before_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which the certificate becomes + valid. + not_after_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which the certificate expires. + """ + + subject = proto.Field( + proto.MESSAGE, + number=1, + message='Subject', + ) + common_name = proto.Field( + proto.STRING, + number=2, + ) + subject_alt_name = proto.Field( + proto.MESSAGE, + number=3, + message='SubjectAltNames', + ) + hex_serial_number = proto.Field( + proto.STRING, + number=4, + ) + lifetime = proto.Field( + proto.MESSAGE, + number=5, + message=duration_pb2.Duration, + ) + not_before_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + not_after_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + + class KeyId(proto.Message): + r"""A KeyId identifies a specific public key, usually by hashing + the public key. + + Attributes: + key_id (str): + Optional. The value of this KeyId encoded in + lowercase hexadecimal. This is most likely the + 160 bit SHA-1 hash of the public key. + """ + + key_id = proto.Field( + proto.STRING, + number=1, + ) + + class CertificateFingerprint(proto.Message): + r"""A group of fingerprints for the x509 certificate. + Attributes: + sha256_hash (str): + The SHA 256 hash, encoded in hexadecimal, of + the DER x509 certificate. + """ + + sha256_hash = proto.Field( + proto.STRING, + number=1, + ) + + subject_description = proto.Field( + proto.MESSAGE, + number=1, + message=SubjectDescription, + ) + config_values = proto.Field( + proto.MESSAGE, + number=2, + message='ReusableConfigValues', + ) + public_key = proto.Field( + proto.MESSAGE, + number=3, + message='PublicKey', + ) + subject_key_id = proto.Field( + proto.MESSAGE, + number=4, + message=KeyId, + ) + authority_key_id = proto.Field( + proto.MESSAGE, + number=5, + message=KeyId, + ) + crl_distribution_points = proto.RepeatedField( + proto.STRING, + number=6, + ) + aia_issuing_certificate_urls = proto.RepeatedField( + proto.STRING, + number=7, + ) + cert_fingerprint = proto.Field( + proto.MESSAGE, + number=8, + message=CertificateFingerprint, + ) + + +class ObjectId(proto.Message): + r"""An [ObjectId][google.cloud.security.privateca.v1beta1.ObjectId] + specifies an object identifier (OID). These provide context and + describe types in ASN.1 messages. + + Attributes: + object_id_path (Sequence[int]): + Required. The parts of an OID path. The most + significant parts of the path come first. + """ + + object_id_path = proto.RepeatedField( + proto.INT32, + number=1, + ) + + +class X509Extension(proto.Message): + r"""An + [X509Extension][google.cloud.security.privateca.v1beta1.X509Extension] + specifies an X.509 extension, which may be used in different parts + of X.509 objects like certificates, CSRs, and CRLs. + + Attributes: + object_id (google.cloud.security.privateca_v1beta1.types.ObjectId): + Required. The OID for this X.509 extension. + critical (bool): + Required. Indicates whether or not this + extension is critical (i.e., if the client does + not know how to handle this extension, the + client should consider this to be an error). + value (bytes): + Required. The value of this X.509 extension. + """ + + object_id = proto.Field( + proto.MESSAGE, + number=1, + message='ObjectId', + ) + critical = proto.Field( + proto.BOOL, + number=2, + ) + value = proto.Field( + proto.BYTES, + number=3, + ) + + +class KeyUsage(proto.Message): + r"""A [KeyUsage][google.cloud.security.privateca.v1beta1.KeyUsage] + describes key usage values that may appear in an X.509 certificate. + + Attributes: + base_key_usage (google.cloud.security.privateca_v1beta1.types.KeyUsage.KeyUsageOptions): + Describes high-level ways in which a key may + be used. + extended_key_usage (google.cloud.security.privateca_v1beta1.types.KeyUsage.ExtendedKeyUsageOptions): + Detailed scenarios in which a key may be + used. + unknown_extended_key_usages (Sequence[google.cloud.security.privateca_v1beta1.types.ObjectId]): + Used to describe extended key usages that are not listed in + the + [KeyUsage.ExtendedKeyUsageOptions][google.cloud.security.privateca.v1beta1.KeyUsage.ExtendedKeyUsageOptions] + message. + """ + + class KeyUsageOptions(proto.Message): + r"""[KeyUsage.KeyUsageOptions][google.cloud.security.privateca.v1beta1.KeyUsage.KeyUsageOptions] + corresponds to the key usage values described in + https://tools.ietf.org/html/rfc5280#section-4.2.1.3. + + Attributes: + digital_signature (bool): + The key may be used for digital signatures. + content_commitment (bool): + The key may be used for cryptographic + commitments. Note that this may also be referred + to as "non-repudiation". + key_encipherment (bool): + The key may be used to encipher other keys. + data_encipherment (bool): + The key may be used to encipher data. + key_agreement (bool): + The key may be used in a key agreement + protocol. + cert_sign (bool): + The key may be used to sign certificates. + crl_sign (bool): + The key may be used sign certificate + revocation lists. + encipher_only (bool): + The key may be used to encipher only. + decipher_only (bool): + The key may be used to decipher only. + """ + + digital_signature = proto.Field( + proto.BOOL, + number=1, + ) + content_commitment = proto.Field( + proto.BOOL, + number=2, + ) + key_encipherment = proto.Field( + proto.BOOL, + number=3, + ) + data_encipherment = proto.Field( + proto.BOOL, + number=4, + ) + key_agreement = proto.Field( + proto.BOOL, + number=5, + ) + cert_sign = proto.Field( + proto.BOOL, + number=6, + ) + crl_sign = proto.Field( + proto.BOOL, + number=7, + ) + encipher_only = proto.Field( + proto.BOOL, + number=8, + ) + decipher_only = proto.Field( + proto.BOOL, + number=9, + ) + + class ExtendedKeyUsageOptions(proto.Message): + r"""[KeyUsage.ExtendedKeyUsageOptions][google.cloud.security.privateca.v1beta1.KeyUsage.ExtendedKeyUsageOptions] + has fields that correspond to certain common OIDs that could be + specified as an extended key usage value. + + Attributes: + server_auth (bool): + Corresponds to OID 1.3.6.1.5.5.7.3.1. + Officially described as "TLS WWW server + authentication", though regularly used for non- + WWW TLS. + client_auth (bool): + Corresponds to OID 1.3.6.1.5.5.7.3.2. + Officially described as "TLS WWW client + authentication", though regularly used for non- + WWW TLS. + code_signing (bool): + Corresponds to OID 1.3.6.1.5.5.7.3.3. + Officially described as "Signing of downloadable + executable code client authentication". + email_protection (bool): + Corresponds to OID 1.3.6.1.5.5.7.3.4. + Officially described as "Email protection". + time_stamping (bool): + Corresponds to OID 1.3.6.1.5.5.7.3.8. + Officially described as "Binding the hash of an + object to a time". + ocsp_signing (bool): + Corresponds to OID 1.3.6.1.5.5.7.3.9. + Officially described as "Signing OCSP + responses". + """ + + server_auth = proto.Field( + proto.BOOL, + number=1, + ) + client_auth = proto.Field( + proto.BOOL, + number=2, + ) + code_signing = proto.Field( + proto.BOOL, + number=3, + ) + email_protection = proto.Field( + proto.BOOL, + number=4, + ) + time_stamping = proto.Field( + proto.BOOL, + number=5, + ) + ocsp_signing = proto.Field( + proto.BOOL, + number=6, + ) + + base_key_usage = proto.Field( + proto.MESSAGE, + number=1, + message=KeyUsageOptions, + ) + extended_key_usage = proto.Field( + proto.MESSAGE, + number=2, + message=ExtendedKeyUsageOptions, + ) + unknown_extended_key_usages = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='ObjectId', + ) + + +class Subject(proto.Message): + r"""[Subject][google.cloud.security.privateca.v1beta1.Subject] describes + parts of a distinguished name that, in turn, describes the subject + of the certificate. + + Attributes: + country_code (str): + The country code of the subject. + organization (str): + The organization of the subject. + organizational_unit (str): + The organizational_unit of the subject. + locality (str): + The locality or city of the subject. + province (str): + The province, territory, or regional state of + the subject. + street_address (str): + The street address of the subject. + postal_code (str): + The postal code of the subject. + """ + + country_code = proto.Field( + proto.STRING, + number=1, + ) + organization = proto.Field( + proto.STRING, + number=2, + ) + organizational_unit = proto.Field( + proto.STRING, + number=3, + ) + locality = proto.Field( + proto.STRING, + number=4, + ) + province = proto.Field( + proto.STRING, + number=5, + ) + street_address = proto.Field( + proto.STRING, + number=6, + ) + postal_code = proto.Field( + proto.STRING, + number=7, + ) + + +class SubjectAltNames(proto.Message): + r"""[SubjectAltNames][google.cloud.security.privateca.v1beta1.SubjectAltNames] + corresponds to a more modern way of listing what the asserted + identity is in a certificate (i.e., compared to the "common name" in + the distinguished name). + + Attributes: + dns_names (Sequence[str]): + Contains only valid, fully-qualified host + names. + uris (Sequence[str]): + Contains only valid RFC 3986 URIs. + email_addresses (Sequence[str]): + Contains only valid RFC 2822 E-mail + addresses. + ip_addresses (Sequence[str]): + Contains only valid 32-bit IPv4 addresses or + RFC 4291 IPv6 addresses. + custom_sans (Sequence[google.cloud.security.privateca_v1beta1.types.X509Extension]): + Contains additional subject alternative name + values. + """ + + dns_names = proto.RepeatedField( + proto.STRING, + number=1, + ) + uris = proto.RepeatedField( + proto.STRING, + number=2, + ) + email_addresses = proto.RepeatedField( + proto.STRING, + number=3, + ) + ip_addresses = proto.RepeatedField( + proto.STRING, + number=4, + ) + custom_sans = proto.RepeatedField( + proto.MESSAGE, + number=5, + message='X509Extension', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/service.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/service.py new file mode 100644 index 0000000..d42d12d --- /dev/null +++ b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/service.py @@ -0,0 +1,1121 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import proto # type: ignore + +from google.cloud.security.privateca_v1beta1.types import resources +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.security.privateca.v1beta1', + manifest={ + 'CreateCertificateRequest', + 'GetCertificateRequest', + 'ListCertificatesRequest', + 'ListCertificatesResponse', + 'RevokeCertificateRequest', + 'UpdateCertificateRequest', + 'ActivateCertificateAuthorityRequest', + 'CreateCertificateAuthorityRequest', + 'DisableCertificateAuthorityRequest', + 'EnableCertificateAuthorityRequest', + 'FetchCertificateAuthorityCsrRequest', + 'FetchCertificateAuthorityCsrResponse', + 'GetCertificateAuthorityRequest', + 'ListCertificateAuthoritiesRequest', + 'ListCertificateAuthoritiesResponse', + 'RestoreCertificateAuthorityRequest', + 'ScheduleDeleteCertificateAuthorityRequest', + 'UpdateCertificateAuthorityRequest', + 'GetCertificateRevocationListRequest', + 'ListCertificateRevocationListsRequest', + 'ListCertificateRevocationListsResponse', + 'UpdateCertificateRevocationListRequest', + 'GetReusableConfigRequest', + 'ListReusableConfigsRequest', + 'ListReusableConfigsResponse', + 'OperationMetadata', + }, +) + + +class CreateCertificateRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.CreateCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.CreateCertificate]. + + Attributes: + parent (str): + Required. The resource name of the location and + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + associated with the + [Certificate][google.cloud.security.privateca.v1beta1.Certificate], + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + certificate_id (str): + Optional. It must be unique within a location and match the + regular expression ``[a-zA-Z0-9_-]{1,63}``. This field is + required when using a + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the Enterprise + [CertificateAuthority.Tier][google.cloud.security.privateca.v1beta1.CertificateAuthority.Tier], + but is optional and its value is ignored otherwise. + certificate (google.cloud.security.privateca_v1beta1.types.Certificate): + Required. A + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + with initial field values. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + certificate_id = proto.Field( + proto.STRING, + number=2, + ) + certificate = proto.Field( + proto.MESSAGE, + number=3, + message=resources.Certificate, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class GetCertificateRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.GetCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificate]. + + Attributes: + name (str): + Required. The + [name][google.cloud.security.privateca.v1beta1.Certificate.name] + of the + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListCertificatesRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificates]. + + Attributes: + parent (str): + Required. The resource name of the location associated with + the + [Certificates][google.cloud.security.privateca.v1beta1.Certificate], + in the format + ``projects/*/locations/*/certificateauthorities/*``. + page_size (int): + Optional. Limit on the number of + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + to include in the response. Further + [Certificates][google.cloud.security.privateca.v1beta1.Certificate] + can subsequently be obtained by including the + [ListCertificatesResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListCertificatesResponse.next_page_token] + in a subsequent request. If unspecified, the server will + pick an appropriate default. + page_token (str): + Optional. Pagination token, returned earlier via + [ListCertificatesResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListCertificatesResponse.next_page_token]. + filter (str): + Optional. Only include resources that match the filter in + the response. For details on supported filters and syntax, + see `Certificates Filtering + documentation `__. + order_by (str): + Optional. Specify how the results should be sorted. For + details on supported fields and syntax, see `Certificates + Sorting + documentation `__. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCertificatesResponse(proto.Message): + r"""Response message for + [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificates]. + + Attributes: + certificates (Sequence[google.cloud.security.privateca_v1beta1.types.Certificate]): + The list of + [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. + next_page_token (str): + A token to retrieve next page of results. Pass this value in + [ListCertificatesRequest.next_page_token][] to retrieve the + next page of results. + unreachable (Sequence[str]): + A list of locations (e.g. "us-west1") that + could not be reached. + """ + + @property + def raw_page(self): + return self + + certificates = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.Certificate, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class RevokeCertificateRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.RevokeCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.RevokeCertificate]. + + Attributes: + name (str): + Required. The resource name for this + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + in the format + ``projects/*/locations/*/certificateAuthorities/*/certificates/*``. + reason (google.cloud.security.privateca_v1beta1.types.RevocationReason): + Required. The + [RevocationReason][google.cloud.security.privateca.v1beta1.RevocationReason] + for revoking this certificate. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + reason = proto.Field( + proto.ENUM, + number=2, + enum=resources.RevocationReason, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class UpdateCertificateRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.UpdateCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificate]. + + Attributes: + certificate (google.cloud.security.privateca_v1beta1.types.Certificate): + Required. + [Certificate][google.cloud.security.privateca.v1beta1.Certificate] + with updated values. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be updated in + this request. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + certificate = proto.Field( + proto.MESSAGE, + number=1, + message=resources.Certificate, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class ActivateCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + pem_ca_certificate (str): + Required. The signed CA certificate issued from + [FetchCertificateAuthorityCsrResponse.pem_csr][google.cloud.security.privateca.v1beta1.FetchCertificateAuthorityCsrResponse.pem_csr]. + subordinate_config (google.cloud.security.privateca_v1beta1.types.SubordinateConfig): + Required. Must include information about the issuer of + 'pem_ca_certificate', and any further issuers until the + self-signed CA. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + pem_ca_certificate = proto.Field( + proto.STRING, + number=2, + ) + subordinate_config = proto.Field( + proto.MESSAGE, + number=3, + message=resources.SubordinateConfig, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class CreateCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.CreateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.CreateCertificateAuthority]. + + Attributes: + parent (str): + Required. The resource name of the location associated with + the + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority], + in the format ``projects/*/locations/*``. + certificate_authority_id (str): + Required. It must be unique within a location and match the + regular expression ``[a-zA-Z0-9_-]{1,63}`` + certificate_authority (google.cloud.security.privateca_v1beta1.types.CertificateAuthority): + Required. A + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + with initial field values. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + certificate_authority_id = proto.Field( + proto.STRING, + number=2, + ) + certificate_authority = proto.Field( + proto.MESSAGE, + number=3, + message=resources.CertificateAuthority, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class DisableCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.DisableCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.DisableCertificateAuthority]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class EnableCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.EnableCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.EnableCertificateAuthority]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class FetchCertificateAuthorityCsrRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class FetchCertificateAuthorityCsrResponse(proto.Message): + r"""Response message for + [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. + + Attributes: + pem_csr (str): + Output only. The PEM-encoded signed + certificate signing request (CSR). + """ + + pem_csr = proto.Field( + proto.STRING, + number=1, + ) + + +class GetCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.GetCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificateAuthority]. + + Attributes: + name (str): + Required. The + [name][google.cloud.security.privateca.v1beta1.CertificateAuthority.name] + of the + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListCertificateAuthoritiesRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateAuthorities]. + + Attributes: + parent (str): + Required. The resource name of the location associated with + the + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority], + in the format ``projects/*/locations/*``. + page_size (int): + Optional. Limit on the number of + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority] + to include in the response. Further + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority] + can subsequently be obtained by including the + [ListCertificateAuthoritiesResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListCertificateAuthoritiesResponse.next_page_token] + in a subsequent request. If unspecified, the server will + pick an appropriate default. + page_token (str): + Optional. Pagination token, returned earlier via + [ListCertificateAuthoritiesResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListCertificateAuthoritiesResponse.next_page_token]. + filter (str): + Optional. Only include resources that match + the filter in the response. + order_by (str): + Optional. Specify how the results should be + sorted. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCertificateAuthoritiesResponse(proto.Message): + r"""Response message for + [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateAuthorities]. + + Attributes: + certificate_authorities (Sequence[google.cloud.security.privateca_v1beta1.types.CertificateAuthority]): + The list of + [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority]. + next_page_token (str): + A token to retrieve next page of results. Pass this value in + [ListCertificateAuthoritiesRequest.next_page_token][] to + retrieve the next page of results. + unreachable (Sequence[str]): + A list of locations (e.g. "us-west1") that + could not be reached. + """ + + @property + def raw_page(self): + return self + + certificate_authorities = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.CertificateAuthority, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class RestoreCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.RestoreCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.RestoreCertificateAuthority]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class ScheduleDeleteCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.ScheduleDeleteCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ScheduleDeleteCertificateAuthority]. + + Attributes: + name (str): + Required. The resource name for this + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + in the format + ``projects/*/locations/*/certificateAuthorities/*``. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class UpdateCertificateAuthorityRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.UpdateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificateAuthority]. + + Attributes: + certificate_authority (google.cloud.security.privateca_v1beta1.types.CertificateAuthority): + Required. + [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] + with updated values. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be updated in + this request. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + certificate_authority = proto.Field( + proto.MESSAGE, + number=1, + message=resources.CertificateAuthority, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class GetCertificateRevocationListRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.GetCertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificateRevocationList]. + + Attributes: + name (str): + Required. The + [name][google.cloud.security.privateca.v1beta1.CertificateRevocationList.name] + of the + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] + to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListCertificateRevocationListsRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateRevocationLists]. + + Attributes: + parent (str): + Required. The resource name of the location associated with + the + [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList], + in the format + ``projects/*/locations/*/certificateauthorities/*``. + page_size (int): + Optional. Limit on the number of + [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList] + to include in the response. Further + [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList] + can subsequently be obtained by including the + [ListCertificateRevocationListsResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListCertificateRevocationListsResponse.next_page_token] + in a subsequent request. If unspecified, the server will + pick an appropriate default. + page_token (str): + Optional. Pagination token, returned earlier via + [ListCertificateRevocationListsResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListCertificateRevocationListsResponse.next_page_token]. + filter (str): + Optional. Only include resources that match + the filter in the response. + order_by (str): + Optional. Specify how the results should be + sorted. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCertificateRevocationListsResponse(proto.Message): + r"""Response message for + [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateRevocationLists]. + + Attributes: + certificate_revocation_lists (Sequence[google.cloud.security.privateca_v1beta1.types.CertificateRevocationList]): + The list of + [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. + next_page_token (str): + A token to retrieve next page of results. Pass this value in + [ListCertificateRevocationListsRequest.next_page_token][] to + retrieve the next page of results. + unreachable (Sequence[str]): + A list of locations (e.g. "us-west1") that + could not be reached. + """ + + @property + def raw_page(self): + return self + + certificate_revocation_lists = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.CertificateRevocationList, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class UpdateCertificateRevocationListRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.UpdateCertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificateRevocationList]. + + Attributes: + certificate_revocation_list (google.cloud.security.privateca_v1beta1.types.CertificateRevocationList): + Required. + [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] + with updated values. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. A list of fields to be updated in + this request. + request_id (str): + Optional. An ID to identify requests. Specify + a unique request ID so that if you must retry + your request, the server will know to ignore the + request if it has already been completed. The + server will guarantee that for at least 60 + minutes since the first request. + + For example, consider a situation where you make + an initial request and t he request times out. + If you make the request again with the same + request ID, the server can check if original + operation with the same request ID was received, + and if so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + certificate_revocation_list = proto.Field( + proto.MESSAGE, + number=1, + message=resources.CertificateRevocationList, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class GetReusableConfigRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.GetReusableConfig][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetReusableConfig]. + + Attributes: + name (str): + Required. The [name][ReusableConfigs.name] of the + [ReusableConfigs][] to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListReusableConfigsRequest(proto.Message): + r"""Request message for + [CertificateAuthorityService.ListReusableConfigs][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListReusableConfigs]. + + Attributes: + parent (str): + Required. The resource name of the location associated with + the + [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig], + in the format ``projects/*/locations/*``. + page_size (int): + Optional. Limit on the number of + [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig] + to include in the response. Further + [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig] + can subsequently be obtained by including the + [ListReusableConfigsResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListReusableConfigsResponse.next_page_token] + in a subsequent request. If unspecified, the server will + pick an appropriate default. + page_token (str): + Optional. Pagination token, returned earlier via + [ListReusableConfigsResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListReusableConfigsResponse.next_page_token]. + filter (str): + Optional. Only include resources that match + the filter in the response. + order_by (str): + Optional. Specify how the results should be + sorted. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListReusableConfigsResponse(proto.Message): + r"""Response message for + [CertificateAuthorityService.ListReusableConfigs][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListReusableConfigs]. + + Attributes: + reusable_configs (Sequence[google.cloud.security.privateca_v1beta1.types.ReusableConfig]): + The list of + [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig]. + next_page_token (str): + A token to retrieve next page of results. Pass this value in + [ListReusableConfigsRequest.next_page_token][] to retrieve + the next page of results. + unreachable (Sequence[str]): + A list of locations (e.g. "us-west1") that + could not be reached. + """ + + @property + def raw_page(self): + return self + + reusable_configs = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.ReusableConfig, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class OperationMetadata(proto.Message): + r"""Represents the metadata of the long-running operation. + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + target (str): + Output only. Server-defined resource path for + the target of the operation. + verb (str): + Output only. Name of the verb executed by the + operation. + status_message (str): + Output only. Human-readable status of the + operation, if any. + requested_cancellation (bool): + Output only. Identifies whether the user has requested + cancellation of the operation. Operations that have + successfully been cancelled have [Operation.error][] value + with a [google.rpc.Status.code][google.rpc.Status.code] of + 1, corresponding to ``Code.CANCELLED``. + api_version (str): + Output only. API version used to start the + operation. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + target = proto.Field( + proto.STRING, + number=3, + ) + verb = proto.Field( + proto.STRING, + number=4, + ) + status_message = proto.Field( + proto.STRING, + number=5, + ) + requested_cancellation = proto.Field( + proto.BOOL, + number=6, + ) + api_version = proto.Field( + proto.STRING, + number=7, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta1/mypy.ini b/owl-bot-staging/v1beta1/mypy.ini new file mode 100644 index 0000000..4505b48 --- /dev/null +++ b/owl-bot-staging/v1beta1/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.6 +namespace_packages = True diff --git a/owl-bot-staging/v1beta1/noxfile.py b/owl-bot-staging/v1beta1/noxfile.py new file mode 100644 index 0000000..e0f659d --- /dev/null +++ b/owl-bot-staging/v1beta1/noxfile.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") + + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", +] + +@nox.session(python=['3.6', '3.7', '3.8', '3.9']) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/cloud/security/privateca_v1beta1/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python='3.7') +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python=['3.6', '3.7']) +def mypy(session): + """Run the type checker.""" + session.install('mypy') + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python='3.6') +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx<3.0.0", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/owl-bot-staging/v1beta1/scripts/fixup_privateca_v1beta1_keywords.py b/owl-bot-staging/v1beta1/scripts/fixup_privateca_v1beta1_keywords.py new file mode 100644 index 0000000..afc0c8d --- /dev/null +++ b/owl-bot-staging/v1beta1/scripts/fixup_privateca_v1beta1_keywords.py @@ -0,0 +1,195 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class privatecaCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'activate_certificate_authority': ('name', 'pem_ca_certificate', 'subordinate_config', 'request_id', ), + 'create_certificate': ('parent', 'certificate', 'certificate_id', 'request_id', ), + 'create_certificate_authority': ('parent', 'certificate_authority_id', 'certificate_authority', 'request_id', ), + 'disable_certificate_authority': ('name', 'request_id', ), + 'enable_certificate_authority': ('name', 'request_id', ), + 'fetch_certificate_authority_csr': ('name', ), + 'get_certificate': ('name', ), + 'get_certificate_authority': ('name', ), + 'get_certificate_revocation_list': ('name', ), + 'get_reusable_config': ('name', ), + 'list_certificate_authorities': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificate_revocation_lists': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_reusable_configs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'restore_certificate_authority': ('name', 'request_id', ), + 'revoke_certificate': ('name', 'reason', 'request_id', ), + 'schedule_delete_certificate_authority': ('name', 'request_id', ), + 'update_certificate': ('certificate', 'update_mask', 'request_id', ), + 'update_certificate_authority': ('certificate_authority', 'update_mask', 'request_id', ), + 'update_certificate_revocation_list': ('certificate_revocation_list', 'update_mask', 'request_id', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: not a.keyword.value in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=privatecaCallTransformer(), +): + """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 privateca client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1beta1/setup.py b/owl-bot-staging/v1beta1/setup.py new file mode 100644 index 0000000..9796ba8 --- /dev/null +++ b/owl-bot-staging/v1beta1/setup.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import io +import os +import setuptools # type: ignore + +version = '0.1.0' + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, 'README.rst') +with io.open(readme_filename, encoding='utf-8') as readme_file: + readme = readme_file.read() + +setuptools.setup( + name='google-cloud-security-privateca', + version=version, + long_description=readme, + packages=setuptools.PEP420PackageFinder.find(), + namespace_packages=('google', 'google.cloud', 'google.cloud.security'), + platforms='Posix; MacOS X; Windows', + include_package_data=True, + install_requires=( + 'google-api-core[grpc] >= 1.22.2, < 2.0.0dev', + 'libcst >= 0.2.5', + 'proto-plus >= 1.15.0', + 'packaging >= 14.3', ), + python_requires='>=3.6', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Topic :: Internet', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + zip_safe=False, +) diff --git a/owl-bot-staging/v1beta1/tests/__init__.py b/owl-bot-staging/v1beta1/tests/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta1/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1beta1/tests/unit/__init__.py b/owl-bot-staging/v1beta1/tests/unit/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta1/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py b/owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/__init__.py b/owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py b/owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py new file mode 100644 index 0000000..a7cf7a2 --- /dev/null +++ b/owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py @@ -0,0 +1,6611 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +import mock +import packaging.version + +import grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import future +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import operation_async # type: ignore +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import CertificateAuthorityServiceAsyncClient +from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import CertificateAuthorityServiceClient +from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import pagers +from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import transports +from google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.base import _API_CORE_VERSION +from google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.base import _GOOGLE_AUTH_VERSION +from google.cloud.security.privateca_v1beta1.types import resources +from google.cloud.security.privateca_v1beta1.types import service +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(None) is None + assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class", [ + CertificateAuthorityServiceClient, + CertificateAuthorityServiceAsyncClient, +]) +def test_certificate_authority_service_client_from_service_account_info(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'privateca.googleapis.com:443' + + +@pytest.mark.parametrize("client_class", [ + CertificateAuthorityServiceClient, + CertificateAuthorityServiceAsyncClient, +]) +def test_certificate_authority_service_client_from_service_account_file(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: + factory.return_value = creds + client = client_class.from_service_account_file("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == 'privateca.googleapis.com:443' + + +def test_certificate_authority_service_client_get_transport_class(): + transport = CertificateAuthorityServiceClient.get_transport_class() + available_transports = [ + transports.CertificateAuthorityServiceGrpcTransport, + ] + assert transport in available_transports + + transport = CertificateAuthorityServiceClient.get_transport_class("grpc") + assert transport == transports.CertificateAuthorityServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc"), + (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(CertificateAuthorityServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceClient)) +@mock.patch.object(CertificateAuthorityServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceAsyncClient)) +def test_certificate_authority_service_client_client_options(client_class, transport_class, transport_name): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(CertificateAuthorityServiceClient, '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(CertificateAuthorityServiceClient, 'get_transport_class') as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc", "true"), + (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc", "false"), + (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(CertificateAuthorityServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceClient)) +@mock.patch.object(CertificateAuthorityServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_certificate_authority_service_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc"), + (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_certificate_authority_service_client_client_options_scopes(client_class, transport_class, transport_name): + # Check the case scopes are provided. + options = client_options.ClientOptions( + scopes=["1", "2"], + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc"), + (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_certificate_authority_service_client_client_options_credentials_file(client_class, transport_class, transport_name): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_certificate_authority_service_client_client_options_from_dict(): + with mock.patch('google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = CertificateAuthorityServiceClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_create_certificate(transport: str = 'grpc', request_type=service.CreateCertificateRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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 = resources.Certificate( + name='name_value', + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + pem_csr='pem_csr_value', + ) + 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] == service.CreateCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +def test_create_certificate_from_dict(): + test_create_certificate(request_type=dict) + + +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 = CertificateAuthorityServiceClient( + 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] == service.CreateCertificateRequest() + + +@pytest.mark.asyncio +async def test_create_certificate_async(transport: str = 'grpc_asyncio', request_type=service.CreateCertificateRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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(resources.Certificate( + name='name_value', + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + )) + 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] == service.CreateCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +@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 = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.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 = resources.Certificate() + 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 = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.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(resources.Certificate()) + 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 = CertificateAuthorityServiceClient( + 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 = resources.Certificate() + # 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=resources.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] + assert args[0].parent == 'parent_value' + assert args[0].certificate == resources.Certificate(name='name_value') + assert args[0].certificate_id == 'certificate_id_value' + + +def test_create_certificate_flattened_error(): + client = CertificateAuthorityServiceClient( + 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( + service.CreateCertificateRequest(), + parent='parent_value', + certificate=resources.Certificate(name='name_value'), + certificate_id='certificate_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_certificate_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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 = resources.Certificate() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) + # 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=resources.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] + assert args[0].parent == 'parent_value' + assert args[0].certificate == resources.Certificate(name='name_value') + assert args[0].certificate_id == 'certificate_id_value' + + +@pytest.mark.asyncio +async def test_create_certificate_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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( + service.CreateCertificateRequest(), + parent='parent_value', + certificate=resources.Certificate(name='name_value'), + certificate_id='certificate_id_value', + ) + + +def test_get_certificate(transport: str = 'grpc', request_type=service.GetCertificateRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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 = resources.Certificate( + name='name_value', + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + pem_csr='pem_csr_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] == service.GetCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +def test_get_certificate_from_dict(): + test_get_certificate(request_type=dict) + + +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 = CertificateAuthorityServiceClient( + 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] == service.GetCertificateRequest() + + +@pytest.mark.asyncio +async def test_get_certificate_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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(resources.Certificate( + name='name_value', + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + )) + 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] == service.GetCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +@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 = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.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 = resources.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 = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.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(resources.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 = CertificateAuthorityServiceClient( + 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 = resources.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] + assert args[0].name == 'name_value' + + +def test_get_certificate_flattened_error(): + client = CertificateAuthorityServiceClient( + 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( + service.GetCertificateRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_certificate_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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 = resources.Certificate() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.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] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_certificate_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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( + service.GetCertificateRequest(), + name='name_value', + ) + + +def test_list_certificates(transport: str = 'grpc', request_type=service.ListCertificatesRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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 = service.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] == service.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_from_dict(): + test_list_certificates(request_type=dict) + + +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 = CertificateAuthorityServiceClient( + 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] == service.ListCertificatesRequest() + + +@pytest.mark.asyncio +async def test_list_certificates_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificatesRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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(service.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] == service.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 = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.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 = service.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 = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.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(service.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 = CertificateAuthorityServiceClient( + 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 = service.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] + assert args[0].parent == 'parent_value' + + +def test_list_certificates_flattened_error(): + client = CertificateAuthorityServiceClient( + 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( + service.ListCertificatesRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_certificates_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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 = service.ListCertificatesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.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] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_certificates_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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( + service.ListCertificatesRequest(), + parent='parent_value', + ) + + +def test_list_certificates_pager(): + client = CertificateAuthorityServiceClient( + 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: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + resources.Certificate(), + ], + next_page_token='abc', + ), + service.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + ], + next_page_token='ghi', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_certificates(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.Certificate) + for i in results) + +def test_list_certificates_pages(): + client = CertificateAuthorityServiceClient( + 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: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + resources.Certificate(), + ], + next_page_token='abc', + ), + service.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + ], + next_page_token='ghi', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.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 = CertificateAuthorityServiceAsyncClient( + 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 = ( + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + resources.Certificate(), + ], + next_page_token='abc', + ), + service.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + ], + next_page_token='ghi', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_certificates(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.Certificate) + for i in responses) + +@pytest.mark.asyncio +async def test_list_certificates_async_pages(): + client = CertificateAuthorityServiceAsyncClient( + 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 = ( + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + resources.Certificate(), + ], + next_page_token='abc', + ), + service.ListCertificatesResponse( + certificates=[], + next_page_token='def', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + ], + next_page_token='ghi', + ), + service.ListCertificatesResponse( + certificates=[ + resources.Certificate(), + resources.Certificate(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_certificates(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_revoke_certificate(transport: str = 'grpc', request_type=service.RevokeCertificateRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.revoke_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Certificate( + name='name_value', + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + pem_csr='pem_csr_value', + ) + response = client.revoke_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] == service.RevokeCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +def test_revoke_certificate_from_dict(): + test_revoke_certificate(request_type=dict) + + +def test_revoke_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 = CertificateAuthorityServiceClient( + 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.revoke_certificate), + '__call__') as call: + client.revoke_certificate() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.RevokeCertificateRequest() + + +@pytest.mark.asyncio +async def test_revoke_certificate_async(transport: str = 'grpc_asyncio', request_type=service.RevokeCertificateRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.revoke_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate( + name='name_value', + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + )) + response = await client.revoke_certificate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.RevokeCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +@pytest.mark.asyncio +async def test_revoke_certificate_async_from_dict(): + await test_revoke_certificate_async(request_type=dict) + + +def test_revoke_certificate_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.RevokeCertificateRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.revoke_certificate), + '__call__') as call: + call.return_value = resources.Certificate() + client.revoke_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_revoke_certificate_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.RevokeCertificateRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.revoke_certificate), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) + await client.revoke_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_revoke_certificate_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.revoke_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Certificate() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.revoke_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] + assert args[0].name == 'name_value' + + +def test_revoke_certificate_flattened_error(): + client = CertificateAuthorityServiceClient( + 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.revoke_certificate( + service.RevokeCertificateRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_revoke_certificate_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.revoke_certificate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Certificate() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.revoke_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] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_revoke_certificate_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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.revoke_certificate( + service.RevokeCertificateRequest(), + name='name_value', + ) + + +def test_update_certificate(transport: str = 'grpc', request_type=service.UpdateCertificateRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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 = resources.Certificate( + name='name_value', + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + pem_csr='pem_csr_value', + ) + 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] == service.UpdateCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +def test_update_certificate_from_dict(): + test_update_certificate(request_type=dict) + + +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 = CertificateAuthorityServiceClient( + 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] == service.UpdateCertificateRequest() + + +@pytest.mark.asyncio +async def test_update_certificate_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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(resources.Certificate( + name='name_value', + pem_certificate='pem_certificate_value', + pem_certificate_chain=['pem_certificate_chain_value'], + )) + 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] == service.UpdateCertificateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Certificate) + assert response.name == 'name_value' + assert response.pem_certificate == 'pem_certificate_value' + assert response.pem_certificate_chain == ['pem_certificate_chain_value'] + + +@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 = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateRequest() + + request.certificate.name = 'certificate.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 = resources.Certificate() + 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=certificate.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_certificate_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateRequest() + + request.certificate.name = 'certificate.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(resources.Certificate()) + 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=certificate.name/value', + ) in kw['metadata'] + + +def test_update_certificate_flattened(): + client = CertificateAuthorityServiceClient( + 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 = resources.Certificate() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_certificate( + certificate=resources.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] + assert args[0].certificate == resources.Certificate(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_certificate_flattened_error(): + client = CertificateAuthorityServiceClient( + 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( + service.UpdateCertificateRequest(), + certificate=resources.Certificate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_certificate_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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 = resources.Certificate() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_certificate( + certificate=resources.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] + assert args[0].certificate == resources.Certificate(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_certificate_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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( + service.UpdateCertificateRequest(), + certificate=resources.Certificate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_activate_certificate_authority(transport: str = 'grpc', request_type=service.ActivateCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.activate_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.ActivateCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_activate_certificate_authority_from_dict(): + test_activate_certificate_authority(request_type=dict) + + +def test_activate_certificate_authority_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 = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + client.activate_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ActivateCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_activate_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.ActivateCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.activate_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ActivateCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_activate_certificate_authority_async_from_dict(): + await test_activate_certificate_authority_async(request_type=dict) + + +def test_activate_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ActivateCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.activate_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_activate_certificate_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ActivateCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.activate_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +def test_activate_certificate_authority_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.activate_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_activate_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.activate_certificate_authority( + service.ActivateCertificateAuthorityRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_activate_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.activate_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_activate_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.activate_certificate_authority( + service.ActivateCertificateAuthorityRequest(), + name='name_value', + ) + + +def test_create_certificate_authority(transport: str = 'grpc', request_type=service.CreateCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_certificate_authority_from_dict(): + test_create_certificate_authority(request_type=dict) + + +def test_create_certificate_authority_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 = CertificateAuthorityServiceClient( + 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_authority), + '__call__') as call: + client.create_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_create_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.CreateCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__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_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_certificate_authority_async_from_dict(): + await test_create_certificate_authority_async(request_type=dict) + + +def test_create_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateCertificateAuthorityRequest() + + 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_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_certificate_authority(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_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateCertificateAuthorityRequest() + + 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_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_certificate_authority(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_authority_flattened(): + client = CertificateAuthorityServiceClient( + 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_authority), + '__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_authority( + parent='parent_value', + certificate_authority=resources.CertificateAuthority(name='name_value'), + certificate_authority_id='certificate_authority_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') + assert args[0].certificate_authority_id == 'certificate_authority_id_value' + + +def test_create_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_authority( + service.CreateCertificateAuthorityRequest(), + parent='parent_value', + certificate_authority=resources.CertificateAuthority(name='name_value'), + certificate_authority_id='certificate_authority_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority), + '__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_authority( + parent='parent_value', + certificate_authority=resources.CertificateAuthority(name='name_value'), + certificate_authority_id='certificate_authority_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') + assert args[0].certificate_authority_id == 'certificate_authority_id_value' + + +@pytest.mark.asyncio +async def test_create_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority( + service.CreateCertificateAuthorityRequest(), + parent='parent_value', + certificate_authority=resources.CertificateAuthority(name='name_value'), + certificate_authority_id='certificate_authority_id_value', + ) + + +def test_disable_certificate_authority(transport: str = 'grpc', request_type=service.DisableCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.disable_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.disable_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.DisableCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_disable_certificate_authority_from_dict(): + test_disable_certificate_authority(request_type=dict) + + +def test_disable_certificate_authority_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 = CertificateAuthorityServiceClient( + 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.disable_certificate_authority), + '__call__') as call: + client.disable_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.DisableCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_disable_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.DisableCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.disable_certificate_authority), + '__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.disable_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.DisableCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_disable_certificate_authority_async_from_dict(): + await test_disable_certificate_authority_async(request_type=dict) + + +def test_disable_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DisableCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.disable_certificate_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.disable_certificate_authority(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_disable_certificate_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DisableCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.disable_certificate_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.disable_certificate_authority(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_disable_certificate_authority_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.disable_certificate_authority), + '__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.disable_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_disable_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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.disable_certificate_authority( + service.DisableCertificateAuthorityRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_disable_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.disable_certificate_authority), + '__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.disable_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_disable_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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.disable_certificate_authority( + service.DisableCertificateAuthorityRequest(), + name='name_value', + ) + + +def test_enable_certificate_authority(transport: str = 'grpc', request_type=service.EnableCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.enable_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.enable_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.EnableCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_enable_certificate_authority_from_dict(): + test_enable_certificate_authority(request_type=dict) + + +def test_enable_certificate_authority_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 = CertificateAuthorityServiceClient( + 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.enable_certificate_authority), + '__call__') as call: + client.enable_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.EnableCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_enable_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.EnableCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.enable_certificate_authority), + '__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.enable_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.EnableCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_enable_certificate_authority_async_from_dict(): + await test_enable_certificate_authority_async(request_type=dict) + + +def test_enable_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.EnableCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.enable_certificate_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.enable_certificate_authority(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_enable_certificate_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.EnableCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.enable_certificate_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.enable_certificate_authority(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_enable_certificate_authority_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.enable_certificate_authority), + '__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.enable_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_enable_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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.enable_certificate_authority( + service.EnableCertificateAuthorityRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_enable_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.enable_certificate_authority), + '__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.enable_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_enable_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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.enable_certificate_authority( + service.EnableCertificateAuthorityRequest(), + name='name_value', + ) + + +def test_fetch_certificate_authority_csr(transport: str = 'grpc', request_type=service.FetchCertificateAuthorityCsrRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.fetch_certificate_authority_csr), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.FetchCertificateAuthorityCsrResponse( + pem_csr='pem_csr_value', + ) + response = client.fetch_certificate_authority_csr(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.FetchCertificateAuthorityCsrRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.FetchCertificateAuthorityCsrResponse) + assert response.pem_csr == 'pem_csr_value' + + +def test_fetch_certificate_authority_csr_from_dict(): + test_fetch_certificate_authority_csr(request_type=dict) + + +def test_fetch_certificate_authority_csr_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 = CertificateAuthorityServiceClient( + 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.fetch_certificate_authority_csr), + '__call__') as call: + client.fetch_certificate_authority_csr() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.FetchCertificateAuthorityCsrRequest() + + +@pytest.mark.asyncio +async def test_fetch_certificate_authority_csr_async(transport: str = 'grpc_asyncio', request_type=service.FetchCertificateAuthorityCsrRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.fetch_certificate_authority_csr), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCertificateAuthorityCsrResponse( + pem_csr='pem_csr_value', + )) + response = await client.fetch_certificate_authority_csr(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.FetchCertificateAuthorityCsrRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.FetchCertificateAuthorityCsrResponse) + assert response.pem_csr == 'pem_csr_value' + + +@pytest.mark.asyncio +async def test_fetch_certificate_authority_csr_async_from_dict(): + await test_fetch_certificate_authority_csr_async(request_type=dict) + + +def test_fetch_certificate_authority_csr_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.FetchCertificateAuthorityCsrRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_certificate_authority_csr), + '__call__') as call: + call.return_value = service.FetchCertificateAuthorityCsrResponse() + client.fetch_certificate_authority_csr(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_fetch_certificate_authority_csr_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.FetchCertificateAuthorityCsrRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_certificate_authority_csr), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCertificateAuthorityCsrResponse()) + await client.fetch_certificate_authority_csr(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_fetch_certificate_authority_csr_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_certificate_authority_csr), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.FetchCertificateAuthorityCsrResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.fetch_certificate_authority_csr( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_fetch_certificate_authority_csr_flattened_error(): + client = CertificateAuthorityServiceClient( + 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.fetch_certificate_authority_csr( + service.FetchCertificateAuthorityCsrRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_fetch_certificate_authority_csr_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_certificate_authority_csr), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.FetchCertificateAuthorityCsrResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCertificateAuthorityCsrResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.fetch_certificate_authority_csr( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_fetch_certificate_authority_csr_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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.fetch_certificate_authority_csr( + service.FetchCertificateAuthorityCsrRequest(), + name='name_value', + ) + + +def test_get_certificate_authority(transport: str = 'grpc', request_type=service.GetCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateAuthority( + name='name_value', + type_=resources.CertificateAuthority.Type.SELF_SIGNED, + tier=resources.CertificateAuthority.Tier.ENTERPRISE, + state=resources.CertificateAuthority.State.ENABLED, + pem_ca_certificates=['pem_ca_certificates_value'], + gcs_bucket='gcs_bucket_value', + ) + response = client.get_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CertificateAuthority) + assert response.name == 'name_value' + assert response.type_ == resources.CertificateAuthority.Type.SELF_SIGNED + assert response.tier == resources.CertificateAuthority.Tier.ENTERPRISE + assert response.state == resources.CertificateAuthority.State.ENABLED + assert response.pem_ca_certificates == ['pem_ca_certificates_value'] + assert response.gcs_bucket == 'gcs_bucket_value' + + +def test_get_certificate_authority_from_dict(): + test_get_certificate_authority(request_type=dict) + + +def test_get_certificate_authority_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 = CertificateAuthorityServiceClient( + 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_authority), + '__call__') as call: + client.get_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_get_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateAuthority( + name='name_value', + type_=resources.CertificateAuthority.Type.SELF_SIGNED, + tier=resources.CertificateAuthority.Tier.ENTERPRISE, + state=resources.CertificateAuthority.State.ENABLED, + pem_ca_certificates=['pem_ca_certificates_value'], + gcs_bucket='gcs_bucket_value', + )) + response = await client.get_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CertificateAuthority) + assert response.name == 'name_value' + assert response.type_ == resources.CertificateAuthority.Type.SELF_SIGNED + assert response.tier == resources.CertificateAuthority.Tier.ENTERPRISE + assert response.state == resources.CertificateAuthority.State.ENABLED + assert response.pem_ca_certificates == ['pem_ca_certificates_value'] + assert response.gcs_bucket == 'gcs_bucket_value' + + +@pytest.mark.asyncio +async def test_get_certificate_authority_async_from_dict(): + await test_get_certificate_authority_async(request_type=dict) + + +def test_get_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCertificateAuthorityRequest() + + 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_authority), + '__call__') as call: + call.return_value = resources.CertificateAuthority() + client.get_certificate_authority(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_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCertificateAuthorityRequest() + + 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_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateAuthority()) + await client.get_certificate_authority(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_authority_flattened(): + client = CertificateAuthorityServiceClient( + 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateAuthority() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_authority( + service.GetCertificateAuthorityRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateAuthority() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateAuthority()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority( + service.GetCertificateAuthorityRequest(), + name='name_value', + ) + + +def test_list_certificate_authorities(transport: str = 'grpc', request_type=service.ListCertificateAuthoritiesRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authorities), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateAuthoritiesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_certificate_authorities(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateAuthoritiesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateAuthoritiesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificate_authorities_from_dict(): + test_list_certificate_authorities(request_type=dict) + + +def test_list_certificate_authorities_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 = CertificateAuthorityServiceClient( + 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_authorities), + '__call__') as call: + client.list_certificate_authorities() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateAuthoritiesRequest() + + +@pytest.mark.asyncio +async def test_list_certificate_authorities_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificateAuthoritiesRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authorities), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateAuthoritiesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_certificate_authorities(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateAuthoritiesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateAuthoritiesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_certificate_authorities_async_from_dict(): + await test_list_certificate_authorities_async(request_type=dict) + + +def test_list_certificate_authorities_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCertificateAuthoritiesRequest() + + 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_authorities), + '__call__') as call: + call.return_value = service.ListCertificateAuthoritiesResponse() + client.list_certificate_authorities(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_authorities_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCertificateAuthoritiesRequest() + + 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_authorities), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateAuthoritiesResponse()) + await client.list_certificate_authorities(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_authorities_flattened(): + client = CertificateAuthorityServiceClient( + 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_authorities), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateAuthoritiesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_certificate_authorities( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +def test_list_certificate_authorities_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_authorities( + service.ListCertificateAuthoritiesRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_certificate_authorities_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authorities), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateAuthoritiesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateAuthoritiesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_certificate_authorities( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_certificate_authorities_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authorities( + service.ListCertificateAuthoritiesRequest(), + parent='parent_value', + ) + + +def test_list_certificate_authorities_pager(): + client = CertificateAuthorityServiceClient( + 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_authorities), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + next_page_token='abc', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[], + next_page_token='def', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + ], + next_page_token='ghi', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_certificate_authorities(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.CertificateAuthority) + for i in results) + +def test_list_certificate_authorities_pages(): + client = CertificateAuthorityServiceClient( + 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_authorities), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + next_page_token='abc', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[], + next_page_token='def', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + ], + next_page_token='ghi', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + ), + RuntimeError, + ) + pages = list(client.list_certificate_authorities(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_authorities_async_pager(): + client = CertificateAuthorityServiceAsyncClient( + 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_authorities), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + next_page_token='abc', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[], + next_page_token='def', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + ], + next_page_token='ghi', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_certificate_authorities(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.CertificateAuthority) + for i in responses) + +@pytest.mark.asyncio +async def test_list_certificate_authorities_async_pages(): + client = CertificateAuthorityServiceAsyncClient( + 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_authorities), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + next_page_token='abc', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[], + next_page_token='def', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + ], + next_page_token='ghi', + ), + service.ListCertificateAuthoritiesResponse( + certificate_authorities=[ + resources.CertificateAuthority(), + resources.CertificateAuthority(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_certificate_authorities(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_restore_certificate_authority(transport: str = 'grpc', request_type=service.RestoreCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.restore_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.restore_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.RestoreCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_restore_certificate_authority_from_dict(): + test_restore_certificate_authority(request_type=dict) + + +def test_restore_certificate_authority_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 = CertificateAuthorityServiceClient( + 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.restore_certificate_authority), + '__call__') as call: + client.restore_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.RestoreCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_restore_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.RestoreCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.restore_certificate_authority), + '__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.restore_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.RestoreCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_restore_certificate_authority_async_from_dict(): + await test_restore_certificate_authority_async(request_type=dict) + + +def test_restore_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.RestoreCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.restore_certificate_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.restore_certificate_authority(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_restore_certificate_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.RestoreCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.restore_certificate_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.restore_certificate_authority(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_restore_certificate_authority_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.restore_certificate_authority), + '__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.restore_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_restore_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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.restore_certificate_authority( + service.RestoreCertificateAuthorityRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_restore_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.restore_certificate_authority), + '__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.restore_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_restore_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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.restore_certificate_authority( + service.RestoreCertificateAuthorityRequest(), + name='name_value', + ) + + +def test_schedule_delete_certificate_authority(transport: str = 'grpc', request_type=service.ScheduleDeleteCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.schedule_delete_certificate_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.schedule_delete_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.ScheduleDeleteCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_schedule_delete_certificate_authority_from_dict(): + test_schedule_delete_certificate_authority(request_type=dict) + + +def test_schedule_delete_certificate_authority_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 = CertificateAuthorityServiceClient( + 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.schedule_delete_certificate_authority), + '__call__') as call: + client.schedule_delete_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ScheduleDeleteCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_schedule_delete_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.ScheduleDeleteCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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.schedule_delete_certificate_authority), + '__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.schedule_delete_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ScheduleDeleteCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_schedule_delete_certificate_authority_async_from_dict(): + await test_schedule_delete_certificate_authority_async(request_type=dict) + + +def test_schedule_delete_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ScheduleDeleteCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.schedule_delete_certificate_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.schedule_delete_certificate_authority(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_schedule_delete_certificate_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ScheduleDeleteCertificateAuthorityRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.schedule_delete_certificate_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.schedule_delete_certificate_authority(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_schedule_delete_certificate_authority_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.schedule_delete_certificate_authority), + '__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.schedule_delete_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_schedule_delete_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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.schedule_delete_certificate_authority( + service.ScheduleDeleteCertificateAuthorityRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_schedule_delete_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.schedule_delete_certificate_authority), + '__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.schedule_delete_certificate_authority( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_schedule_delete_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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.schedule_delete_certificate_authority( + service.ScheduleDeleteCertificateAuthorityRequest(), + name='name_value', + ) + + +def test_update_certificate_authority(transport: str = 'grpc', request_type=service.UpdateCertificateAuthorityRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_certificate_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_certificate_authority_from_dict(): + test_update_certificate_authority(request_type=dict) + + +def test_update_certificate_authority_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 = CertificateAuthorityServiceClient( + 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_authority), + '__call__') as call: + client.update_certificate_authority() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateAuthorityRequest() + + +@pytest.mark.asyncio +async def test_update_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateAuthorityRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_authority), + '__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_authority(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateAuthorityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_certificate_authority_async_from_dict(): + await test_update_certificate_authority_async(request_type=dict) + + +def test_update_certificate_authority_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateAuthorityRequest() + + request.certificate_authority.name = 'certificate_authority.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_authority), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_certificate_authority(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_authority.name=certificate_authority.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_certificate_authority_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateAuthorityRequest() + + request.certificate_authority.name = 'certificate_authority.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_authority), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_certificate_authority(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_authority.name=certificate_authority.name/value', + ) in kw['metadata'] + + +def test_update_certificate_authority_flattened(): + client = CertificateAuthorityServiceClient( + 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_authority), + '__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_authority( + certificate_authority=resources.CertificateAuthority(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_certificate_authority_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_authority( + service.UpdateCertificateAuthorityRequest(), + certificate_authority=resources.CertificateAuthority(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_certificate_authority_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority), + '__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_authority( + certificate_authority=resources.CertificateAuthority(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_certificate_authority_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_authority( + service.UpdateCertificateAuthorityRequest(), + certificate_authority=resources.CertificateAuthority(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_get_certificate_revocation_list(transport: str = 'grpc', request_type=service.GetCertificateRevocationListRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_revocation_list), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateRevocationList( + name='name_value', + sequence_number=1601, + pem_crl='pem_crl_value', + access_url='access_url_value', + state=resources.CertificateRevocationList.State.ACTIVE, + ) + response = client.get_certificate_revocation_list(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateRevocationListRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CertificateRevocationList) + assert response.name == 'name_value' + assert response.sequence_number == 1601 + assert response.pem_crl == 'pem_crl_value' + assert response.access_url == 'access_url_value' + assert response.state == resources.CertificateRevocationList.State.ACTIVE + + +def test_get_certificate_revocation_list_from_dict(): + test_get_certificate_revocation_list(request_type=dict) + + +def test_get_certificate_revocation_list_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 = CertificateAuthorityServiceClient( + 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_revocation_list), + '__call__') as call: + client.get_certificate_revocation_list() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateRevocationListRequest() + + +@pytest.mark.asyncio +async def test_get_certificate_revocation_list_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateRevocationListRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_revocation_list), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateRevocationList( + name='name_value', + sequence_number=1601, + pem_crl='pem_crl_value', + access_url='access_url_value', + state=resources.CertificateRevocationList.State.ACTIVE, + )) + response = await client.get_certificate_revocation_list(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCertificateRevocationListRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.CertificateRevocationList) + assert response.name == 'name_value' + assert response.sequence_number == 1601 + assert response.pem_crl == 'pem_crl_value' + assert response.access_url == 'access_url_value' + assert response.state == resources.CertificateRevocationList.State.ACTIVE + + +@pytest.mark.asyncio +async def test_get_certificate_revocation_list_async_from_dict(): + await test_get_certificate_revocation_list_async(request_type=dict) + + +def test_get_certificate_revocation_list_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCertificateRevocationListRequest() + + 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_revocation_list), + '__call__') as call: + call.return_value = resources.CertificateRevocationList() + client.get_certificate_revocation_list(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_revocation_list_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCertificateRevocationListRequest() + + 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_revocation_list), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateRevocationList()) + await client.get_certificate_revocation_list(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_revocation_list_flattened(): + client = CertificateAuthorityServiceClient( + 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_revocation_list), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateRevocationList() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_certificate_revocation_list( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_certificate_revocation_list_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_revocation_list( + service.GetCertificateRevocationListRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_certificate_revocation_list_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_list), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.CertificateRevocationList() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateRevocationList()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_certificate_revocation_list( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_certificate_revocation_list_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_list( + service.GetCertificateRevocationListRequest(), + name='name_value', + ) + + +def test_list_certificate_revocation_lists(transport: str = 'grpc', request_type=service.ListCertificateRevocationListsRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_revocation_lists), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateRevocationListsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_certificate_revocation_lists(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateRevocationListsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateRevocationListsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_certificate_revocation_lists_from_dict(): + test_list_certificate_revocation_lists(request_type=dict) + + +def test_list_certificate_revocation_lists_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 = CertificateAuthorityServiceClient( + 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_revocation_lists), + '__call__') as call: + client.list_certificate_revocation_lists() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateRevocationListsRequest() + + +@pytest.mark.asyncio +async def test_list_certificate_revocation_lists_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificateRevocationListsRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_revocation_lists), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateRevocationListsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_certificate_revocation_lists(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCertificateRevocationListsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCertificateRevocationListsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_certificate_revocation_lists_async_from_dict(): + await test_list_certificate_revocation_lists_async(request_type=dict) + + +def test_list_certificate_revocation_lists_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCertificateRevocationListsRequest() + + 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_revocation_lists), + '__call__') as call: + call.return_value = service.ListCertificateRevocationListsResponse() + client.list_certificate_revocation_lists(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_revocation_lists_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCertificateRevocationListsRequest() + + 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_revocation_lists), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateRevocationListsResponse()) + await client.list_certificate_revocation_lists(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_revocation_lists_flattened(): + client = CertificateAuthorityServiceClient( + 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_revocation_lists), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateRevocationListsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_certificate_revocation_lists( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +def test_list_certificate_revocation_lists_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_revocation_lists( + service.ListCertificateRevocationListsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_certificate_revocation_lists_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_lists), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCertificateRevocationListsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateRevocationListsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_certificate_revocation_lists( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_certificate_revocation_lists_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_lists( + service.ListCertificateRevocationListsRequest(), + parent='parent_value', + ) + + +def test_list_certificate_revocation_lists_pager(): + client = CertificateAuthorityServiceClient( + 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_revocation_lists), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + next_page_token='abc', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[], + next_page_token='def', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + ], + next_page_token='ghi', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_certificate_revocation_lists(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.CertificateRevocationList) + for i in results) + +def test_list_certificate_revocation_lists_pages(): + client = CertificateAuthorityServiceClient( + 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_revocation_lists), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + next_page_token='abc', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[], + next_page_token='def', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + ], + next_page_token='ghi', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + ), + RuntimeError, + ) + pages = list(client.list_certificate_revocation_lists(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_revocation_lists_async_pager(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_lists), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + next_page_token='abc', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[], + next_page_token='def', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + ], + next_page_token='ghi', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_certificate_revocation_lists(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.CertificateRevocationList) + for i in responses) + +@pytest.mark.asyncio +async def test_list_certificate_revocation_lists_async_pages(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_lists), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + next_page_token='abc', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[], + next_page_token='def', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + ], + next_page_token='ghi', + ), + service.ListCertificateRevocationListsResponse( + certificate_revocation_lists=[ + resources.CertificateRevocationList(), + resources.CertificateRevocationList(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_certificate_revocation_lists(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_update_certificate_revocation_list(transport: str = 'grpc', request_type=service.UpdateCertificateRevocationListRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_revocation_list), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_certificate_revocation_list(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateRevocationListRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_certificate_revocation_list_from_dict(): + test_update_certificate_revocation_list(request_type=dict) + + +def test_update_certificate_revocation_list_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 = CertificateAuthorityServiceClient( + 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_revocation_list), + '__call__') as call: + client.update_certificate_revocation_list() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateRevocationListRequest() + + +@pytest.mark.asyncio +async def test_update_certificate_revocation_list_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateRevocationListRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_revocation_list), + '__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_revocation_list(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCertificateRevocationListRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_certificate_revocation_list_async_from_dict(): + await test_update_certificate_revocation_list_async(request_type=dict) + + +def test_update_certificate_revocation_list_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateRevocationListRequest() + + request.certificate_revocation_list.name = 'certificate_revocation_list.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_revocation_list), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_certificate_revocation_list(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_revocation_list.name=certificate_revocation_list.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_certificate_revocation_list_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCertificateRevocationListRequest() + + request.certificate_revocation_list.name = 'certificate_revocation_list.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_certificate_revocation_list), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_certificate_revocation_list(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_revocation_list.name=certificate_revocation_list.name/value', + ) in kw['metadata'] + + +def test_update_certificate_revocation_list_flattened(): + client = CertificateAuthorityServiceClient( + 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_revocation_list), + '__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_revocation_list( + certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].certificate_revocation_list == resources.CertificateRevocationList(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_certificate_revocation_list_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_revocation_list( + service.UpdateCertificateRevocationListRequest(), + certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_certificate_revocation_list_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_list), + '__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_revocation_list( + certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].certificate_revocation_list == resources.CertificateRevocationList(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_certificate_revocation_list_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_revocation_list( + service.UpdateCertificateRevocationListRequest(), + certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_get_reusable_config(transport: str = 'grpc', request_type=service.GetReusableConfigRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_reusable_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ReusableConfig( + name='name_value', + description='description_value', + ) + response = client.get_reusable_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] == service.GetReusableConfigRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.ReusableConfig) + assert response.name == 'name_value' + assert response.description == 'description_value' + + +def test_get_reusable_config_from_dict(): + test_get_reusable_config(request_type=dict) + + +def test_get_reusable_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 = CertificateAuthorityServiceClient( + 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_reusable_config), + '__call__') as call: + client.get_reusable_config() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetReusableConfigRequest() + + +@pytest.mark.asyncio +async def test_get_reusable_config_async(transport: str = 'grpc_asyncio', request_type=service.GetReusableConfigRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_reusable_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.ReusableConfig( + name='name_value', + description='description_value', + )) + response = await client.get_reusable_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetReusableConfigRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.ReusableConfig) + assert response.name == 'name_value' + assert response.description == 'description_value' + + +@pytest.mark.asyncio +async def test_get_reusable_config_async_from_dict(): + await test_get_reusable_config_async(request_type=dict) + + +def test_get_reusable_config_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetReusableConfigRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_reusable_config), + '__call__') as call: + call.return_value = resources.ReusableConfig() + client.get_reusable_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_reusable_config_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetReusableConfigRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_reusable_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.ReusableConfig()) + await client.get_reusable_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_reusable_config_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_reusable_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ReusableConfig() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_reusable_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] + assert args[0].name == 'name_value' + + +def test_get_reusable_config_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_reusable_config( + service.GetReusableConfigRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_reusable_config_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_reusable_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.ReusableConfig() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.ReusableConfig()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_reusable_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] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_reusable_config_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_reusable_config( + service.GetReusableConfigRequest(), + name='name_value', + ) + + +def test_list_reusable_configs(transport: str = 'grpc', request_type=service.ListReusableConfigsRequest): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_reusable_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListReusableConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_reusable_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] == service.ListReusableConfigsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListReusableConfigsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_reusable_configs_from_dict(): + test_list_reusable_configs(request_type=dict) + + +def test_list_reusable_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 = CertificateAuthorityServiceClient( + 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_reusable_configs), + '__call__') as call: + client.list_reusable_configs() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListReusableConfigsRequest() + + +@pytest.mark.asyncio +async def test_list_reusable_configs_async(transport: str = 'grpc_asyncio', request_type=service.ListReusableConfigsRequest): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional 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_reusable_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListReusableConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_reusable_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListReusableConfigsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListReusableConfigsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_reusable_configs_async_from_dict(): + await test_list_reusable_configs_async(request_type=dict) + + +def test_list_reusable_configs_field_headers(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListReusableConfigsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_reusable_configs), + '__call__') as call: + call.return_value = service.ListReusableConfigsResponse() + client.list_reusable_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_reusable_configs_field_headers_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListReusableConfigsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_reusable_configs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListReusableConfigsResponse()) + await client.list_reusable_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_reusable_configs_flattened(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_reusable_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListReusableConfigsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_reusable_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] + assert args[0].parent == 'parent_value' + + +def test_list_reusable_configs_flattened_error(): + client = CertificateAuthorityServiceClient( + 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_reusable_configs( + service.ListReusableConfigsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_reusable_configs_flattened_async(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_reusable_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListReusableConfigsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListReusableConfigsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_reusable_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] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_reusable_configs_flattened_error_async(): + client = CertificateAuthorityServiceAsyncClient( + 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_reusable_configs( + service.ListReusableConfigsRequest(), + parent='parent_value', + ) + + +def test_list_reusable_configs_pager(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_reusable_configs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListReusableConfigsResponse( + reusable_configs=[ + resources.ReusableConfig(), + resources.ReusableConfig(), + resources.ReusableConfig(), + ], + next_page_token='abc', + ), + service.ListReusableConfigsResponse( + reusable_configs=[], + next_page_token='def', + ), + service.ListReusableConfigsResponse( + reusable_configs=[ + resources.ReusableConfig(), + ], + next_page_token='ghi', + ), + service.ListReusableConfigsResponse( + reusable_configs=[ + resources.ReusableConfig(), + resources.ReusableConfig(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_reusable_configs(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.ReusableConfig) + for i in results) + +def test_list_reusable_configs_pages(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_reusable_configs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListReusableConfigsResponse( + reusable_configs=[ + resources.ReusableConfig(), + resources.ReusableConfig(), + resources.ReusableConfig(), + ], + next_page_token='abc', + ), + service.ListReusableConfigsResponse( + reusable_configs=[], + next_page_token='def', + ), + service.ListReusableConfigsResponse( + reusable_configs=[ + resources.ReusableConfig(), + ], + next_page_token='ghi', + ), + service.ListReusableConfigsResponse( + reusable_configs=[ + resources.ReusableConfig(), + resources.ReusableConfig(), + ], + ), + RuntimeError, + ) + pages = list(client.list_reusable_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_reusable_configs_async_pager(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_reusable_configs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListReusableConfigsResponse( + reusable_configs=[ + resources.ReusableConfig(), + resources.ReusableConfig(), + resources.ReusableConfig(), + ], + next_page_token='abc', + ), + service.ListReusableConfigsResponse( + reusable_configs=[], + next_page_token='def', + ), + service.ListReusableConfigsResponse( + reusable_configs=[ + resources.ReusableConfig(), + ], + next_page_token='ghi', + ), + service.ListReusableConfigsResponse( + reusable_configs=[ + resources.ReusableConfig(), + resources.ReusableConfig(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_reusable_configs(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.ReusableConfig) + for i in responses) + +@pytest.mark.asyncio +async def test_list_reusable_configs_async_pages(): + client = CertificateAuthorityServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_reusable_configs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListReusableConfigsResponse( + reusable_configs=[ + resources.ReusableConfig(), + resources.ReusableConfig(), + resources.ReusableConfig(), + ], + next_page_token='abc', + ), + service.ListReusableConfigsResponse( + reusable_configs=[], + next_page_token='def', + ), + service.ListReusableConfigsResponse( + reusable_configs=[ + resources.ReusableConfig(), + ], + next_page_token='ghi', + ), + service.ListReusableConfigsResponse( + reusable_configs=[ + resources.ReusableConfig(), + resources.ReusableConfig(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_reusable_configs(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.CertificateAuthorityServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.CertificateAuthorityServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CertificateAuthorityServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.CertificateAuthorityServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CertificateAuthorityServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.CertificateAuthorityServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = CertificateAuthorityServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.CertificateAuthorityServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.CertificateAuthorityServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.CertificateAuthorityServiceGrpcTransport, + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, +]) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CertificateAuthorityServiceGrpcTransport, + ) + +def test_certificate_authority_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.CertificateAuthorityServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_certificate_authority_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.CertificateAuthorityServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_certificate', + 'get_certificate', + 'list_certificates', + 'revoke_certificate', + 'update_certificate', + 'activate_certificate_authority', + 'create_certificate_authority', + 'disable_certificate_authority', + 'enable_certificate_authority', + 'fetch_certificate_authority_csr', + 'get_certificate_authority', + 'list_certificate_authorities', + 'restore_certificate_authority', + 'schedule_delete_certificate_authority', + 'update_certificate_authority', + 'get_certificate_revocation_list', + 'list_certificate_revocation_lists', + 'update_certificate_revocation_list', + 'get_reusable_config', + 'list_reusable_configs', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + +@requires_google_auth_gte_1_25_0 +def test_certificate_authority_service_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CertificateAuthorityServiceTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_certificate_authority_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CertificateAuthorityServiceTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + quota_project_id="octopus", + ) + + +def test_certificate_authority_service_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CertificateAuthorityServiceTransport() + adc.assert_called_once() + + +@requires_google_auth_gte_1_25_0 +def test_certificate_authority_service_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + CertificateAuthorityServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_certificate_authority_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + CertificateAuthorityServiceClient() + adc.assert_called_once_with( + scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.CertificateAuthorityServiceGrpcTransport, + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_certificate_authority_service_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.CertificateAuthorityServiceGrpcTransport, + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_certificate_authority_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") + adc.assert_called_once_with(scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), + (transports.CertificateAuthorityServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +@requires_api_core_gte_1_26_0 +def test_certificate_authority_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class( + quota_project_id="octopus", + scopes=["1", "2"] + ) + + create_channel.assert_called_with( + "privateca.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="privateca.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), + (transports.CertificateAuthorityServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +@requires_api_core_lt_1_26_0 +def test_certificate_authority_service_transport_create_channel_old_api_core(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") + + create_channel.assert_called_with( + "privateca.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), + (transports.CertificateAuthorityServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +@requires_api_core_lt_1_26_0 +def test_certificate_authority_service_transport_create_channel_user_scopes(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( + "privateca.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.CertificateAuthorityServiceGrpcTransport, transports.CertificateAuthorityServiceGrpcAsyncIOTransport]) +def test_certificate_authority_service_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + 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_authority_service_host_no_port(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='privateca.googleapis.com'), + ) + assert client.transport._host == 'privateca.googleapis.com:443' + + +def test_certificate_authority_service_host_with_port(): + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='privateca.googleapis.com:8000'), + ) + assert client.transport._host == 'privateca.googleapis.com:8000' + +def test_certificate_authority_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CertificateAuthorityServiceGrpcTransport( + 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_authority_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CertificateAuthorityServiceGrpcAsyncIOTransport( + 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.CertificateAuthorityServiceGrpcTransport, transports.CertificateAuthorityServiceGrpcAsyncIOTransport]) +def test_certificate_authority_service_transport_channel_mtls_with_client_cert_source( + transport_class +): + with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + 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.CertificateAuthorityServiceGrpcTransport, transports.CertificateAuthorityServiceGrpcAsyncIOTransport]) +def test_certificate_authority_service_transport_channel_mtls_with_adc( + transport_class +): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=( + 'https://www.googleapis.com/auth/cloud-platform', + ), + 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_authority_service_grpc_lro_client(): + client = CertificateAuthorityServiceClient( + 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_authority_service_grpc_lro_async_client(): + client = CertificateAuthorityServiceAsyncClient( + 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_certificate_path(): + project = "squid" + location = "clam" + certificate_authority = "whelk" + certificate = "octopus" + expected = "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}/certificates/{certificate}".format(project=project, location=location, certificate_authority=certificate_authority, certificate=certificate, ) + actual = CertificateAuthorityServiceClient.certificate_path(project, location, certificate_authority, certificate) + assert expected == actual + + +def test_parse_certificate_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "certificate_authority": "cuttlefish", + "certificate": "mussel", + } + path = CertificateAuthorityServiceClient.certificate_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_certificate_path(path) + assert expected == actual + +def test_certificate_authority_path(): + project = "winkle" + location = "nautilus" + certificate_authority = "scallop" + expected = "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}".format(project=project, location=location, certificate_authority=certificate_authority, ) + actual = CertificateAuthorityServiceClient.certificate_authority_path(project, location, certificate_authority) + assert expected == actual + + +def test_parse_certificate_authority_path(): + expected = { + "project": "abalone", + "location": "squid", + "certificate_authority": "clam", + } + path = CertificateAuthorityServiceClient.certificate_authority_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_certificate_authority_path(path) + assert expected == actual + +def test_certificate_revocation_list_path(): + project = "whelk" + location = "octopus" + certificate_authority = "oyster" + certificate_revocation_list = "nudibranch" + expected = "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list}".format(project=project, location=location, certificate_authority=certificate_authority, certificate_revocation_list=certificate_revocation_list, ) + actual = CertificateAuthorityServiceClient.certificate_revocation_list_path(project, location, certificate_authority, certificate_revocation_list) + assert expected == actual + + +def test_parse_certificate_revocation_list_path(): + expected = { + "project": "cuttlefish", + "location": "mussel", + "certificate_authority": "winkle", + "certificate_revocation_list": "nautilus", + } + path = CertificateAuthorityServiceClient.certificate_revocation_list_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_certificate_revocation_list_path(path) + assert expected == actual + +def test_reusable_config_path(): + project = "scallop" + location = "abalone" + reusable_config = "squid" + expected = "projects/{project}/locations/{location}/reusableConfigs/{reusable_config}".format(project=project, location=location, reusable_config=reusable_config, ) + actual = CertificateAuthorityServiceClient.reusable_config_path(project, location, reusable_config) + assert expected == actual + + +def test_parse_reusable_config_path(): + expected = { + "project": "clam", + "location": "whelk", + "reusable_config": "octopus", + } + path = CertificateAuthorityServiceClient.reusable_config_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_reusable_config_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "oyster" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = CertificateAuthorityServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "nudibranch", + } + path = CertificateAuthorityServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "cuttlefish" + expected = "folders/{folder}".format(folder=folder, ) + actual = CertificateAuthorityServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "mussel", + } + path = CertificateAuthorityServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "winkle" + expected = "organizations/{organization}".format(organization=organization, ) + actual = CertificateAuthorityServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nautilus", + } + path = CertificateAuthorityServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "scallop" + expected = "projects/{project}".format(project=project, ) + actual = CertificateAuthorityServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "abalone", + } + path = CertificateAuthorityServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "squid" + location = "clam" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = CertificateAuthorityServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "whelk", + "location": "octopus", + } + path = CertificateAuthorityServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = CertificateAuthorityServiceClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_withDEFAULT_CLIENT_INFO(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.CertificateAuthorityServiceTransport, '_prep_wrapped_messages') as prep: + client = CertificateAuthorityServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.CertificateAuthorityServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = CertificateAuthorityServiceClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) From d914545ca945ac95d35312a28a8a21c85e988d6a Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 14 May 2021 04:53:33 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../certificate_authority_service.rst | 1 - .../certificate_authority_service.rst | 1 - google/cloud/security/privateca/__init__.py | 196 +- .../cloud/security/privateca_v1/__init__.py | 17 +- .../security/privateca_v1/gapic_metadata.json | 0 .../privateca_v1/services/__init__.py | 1 - .../certificate_authority_service/__init__.py | 2 - .../async_client.py | 102 +- .../certificate_authority_service/client.py | 184 +- .../certificate_authority_service/pagers.py | 12 +- .../transports/__init__.py | 2 - .../transports/base.py | 239 +- .../transports/grpc.py | 94 +- .../transports/grpc_asyncio.py | 84 +- .../security/privateca_v1/types/__init__.py | 2 - .../security/privateca_v1/types/resources.py | 341 +- .../security/privateca_v1/types/service.py | 280 +- .../security/privateca_v1beta1/__init__.py | 11 +- .../privateca_v1beta1/gapic_metadata.json | 0 .../privateca_v1beta1/services/__init__.py | 1 - .../certificate_authority_service/__init__.py | 2 - .../async_client.py | 76 +- .../certificate_authority_service/client.py | 145 +- .../certificate_authority_service/pagers.py | 10 +- .../transports/__init__.py | 2 - .../transports/base.py | 197 +- .../transports/grpc.py | 68 +- .../transports/grpc_asyncio.py | 60 +- .../privateca_v1beta1/types/__init__.py | 2 - .../privateca_v1beta1/types/resources.py | 314 +- .../privateca_v1beta1/types/service.py | 197 +- owl-bot-staging/v1/MANIFEST.in | 2 - owl-bot-staging/v1/README.rst | 49 - owl-bot-staging/v1/docs/conf.py | 376 - owl-bot-staging/v1/docs/index.rst | 7 - .../certificate_authority_service.rst | 10 - .../v1/docs/privateca_v1/services.rst | 6 - .../v1/docs/privateca_v1/types.rst | 7 - .../cloud/security/privateca/__init__.py | 135 - .../google/cloud/security/privateca/py.typed | 2 - .../cloud/security/privateca_v1/__init__.py | 136 - .../cloud/security/privateca_v1/py.typed | 2 - .../certificate_authority_service/__init__.py | 22 - .../async_client.py | 2874 ------ .../certificate_authority_service/client.py | 3097 ------ .../certificate_authority_service/pagers.py | 629 -- .../transports/__init__.py | 33 - .../transports/base.py | 582 -- .../transports/grpc.py | 1055 -- .../transports/grpc_asyncio.py | 1059 -- .../security/privateca_v1/types/__init__.py | 134 - .../security/privateca_v1/types/resources.py | 1896 ---- .../security/privateca_v1/types/service.py | 1656 --- owl-bot-staging/v1/mypy.ini | 3 - owl-bot-staging/v1/noxfile.py | 132 - .../v1/scripts/fixup_privateca_v1_keywords.py | 204 - owl-bot-staging/v1/setup.py | 53 - owl-bot-staging/v1/tests/unit/__init__.py | 16 - .../v1/tests/unit/gapic/__init__.py | 16 - .../tests/unit/gapic/privateca_v1/__init__.py | 16 - .../test_certificate_authority_service.py | 8989 ----------------- owl-bot-staging/v1beta1/MANIFEST.in | 2 - owl-bot-staging/v1beta1/README.rst | 49 - owl-bot-staging/v1beta1/docs/conf.py | 376 - owl-bot-staging/v1beta1/docs/index.rst | 7 - .../certificate_authority_service.rst | 10 - .../docs/privateca_v1beta1/services.rst | 6 - .../v1beta1/docs/privateca_v1beta1/types.rst | 7 - .../cloud/security/privateca/__init__.py | 107 - .../google/cloud/security/privateca/py.typed | 2 - .../security/privateca_v1beta1/__init__.py | 108 - .../cloud/security/privateca_v1beta1/py.typed | 2 - .../certificate_authority_service/__init__.py | 22 - .../async_client.py | 2001 ---- .../certificate_authority_service/client.py | 2215 ---- .../certificate_authority_service/pagers.py | 507 - .../transports/__init__.py | 33 - .../transports/base.py | 456 - .../transports/grpc.py | 814 -- .../transports/grpc_asyncio.py | 818 -- .../privateca_v1beta1/types/__init__.py | 106 - .../privateca_v1beta1/types/resources.py | 1687 ---- .../privateca_v1beta1/types/service.py | 1121 -- owl-bot-staging/v1beta1/mypy.ini | 3 - owl-bot-staging/v1beta1/noxfile.py | 132 - .../fixup_privateca_v1beta1_keywords.py | 195 - owl-bot-staging/v1beta1/setup.py | 53 - owl-bot-staging/v1beta1/tests/__init__.py | 16 - .../v1beta1/tests/unit/__init__.py | 16 - .../v1beta1/tests/unit/gapic/__init__.py | 16 - .../unit/gapic/privateca_v1beta1/__init__.py | 16 - .../test_certificate_authority_service.py | 6611 ------------ scripts/fixup_privateca_v1_keywords.py | 63 +- scripts/fixup_privateca_v1beta1_keywords.py | 45 +- .../services => tests}/__init__.py | 0 .../services => tests/unit}/__init__.py | 0 .../v1/tests => tests/unit/gapic}/__init__.py | 1 - tests/unit/gapic/privateca_v1/__init__.py | 1 - .../test_certificate_authority_service.py | 1427 ++- .../unit/gapic/privateca_v1beta1/__init__.py | 1 - .../test_certificate_authority_service.py | 1075 +- 101 files changed, 2295 insertions(+), 43673 deletions(-) rename {owl-bot-staging/v1/google => google}/cloud/security/privateca_v1/gapic_metadata.json (100%) rename {owl-bot-staging/v1beta1/google => google}/cloud/security/privateca_v1beta1/gapic_metadata.json (100%) delete mode 100644 owl-bot-staging/v1/MANIFEST.in delete mode 100644 owl-bot-staging/v1/README.rst delete mode 100644 owl-bot-staging/v1/docs/conf.py delete mode 100644 owl-bot-staging/v1/docs/index.rst delete mode 100644 owl-bot-staging/v1/docs/privateca_v1/certificate_authority_service.rst delete mode 100644 owl-bot-staging/v1/docs/privateca_v1/services.rst delete mode 100644 owl-bot-staging/v1/docs/privateca_v1/types.rst delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca/py.typed delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/py.typed delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/types/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/types/resources.py delete mode 100644 owl-bot-staging/v1/google/cloud/security/privateca_v1/types/service.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/scripts/fixup_privateca_v1_keywords.py delete mode 100644 owl-bot-staging/v1/setup.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/privateca_v1/__init__.py delete mode 100644 owl-bot-staging/v1/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py delete mode 100644 owl-bot-staging/v1beta1/MANIFEST.in delete mode 100644 owl-bot-staging/v1beta1/README.rst delete mode 100644 owl-bot-staging/v1beta1/docs/conf.py delete mode 100644 owl-bot-staging/v1beta1/docs/index.rst delete mode 100644 owl-bot-staging/v1beta1/docs/privateca_v1beta1/certificate_authority_service.rst delete mode 100644 owl-bot-staging/v1beta1/docs/privateca_v1beta1/services.rst delete mode 100644 owl-bot-staging/v1beta1/docs/privateca_v1beta1/types.rst delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca/__init__.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca/py.typed delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/__init__.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/py.typed delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/__init__.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/__init__.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/__init__.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/resources.py delete mode 100644 owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/service.py delete mode 100644 owl-bot-staging/v1beta1/mypy.ini delete mode 100644 owl-bot-staging/v1beta1/noxfile.py delete mode 100644 owl-bot-staging/v1beta1/scripts/fixup_privateca_v1beta1_keywords.py delete mode 100644 owl-bot-staging/v1beta1/setup.py delete mode 100644 owl-bot-staging/v1beta1/tests/__init__.py delete mode 100644 owl-bot-staging/v1beta1/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/__init__.py delete mode 100644 owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py rename {owl-bot-staging/v1/google/cloud/security/privateca_v1/services => tests}/__init__.py (100%) rename {owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services => tests/unit}/__init__.py (100%) rename {owl-bot-staging/v1/tests => tests/unit/gapic}/__init__.py (99%) diff --git a/docs/privateca_v1/certificate_authority_service.rst b/docs/privateca_v1/certificate_authority_service.rst index 5cf7339..00601bc 100644 --- a/docs/privateca_v1/certificate_authority_service.rst +++ b/docs/privateca_v1/certificate_authority_service.rst @@ -5,7 +5,6 @@ CertificateAuthorityService :members: :inherited-members: - .. automodule:: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers :members: :inherited-members: diff --git a/docs/privateca_v1beta1/certificate_authority_service.rst b/docs/privateca_v1beta1/certificate_authority_service.rst index e6f3134..536a4c8 100644 --- a/docs/privateca_v1beta1/certificate_authority_service.rst +++ b/docs/privateca_v1beta1/certificate_authority_service.rst @@ -5,7 +5,6 @@ CertificateAuthorityService :members: :inherited-members: - .. automodule:: google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers :members: :inherited-members: diff --git a/google/cloud/security/privateca/__init__.py b/google/cloud/security/privateca/__init__.py index bce2507..480932c 100644 --- a/google/cloud/security/privateca/__init__.py +++ b/google/cloud/security/privateca/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,152 +14,175 @@ # limitations under the License. # -from google.cloud.security.privateca_v1beta1.services.certificate_authority_service.async_client import ( - CertificateAuthorityServiceAsyncClient, -) -from google.cloud.security.privateca_v1beta1.services.certificate_authority_service.client import ( +from google.cloud.security.privateca_v1.services.certificate_authority_service.client import ( CertificateAuthorityServiceClient, ) -from google.cloud.security.privateca_v1beta1.types.resources import Certificate -from google.cloud.security.privateca_v1beta1.types.resources import CertificateAuthority -from google.cloud.security.privateca_v1beta1.types.resources import CertificateConfig -from google.cloud.security.privateca_v1beta1.types.resources import ( - CertificateDescription, -) -from google.cloud.security.privateca_v1beta1.types.resources import ( - CertificateRevocationList, -) -from google.cloud.security.privateca_v1beta1.types.resources import KeyUsage -from google.cloud.security.privateca_v1beta1.types.resources import ObjectId -from google.cloud.security.privateca_v1beta1.types.resources import PublicKey -from google.cloud.security.privateca_v1beta1.types.resources import ReusableConfig -from google.cloud.security.privateca_v1beta1.types.resources import ReusableConfigValues -from google.cloud.security.privateca_v1beta1.types.resources import ( - ReusableConfigWrapper, -) -from google.cloud.security.privateca_v1beta1.types.resources import RevocationReason -from google.cloud.security.privateca_v1beta1.types.resources import Subject -from google.cloud.security.privateca_v1beta1.types.resources import SubjectAltNames -from google.cloud.security.privateca_v1beta1.types.resources import SubordinateConfig -from google.cloud.security.privateca_v1beta1.types.resources import X509Extension -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.services.certificate_authority_service.async_client import ( + CertificateAuthorityServiceAsyncClient, +) + +from google.cloud.security.privateca_v1.types.resources import CaPool +from google.cloud.security.privateca_v1.types.resources import Certificate +from google.cloud.security.privateca_v1.types.resources import CertificateAuthority +from google.cloud.security.privateca_v1.types.resources import CertificateConfig +from google.cloud.security.privateca_v1.types.resources import CertificateDescription +from google.cloud.security.privateca_v1.types.resources import ( + CertificateExtensionConstraints, +) +from google.cloud.security.privateca_v1.types.resources import ( + CertificateIdentityConstraints, +) +from google.cloud.security.privateca_v1.types.resources import CertificateRevocationList +from google.cloud.security.privateca_v1.types.resources import CertificateTemplate +from google.cloud.security.privateca_v1.types.resources import KeyUsage +from google.cloud.security.privateca_v1.types.resources import ObjectId +from google.cloud.security.privateca_v1.types.resources import PublicKey +from google.cloud.security.privateca_v1.types.resources import Subject +from google.cloud.security.privateca_v1.types.resources import SubjectAltNames +from google.cloud.security.privateca_v1.types.resources import SubordinateConfig +from google.cloud.security.privateca_v1.types.resources import X509Extension +from google.cloud.security.privateca_v1.types.resources import X509Parameters +from google.cloud.security.privateca_v1.types.resources import RevocationReason +from google.cloud.security.privateca_v1.types.resources import SubjectRequestMode +from google.cloud.security.privateca_v1.types.service import ( ActivateCertificateAuthorityRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import CreateCaPoolRequest +from google.cloud.security.privateca_v1.types.service import ( CreateCertificateAuthorityRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import ( - CreateCertificateRequest, +from google.cloud.security.privateca_v1.types.service import CreateCertificateRequest +from google.cloud.security.privateca_v1.types.service import ( + CreateCertificateTemplateRequest, +) +from google.cloud.security.privateca_v1.types.service import DeleteCaPoolRequest +from google.cloud.security.privateca_v1.types.service import ( + DeleteCertificateAuthorityRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import ( + DeleteCertificateTemplateRequest, +) +from google.cloud.security.privateca_v1.types.service import ( DisableCertificateAuthorityRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import ( EnableCertificateAuthorityRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import FetchCaCertsRequest +from google.cloud.security.privateca_v1.types.service import FetchCaCertsResponse +from google.cloud.security.privateca_v1.types.service import ( FetchCertificateAuthorityCsrRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import ( FetchCertificateAuthorityCsrResponse, ) -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import GetCaPoolRequest +from google.cloud.security.privateca_v1.types.service import ( GetCertificateAuthorityRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import GetCertificateRequest -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import GetCertificateRequest +from google.cloud.security.privateca_v1.types.service import ( GetCertificateRevocationListRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import ( - GetReusableConfigRequest, +from google.cloud.security.privateca_v1.types.service import ( + GetCertificateTemplateRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import ListCaPoolsRequest +from google.cloud.security.privateca_v1.types.service import ListCaPoolsResponse +from google.cloud.security.privateca_v1.types.service import ( ListCertificateAuthoritiesRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import ( ListCertificateAuthoritiesResponse, ) -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import ( ListCertificateRevocationListsRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import ( ListCertificateRevocationListsResponse, ) -from google.cloud.security.privateca_v1beta1.types.service import ( - ListCertificatesRequest, -) -from google.cloud.security.privateca_v1beta1.types.service import ( - ListCertificatesResponse, +from google.cloud.security.privateca_v1.types.service import ListCertificatesRequest +from google.cloud.security.privateca_v1.types.service import ListCertificatesResponse +from google.cloud.security.privateca_v1.types.service import ( + ListCertificateTemplatesRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import ( - ListReusableConfigsRequest, +from google.cloud.security.privateca_v1.types.service import ( + ListCertificateTemplatesResponse, ) -from google.cloud.security.privateca_v1beta1.types.service import ( - ListReusableConfigsResponse, +from google.cloud.security.privateca_v1.types.service import OperationMetadata +from google.cloud.security.privateca_v1.types.service import RevokeCertificateRequest +from google.cloud.security.privateca_v1.types.service import ( + UndeleteCertificateAuthorityRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import OperationMetadata -from google.cloud.security.privateca_v1beta1.types.service import ( - RestoreCertificateAuthorityRequest, -) -from google.cloud.security.privateca_v1beta1.types.service import ( - RevokeCertificateRequest, -) -from google.cloud.security.privateca_v1beta1.types.service import ( - ScheduleDeleteCertificateAuthorityRequest, -) -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import UpdateCaPoolRequest +from google.cloud.security.privateca_v1.types.service import ( UpdateCertificateAuthorityRequest, ) -from google.cloud.security.privateca_v1beta1.types.service import ( - UpdateCertificateRequest, -) -from google.cloud.security.privateca_v1beta1.types.service import ( +from google.cloud.security.privateca_v1.types.service import UpdateCertificateRequest +from google.cloud.security.privateca_v1.types.service import ( UpdateCertificateRevocationListRequest, ) +from google.cloud.security.privateca_v1.types.service import ( + UpdateCertificateTemplateRequest, +) __all__ = ( - "ActivateCertificateAuthorityRequest", + "CertificateAuthorityServiceClient", + "CertificateAuthorityServiceAsyncClient", + "CaPool", "Certificate", "CertificateAuthority", - "CertificateAuthorityServiceAsyncClient", - "CertificateAuthorityServiceClient", "CertificateConfig", "CertificateDescription", + "CertificateExtensionConstraints", + "CertificateIdentityConstraints", "CertificateRevocationList", + "CertificateTemplate", + "KeyUsage", + "ObjectId", + "PublicKey", + "Subject", + "SubjectAltNames", + "SubordinateConfig", + "X509Extension", + "X509Parameters", + "RevocationReason", + "SubjectRequestMode", + "ActivateCertificateAuthorityRequest", + "CreateCaPoolRequest", "CreateCertificateAuthorityRequest", "CreateCertificateRequest", + "CreateCertificateTemplateRequest", + "DeleteCaPoolRequest", + "DeleteCertificateAuthorityRequest", + "DeleteCertificateTemplateRequest", "DisableCertificateAuthorityRequest", "EnableCertificateAuthorityRequest", + "FetchCaCertsRequest", + "FetchCaCertsResponse", "FetchCertificateAuthorityCsrRequest", "FetchCertificateAuthorityCsrResponse", + "GetCaPoolRequest", "GetCertificateAuthorityRequest", "GetCertificateRequest", "GetCertificateRevocationListRequest", - "GetReusableConfigRequest", - "KeyUsage", + "GetCertificateTemplateRequest", + "ListCaPoolsRequest", + "ListCaPoolsResponse", "ListCertificateAuthoritiesRequest", "ListCertificateAuthoritiesResponse", "ListCertificateRevocationListsRequest", "ListCertificateRevocationListsResponse", "ListCertificatesRequest", "ListCertificatesResponse", - "ListReusableConfigsRequest", - "ListReusableConfigsResponse", - "ObjectId", + "ListCertificateTemplatesRequest", + "ListCertificateTemplatesResponse", "OperationMetadata", - "PublicKey", - "RestoreCertificateAuthorityRequest", - "ReusableConfig", - "ReusableConfigValues", - "ReusableConfigWrapper", - "RevocationReason", "RevokeCertificateRequest", - "ScheduleDeleteCertificateAuthorityRequest", - "Subject", - "SubjectAltNames", - "SubordinateConfig", + "UndeleteCertificateAuthorityRequest", + "UpdateCaPoolRequest", "UpdateCertificateAuthorityRequest", "UpdateCertificateRequest", "UpdateCertificateRevocationListRequest", - "X509Extension", + "UpdateCertificateTemplateRequest", ) diff --git a/google/cloud/security/privateca_v1/__init__.py b/google/cloud/security/privateca_v1/__init__.py index 9d54ac9..4137916 100644 --- a/google/cloud/security/privateca_v1/__init__.py +++ b/google/cloud/security/privateca_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +15,10 @@ # from .services.certificate_authority_service import CertificateAuthorityServiceClient +from .services.certificate_authority_service import ( + CertificateAuthorityServiceAsyncClient, +) + from .types.resources import CaPool from .types.resources import Certificate from .types.resources import CertificateAuthority @@ -28,13 +31,13 @@ from .types.resources import KeyUsage from .types.resources import ObjectId from .types.resources import PublicKey -from .types.resources import RevocationReason from .types.resources import Subject from .types.resources import SubjectAltNames -from .types.resources import SubjectRequestMode from .types.resources import SubordinateConfig from .types.resources import X509Extension from .types.resources import X509Parameters +from .types.resources import RevocationReason +from .types.resources import SubjectRequestMode from .types.service import ActivateCertificateAuthorityRequest from .types.service import CreateCaPoolRequest from .types.service import CreateCertificateAuthorityRequest @@ -60,10 +63,10 @@ from .types.service import ListCertificateAuthoritiesResponse from .types.service import ListCertificateRevocationListsRequest from .types.service import ListCertificateRevocationListsResponse -from .types.service import ListCertificateTemplatesRequest -from .types.service import ListCertificateTemplatesResponse from .types.service import ListCertificatesRequest from .types.service import ListCertificatesResponse +from .types.service import ListCertificateTemplatesRequest +from .types.service import ListCertificateTemplatesResponse from .types.service import OperationMetadata from .types.service import RevokeCertificateRequest from .types.service import UndeleteCertificateAuthorityRequest @@ -73,12 +76,13 @@ from .types.service import UpdateCertificateRevocationListRequest from .types.service import UpdateCertificateTemplateRequest - __all__ = ( + "CertificateAuthorityServiceAsyncClient", "ActivateCertificateAuthorityRequest", "CaPool", "Certificate", "CertificateAuthority", + "CertificateAuthorityServiceClient", "CertificateConfig", "CertificateDescription", "CertificateExtensionConstraints", @@ -131,5 +135,4 @@ "UpdateCertificateTemplateRequest", "X509Extension", "X509Parameters", - "CertificateAuthorityServiceClient", ) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/gapic_metadata.json b/google/cloud/security/privateca_v1/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1/google/cloud/security/privateca_v1/gapic_metadata.json rename to google/cloud/security/privateca_v1/gapic_metadata.json diff --git a/google/cloud/security/privateca_v1/services/__init__.py b/google/cloud/security/privateca_v1/services/__init__.py index 42ffdf2..4de6597 100644 --- a/google/cloud/security/privateca_v1/services/__init__.py +++ b/google/cloud/security/privateca_v1/services/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/google/cloud/security/privateca_v1/services/certificate_authority_service/__init__.py b/google/cloud/security/privateca_v1/services/certificate_authority_service/__init__.py index d837719..f519622 100644 --- a/google/cloud/security/privateca_v1/services/certificate_authority_service/__init__.py +++ b/google/cloud/security/privateca_v1/services/certificate_authority_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import CertificateAuthorityServiceClient from .async_client import CertificateAuthorityServiceAsyncClient diff --git a/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py b/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py index 0f76a45..792a60b 100644 --- a/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py +++ b/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore @@ -35,11 +33,10 @@ ) from google.cloud.security.privateca_v1.types import resources from google.cloud.security.privateca_v1.types import service -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +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 CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport from .client import CertificateAuthorityServiceClient @@ -82,35 +79,30 @@ class CertificateAuthorityServiceAsyncClient: parse_certificate_template_path = staticmethod( CertificateAuthorityServiceClient.parse_certificate_template_path ) - common_billing_account_path = staticmethod( CertificateAuthorityServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( CertificateAuthorityServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod( CertificateAuthorityServiceClient.common_folder_path ) parse_common_folder_path = staticmethod( CertificateAuthorityServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( CertificateAuthorityServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( CertificateAuthorityServiceClient.parse_common_organization_path ) - common_project_path = staticmethod( CertificateAuthorityServiceClient.common_project_path ) parse_common_project_path = staticmethod( CertificateAuthorityServiceClient.parse_common_project_path ) - common_location_path = staticmethod( CertificateAuthorityServiceClient.common_location_path ) @@ -120,7 +112,8 @@ class CertificateAuthorityServiceAsyncClient: @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -135,7 +128,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -152,7 +145,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> CertificateAuthorityServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: CertificateAuthorityServiceTransport: The transport used by the client instance. @@ -167,12 +160,12 @@ def transport(self) -> CertificateAuthorityServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, CertificateAuthorityServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the certificate authority service client. + """Instantiates the certificate authority service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -204,7 +197,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = CertificateAuthorityServiceClient( credentials=credentials, transport=transport, @@ -261,7 +253,6 @@ async def create_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. @@ -288,7 +279,6 @@ async def create_certificate( # 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: @@ -342,7 +332,6 @@ async def get_certificate( 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. @@ -369,7 +358,6 @@ async def get_certificate( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -418,7 +406,6 @@ async def list_certificates( 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. @@ -448,7 +435,6 @@ async def list_certificates( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -503,7 +489,6 @@ async def revoke_certificate( 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. @@ -530,7 +515,6 @@ async def revoke_certificate( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -559,7 +543,7 @@ async def update_certificate( request: service.UpdateCertificateRequest = None, *, certificate: resources.Certificate = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -589,7 +573,6 @@ async def update_certificate( 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. @@ -616,7 +599,6 @@ async def update_certificate( # 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: @@ -677,7 +659,6 @@ async def activate_certificate_authority( 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. @@ -709,7 +690,6 @@ async def activate_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -785,7 +765,6 @@ async def create_certificate_authority( This corresponds to the ``certificate_authority_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. @@ -819,7 +798,6 @@ async def create_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if certificate_authority is not None: @@ -880,7 +858,6 @@ async def disable_certificate_authority( 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. @@ -912,7 +889,6 @@ async def disable_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -969,7 +945,6 @@ async def enable_certificate_authority( 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. @@ -1001,7 +976,6 @@ async def enable_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1067,7 +1041,6 @@ async def fetch_certificate_authority_csr( 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. @@ -1094,7 +1067,6 @@ async def fetch_certificate_authority_csr( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1144,7 +1116,6 @@ async def get_certificate_authority( 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. @@ -1174,7 +1145,6 @@ async def get_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1224,7 +1194,6 @@ async def list_certificate_authorities( 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. @@ -1254,7 +1223,6 @@ async def list_certificate_authorities( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1310,7 +1278,6 @@ async def undelete_certificate_authority( 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. @@ -1342,7 +1309,6 @@ async def undelete_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1399,7 +1365,6 @@ async def delete_certificate_authority( 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. @@ -1431,7 +1396,6 @@ async def delete_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1468,7 +1432,7 @@ async def update_certificate_authority( request: service.UpdateCertificateAuthorityRequest = None, *, certificate_authority: resources.CertificateAuthority = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1495,7 +1459,6 @@ async def update_certificate_authority( 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. @@ -1527,7 +1490,6 @@ async def update_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if certificate_authority is not None: request.certificate_authority = certificate_authority if update_mask is not None: @@ -1604,7 +1566,6 @@ async def create_ca_pool( This corresponds to the ``ca_pool_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. @@ -1640,7 +1601,6 @@ async def create_ca_pool( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if ca_pool is not None: @@ -1681,7 +1641,7 @@ async def update_ca_pool( request: service.UpdateCaPoolRequest = None, *, ca_pool: resources.CaPool = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1707,7 +1667,6 @@ async def update_ca_pool( 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. @@ -1743,7 +1702,6 @@ async def update_ca_pool( # If we have keyword arguments corresponding to fields on the # request, apply these. - if ca_pool is not None: request.ca_pool = ca_pool if update_mask is not None: @@ -1804,7 +1762,6 @@ async def get_ca_pool( 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. @@ -1838,7 +1795,6 @@ async def get_ca_pool( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1886,7 +1842,6 @@ async def list_ca_pools( 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. @@ -1916,7 +1871,6 @@ async def list_ca_pools( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1969,7 +1923,6 @@ async def delete_ca_pool( 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. @@ -2005,7 +1958,6 @@ async def delete_ca_pool( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2065,7 +2017,6 @@ async def fetch_ca_certs( This corresponds to the ``ca_pool`` 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. @@ -2092,7 +2043,6 @@ async def fetch_ca_certs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if ca_pool is not None: request.ca_pool = ca_pool @@ -2142,7 +2092,6 @@ async def get_certificate_revocation_list( 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. @@ -2171,7 +2120,6 @@ async def get_certificate_revocation_list( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2221,7 +2169,6 @@ async def list_certificate_revocation_lists( 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. @@ -2251,7 +2198,6 @@ async def list_certificate_revocation_lists( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2286,7 +2232,7 @@ async def update_certificate_revocation_list( request: service.UpdateCertificateRevocationListRequest = None, *, certificate_revocation_list: resources.CertificateRevocationList = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2313,7 +2259,6 @@ async def update_certificate_revocation_list( 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. @@ -2344,7 +2289,6 @@ async def update_certificate_revocation_list( # If we have keyword arguments corresponding to fields on the # request, apply these. - if certificate_revocation_list is not None: request.certificate_revocation_list = certificate_revocation_list if update_mask is not None: @@ -2428,7 +2372,6 @@ async def create_certificate_template( This corresponds to the ``certificate_template_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. @@ -2459,7 +2402,6 @@ async def create_certificate_template( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if certificate_template is not None: @@ -2520,7 +2462,6 @@ async def delete_certificate_template( 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. @@ -2560,7 +2501,6 @@ async def delete_certificate_template( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2585,7 +2525,7 @@ async def delete_certificate_template( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=service.OperationMetadata, ) @@ -2618,7 +2558,6 @@ async def get_certificate_template( 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. @@ -2645,7 +2584,6 @@ async def get_certificate_template( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2694,7 +2632,6 @@ async def list_certificate_templates( 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. @@ -2724,7 +2661,6 @@ async def list_certificate_templates( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2759,7 +2695,7 @@ async def update_certificate_template( request: service.UpdateCertificateTemplateRequest = None, *, certificate_template: resources.CertificateTemplate = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2786,7 +2722,6 @@ async def update_certificate_template( 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. @@ -2815,7 +2750,6 @@ async def update_certificate_template( # If we have keyword arguments corresponding to fields on the # request, apply these. - if certificate_template is not None: request.certificate_template = certificate_template if update_mask is not None: diff --git a/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py b/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py index ad3047f..ac7e7d5 100644 --- a/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py +++ b/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -39,11 +37,10 @@ ) from google.cloud.security.privateca_v1.types import resources from google.cloud.security.privateca_v1.types import service -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +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 CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import CertificateAuthorityServiceGrpcTransport from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport @@ -68,7 +65,7 @@ class CertificateAuthorityServiceClientMeta(type): def get_transport_class( cls, label: str = None, ) -> Type[CertificateAuthorityServiceTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -96,7 +93,8 @@ class CertificateAuthorityServiceClient( @staticmethod def _get_default_mtls_endpoint(api_endpoint): - """Convert api endpoint to mTLS 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: @@ -130,7 +128,8 @@ def _get_default_mtls_endpoint(api_endpoint): @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -147,7 +146,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -166,23 +165,24 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> CertificateAuthorityServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - CertificateAuthorityServiceTransport: The transport used by the client instance. + CertificateAuthorityServiceTransport: The transport used by the client + instance. """ return self._transport @staticmethod def ca_pool_path(project: str, location: str, ca_pool: str,) -> str: - """Return a fully-qualified ca_pool string.""" + """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]: - """Parse a ca_pool path into its component segments.""" + """Parses a ca_pool path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/caPools/(?P.+?)$", path, @@ -193,7 +193,7 @@ def parse_ca_pool_path(path: str) -> Dict[str, str]: def certificate_path( project: str, location: str, ca_pool: str, certificate: str, ) -> str: - """Return a fully-qualified certificate string.""" + """Returns a fully-qualified certificate string.""" return "projects/{project}/locations/{location}/caPools/{ca_pool}/certificates/{certificate}".format( project=project, location=location, @@ -203,7 +203,7 @@ def certificate_path( @staticmethod def parse_certificate_path(path: str) -> Dict[str, str]: - """Parse a certificate path into its component segments.""" + """Parses a certificate path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/caPools/(?P.+?)/certificates/(?P.+?)$", path, @@ -214,7 +214,7 @@ def parse_certificate_path(path: str) -> Dict[str, str]: def certificate_authority_path( project: str, location: str, ca_pool: str, certificate_authority: str, ) -> str: - """Return a fully-qualified certificate_authority string.""" + """Returns a fully-qualified certificate_authority string.""" return "projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}".format( project=project, location=location, @@ -224,7 +224,7 @@ def certificate_authority_path( @staticmethod def parse_certificate_authority_path(path: str) -> Dict[str, str]: - """Parse a certificate_authority path into its component segments.""" + """Parses a certificate_authority path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/caPools/(?P.+?)/certificateAuthorities/(?P.+?)$", path, @@ -239,7 +239,7 @@ def certificate_revocation_list_path( certificate_authority: str, certificate_revocation_list: str, ) -> str: - """Return a fully-qualified certificate_revocation_list string.""" + """Returns a fully-qualified certificate_revocation_list string.""" return "projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list}".format( project=project, location=location, @@ -250,7 +250,7 @@ def certificate_revocation_list_path( @staticmethod def parse_certificate_revocation_list_path(path: str) -> Dict[str, str]: - """Parse a certificate_revocation_list path into its component segments.""" + """Parses a certificate_revocation_list path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/caPools/(?P.+?)/certificateAuthorities/(?P.+?)/certificateRevocationLists/(?P.+?)$", path, @@ -261,7 +261,7 @@ def parse_certificate_revocation_list_path(path: str) -> Dict[str, str]: def certificate_template_path( project: str, location: str, certificate_template: str, ) -> str: - """Return a fully-qualified certificate_template string.""" + """Returns a fully-qualified certificate_template string.""" return "projects/{project}/locations/{location}/certificateTemplates/{certificate_template}".format( project=project, location=location, @@ -270,7 +270,7 @@ def certificate_template_path( @staticmethod def parse_certificate_template_path(path: str) -> Dict[str, str]: - """Parse a certificate_template path into its component segments.""" + """Parses a certificate_template path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/certificateTemplates/(?P.+?)$", path, @@ -279,7 +279,7 @@ def parse_certificate_template_path(path: str) -> Dict[str, str]: @staticmethod def common_billing_account_path(billing_account: str,) -> str: - """Return a fully-qualified billing_account string.""" + """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -292,7 +292,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: @staticmethod def common_folder_path(folder: str,) -> str: - """Return a fully-qualified folder string.""" + """Returns a fully-qualified folder string.""" return "folders/{folder}".format(folder=folder,) @staticmethod @@ -303,7 +303,7 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: @staticmethod def common_organization_path(organization: str,) -> str: - """Return a fully-qualified organization string.""" + """Returns a fully-qualified organization string.""" return "organizations/{organization}".format(organization=organization,) @staticmethod @@ -314,7 +314,7 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: @staticmethod def common_project_path(project: str,) -> str: - """Return a fully-qualified project string.""" + """Returns a fully-qualified project string.""" return "projects/{project}".format(project=project,) @staticmethod @@ -325,7 +325,7 @@ def parse_common_project_path(path: str) -> Dict[str, str]: @staticmethod def common_location_path(project: str, location: str,) -> str: - """Return a fully-qualified location string.""" + """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -339,12 +339,12 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, CertificateAuthorityServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the certificate authority service client. + """Instantiates the certificate authority service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -399,9 +399,10 @@ def __init__( client_cert_source_func = client_options.client_cert_source else: is_mtls = mtls.has_default_client_cert_source() - client_cert_source_func = ( - mtls.default_client_cert_source() if is_mtls else None - ) + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None # Figure out which api endpoint to use. if client_options.api_endpoint is not None: @@ -413,12 +414,14 @@ def __init__( elif use_mtls_env == "always": api_endpoint = self.DEFAULT_MTLS_ENDPOINT elif use_mtls_env == "auto": - api_endpoint = ( - self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT - ) + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT else: raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always" + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" ) # Save or instantiate the transport. @@ -433,8 +436,8 @@ def __init__( ) if client_options.scopes: raise ValueError( - "When providing a transport instance, " - "provide its scopes directly." + "When providing a transport instance, provide its scopes " + "directly." ) self._transport = transport else: @@ -498,7 +501,6 @@ def create_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. @@ -527,10 +529,8 @@ def create_certificate( # there are no flattened fields. if not isinstance(request, service.CreateCertificateRequest): request = service.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: @@ -580,7 +580,6 @@ def get_certificate( 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. @@ -609,10 +608,8 @@ def get_certificate( # there are no flattened fields. if not isinstance(request, service.GetCertificateRequest): request = service.GetCertificateRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -657,7 +654,6 @@ def list_certificates( 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. @@ -689,10 +685,8 @@ def list_certificates( # there are no flattened fields. if not isinstance(request, service.ListCertificatesRequest): request = service.ListCertificatesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -743,7 +737,6 @@ def revoke_certificate( 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. @@ -772,10 +765,8 @@ def revoke_certificate( # there are no flattened fields. if not isinstance(request, service.RevokeCertificateRequest): request = service.RevokeCertificateRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -800,7 +791,7 @@ def update_certificate( request: service.UpdateCertificateRequest = None, *, certificate: resources.Certificate = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -830,7 +821,6 @@ def update_certificate( 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. @@ -859,10 +849,8 @@ def update_certificate( # there are no flattened fields. if not isinstance(request, service.UpdateCertificateRequest): request = service.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: @@ -919,7 +907,6 @@ def activate_certificate_authority( 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. @@ -953,10 +940,8 @@ def activate_certificate_authority( # there are no flattened fields. if not isinstance(request, service.ActivateCertificateAuthorityRequest): request = service.ActivateCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1030,7 +1015,6 @@ def create_certificate_authority( This corresponds to the ``certificate_authority_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. @@ -1066,10 +1050,8 @@ def create_certificate_authority( # there are no flattened fields. if not isinstance(request, service.CreateCertificateAuthorityRequest): request = service.CreateCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if certificate_authority is not None: @@ -1128,7 +1110,6 @@ def disable_certificate_authority( 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. @@ -1162,10 +1143,8 @@ def disable_certificate_authority( # there are no flattened fields. if not isinstance(request, service.DisableCertificateAuthorityRequest): request = service.DisableCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1220,7 +1199,6 @@ def enable_certificate_authority( 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. @@ -1254,10 +1232,8 @@ def enable_certificate_authority( # there are no flattened fields. if not isinstance(request, service.EnableCertificateAuthorityRequest): request = service.EnableCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1321,7 +1297,6 @@ def fetch_certificate_authority_csr( 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. @@ -1350,10 +1325,8 @@ def fetch_certificate_authority_csr( # there are no flattened fields. if not isinstance(request, service.FetchCertificateAuthorityCsrRequest): request = service.FetchCertificateAuthorityCsrRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1401,7 +1374,6 @@ def get_certificate_authority( 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. @@ -1433,10 +1405,8 @@ def get_certificate_authority( # there are no flattened fields. if not isinstance(request, service.GetCertificateAuthorityRequest): request = service.GetCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1484,7 +1454,6 @@ def list_certificate_authorities( 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. @@ -1516,10 +1485,8 @@ def list_certificate_authorities( # there are no flattened fields. if not isinstance(request, service.ListCertificateAuthoritiesRequest): request = service.ListCertificateAuthoritiesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1573,7 +1540,6 @@ def undelete_certificate_authority( 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. @@ -1607,10 +1573,8 @@ def undelete_certificate_authority( # there are no flattened fields. if not isinstance(request, service.UndeleteCertificateAuthorityRequest): request = service.UndeleteCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1665,7 +1629,6 @@ def delete_certificate_authority( 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. @@ -1699,10 +1662,8 @@ def delete_certificate_authority( # there are no flattened fields. if not isinstance(request, service.DeleteCertificateAuthorityRequest): request = service.DeleteCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1737,7 +1698,7 @@ def update_certificate_authority( request: service.UpdateCertificateAuthorityRequest = None, *, certificate_authority: resources.CertificateAuthority = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1764,7 +1725,6 @@ def update_certificate_authority( 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. @@ -1798,10 +1758,8 @@ def update_certificate_authority( # there are no flattened fields. if not isinstance(request, service.UpdateCertificateAuthorityRequest): request = service.UpdateCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if certificate_authority is not None: request.certificate_authority = certificate_authority if update_mask is not None: @@ -1876,7 +1834,6 @@ def create_ca_pool( This corresponds to the ``ca_pool_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. @@ -1914,10 +1871,8 @@ def create_ca_pool( # there are no flattened fields. if not isinstance(request, service.CreateCaPoolRequest): request = service.CreateCaPoolRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if ca_pool is not None: @@ -1954,7 +1909,7 @@ def update_ca_pool( request: service.UpdateCaPoolRequest = None, *, ca_pool: resources.CaPool = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1980,7 +1935,6 @@ def update_ca_pool( 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. @@ -2018,10 +1972,8 @@ def update_ca_pool( # there are no flattened fields. if not isinstance(request, service.UpdateCaPoolRequest): request = service.UpdateCaPoolRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if ca_pool is not None: request.ca_pool = ca_pool if update_mask is not None: @@ -2078,7 +2030,6 @@ def get_ca_pool( 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. @@ -2114,10 +2065,8 @@ def get_ca_pool( # there are no flattened fields. if not isinstance(request, service.GetCaPoolRequest): request = service.GetCaPoolRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2161,7 +2110,6 @@ def list_ca_pools( 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. @@ -2193,10 +2141,8 @@ def list_ca_pools( # there are no flattened fields. if not isinstance(request, service.ListCaPoolsRequest): request = service.ListCaPoolsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2245,7 +2191,6 @@ def delete_ca_pool( 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. @@ -2283,10 +2228,8 @@ def delete_ca_pool( # there are no flattened fields. if not isinstance(request, service.DeleteCaPoolRequest): request = service.DeleteCaPoolRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2342,7 +2285,6 @@ def fetch_ca_certs( This corresponds to the ``ca_pool`` 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. @@ -2371,10 +2313,8 @@ def fetch_ca_certs( # there are no flattened fields. if not isinstance(request, service.FetchCaCertsRequest): request = service.FetchCaCertsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if ca_pool is not None: request.ca_pool = ca_pool @@ -2420,7 +2360,6 @@ def get_certificate_revocation_list( 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. @@ -2451,10 +2390,8 @@ def get_certificate_revocation_list( # there are no flattened fields. if not isinstance(request, service.GetCertificateRevocationListRequest): request = service.GetCertificateRevocationListRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2502,7 +2439,6 @@ def list_certificate_revocation_lists( 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. @@ -2534,10 +2470,8 @@ def list_certificate_revocation_lists( # there are no flattened fields. if not isinstance(request, service.ListCertificateRevocationListsRequest): request = service.ListCertificateRevocationListsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2570,7 +2504,7 @@ def update_certificate_revocation_list( request: service.UpdateCertificateRevocationListRequest = None, *, certificate_revocation_list: resources.CertificateRevocationList = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2597,7 +2531,6 @@ def update_certificate_revocation_list( 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. @@ -2630,10 +2563,8 @@ def update_certificate_revocation_list( # there are no flattened fields. if not isinstance(request, service.UpdateCertificateRevocationListRequest): request = service.UpdateCertificateRevocationListRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if certificate_revocation_list is not None: request.certificate_revocation_list = certificate_revocation_list if update_mask is not None: @@ -2715,7 +2646,6 @@ def create_certificate_template( This corresponds to the ``certificate_template_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. @@ -2748,10 +2678,8 @@ def create_certificate_template( # there are no flattened fields. if not isinstance(request, service.CreateCertificateTemplateRequest): request = service.CreateCertificateTemplateRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if certificate_template is not None: @@ -2810,7 +2738,6 @@ def delete_certificate_template( 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. @@ -2852,10 +2779,8 @@ def delete_certificate_template( # there are no flattened fields. if not isinstance(request, service.DeleteCertificateTemplateRequest): request = service.DeleteCertificateTemplateRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2878,7 +2803,7 @@ def delete_certificate_template( response = operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=service.OperationMetadata, ) @@ -2911,7 +2836,6 @@ def get_certificate_template( 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. @@ -2940,10 +2864,8 @@ def get_certificate_template( # there are no flattened fields. if not isinstance(request, service.GetCertificateTemplateRequest): request = service.GetCertificateTemplateRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2988,7 +2910,6 @@ def list_certificate_templates( 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. @@ -3020,10 +2941,8 @@ def list_certificate_templates( # there are no flattened fields. if not isinstance(request, service.ListCertificateTemplatesRequest): request = service.ListCertificateTemplatesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -3056,7 +2975,7 @@ def update_certificate_template( request: service.UpdateCertificateTemplateRequest = None, *, certificate_template: resources.CertificateTemplate = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -3083,7 +3002,6 @@ def update_certificate_template( 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. @@ -3114,10 +3032,8 @@ def update_certificate_template( # there are no flattened fields. if not isinstance(request, service.UpdateCertificateTemplateRequest): request = service.UpdateCertificateTemplateRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if certificate_template is not None: request.certificate_template = certificate_template if update_mask is not None: diff --git a/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py b/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py index 99ef635..689e033 100644 --- a/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py +++ b/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, @@ -118,7 +116,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -246,7 +244,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -374,7 +372,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -504,7 +502,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -634,7 +632,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and diff --git a/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/__init__.py b/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/__init__.py index 3a3aa46..ab66300 100644 --- a/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/__init__.py +++ b/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py b/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py index 0f8d05d..9a0216f 100644 --- a/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py +++ b/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.security.privateca_v1.types import resources from google.cloud.security.privateca_v1.types import service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -40,27 +39,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class CertificateAuthorityServiceTransport(abc.ABC): """Abstract transport class for CertificateAuthorityService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "privateca.googleapis.com" + def __init__( self, *, - host: str = "privateca.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + 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 @@ -69,7 +82,7 @@ def __init__( 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. - scope (Optional[Sequence[str]]): A list of scopes. + 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): @@ -83,29 +96,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -242,29 +302,29 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_certificate( self, - ) -> typing.Callable[ + ) -> Callable[ [service.CreateCertificateRequest], - typing.Union[resources.Certificate, typing.Awaitable[resources.Certificate]], + Union[resources.Certificate, Awaitable[resources.Certificate]], ]: raise NotImplementedError() @property def get_certificate( self, - ) -> typing.Callable[ + ) -> Callable[ [service.GetCertificateRequest], - typing.Union[resources.Certificate, typing.Awaitable[resources.Certificate]], + Union[resources.Certificate, Awaitable[resources.Certificate]], ]: raise NotImplementedError() @property def list_certificates( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ListCertificatesRequest], - typing.Union[ + Union[ service.ListCertificatesResponse, - typing.Awaitable[service.ListCertificatesResponse], + Awaitable[service.ListCertificatesResponse], ], ]: raise NotImplementedError() @@ -272,65 +332,65 @@ def list_certificates( @property def revoke_certificate( self, - ) -> typing.Callable[ + ) -> Callable[ [service.RevokeCertificateRequest], - typing.Union[resources.Certificate, typing.Awaitable[resources.Certificate]], + Union[resources.Certificate, Awaitable[resources.Certificate]], ]: raise NotImplementedError() @property def update_certificate( self, - ) -> typing.Callable[ + ) -> Callable[ [service.UpdateCertificateRequest], - typing.Union[resources.Certificate, typing.Awaitable[resources.Certificate]], + Union[resources.Certificate, Awaitable[resources.Certificate]], ]: raise NotImplementedError() @property def activate_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ActivateCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def create_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.CreateCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def disable_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.DisableCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def enable_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.EnableCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def fetch_certificate_authority_csr( self, - ) -> typing.Callable[ + ) -> Callable[ [service.FetchCertificateAuthorityCsrRequest], - typing.Union[ + Union[ service.FetchCertificateAuthorityCsrResponse, - typing.Awaitable[service.FetchCertificateAuthorityCsrResponse], + Awaitable[service.FetchCertificateAuthorityCsrResponse], ], ]: raise NotImplementedError() @@ -338,11 +398,10 @@ def fetch_certificate_authority_csr( @property def get_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.GetCertificateAuthorityRequest], - typing.Union[ - resources.CertificateAuthority, - typing.Awaitable[resources.CertificateAuthority], + Union[ + resources.CertificateAuthority, Awaitable[resources.CertificateAuthority] ], ]: raise NotImplementedError() @@ -350,11 +409,11 @@ def get_certificate_authority( @property def list_certificate_authorities( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ListCertificateAuthoritiesRequest], - typing.Union[ + Union[ service.ListCertificateAuthoritiesResponse, - typing.Awaitable[service.ListCertificateAuthoritiesResponse], + Awaitable[service.ListCertificateAuthoritiesResponse], ], ]: raise NotImplementedError() @@ -362,96 +421,91 @@ def list_certificate_authorities( @property def undelete_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.UndeleteCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def delete_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.DeleteCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def update_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.UpdateCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def create_ca_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [service.CreateCaPoolRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def update_ca_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [service.UpdateCaPoolRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_ca_pool( self, - ) -> typing.Callable[ - [service.GetCaPoolRequest], - typing.Union[resources.CaPool, typing.Awaitable[resources.CaPool]], + ) -> Callable[ + [service.GetCaPoolRequest], Union[resources.CaPool, Awaitable[resources.CaPool]] ]: raise NotImplementedError() @property def list_ca_pools( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ListCaPoolsRequest], - typing.Union[ - service.ListCaPoolsResponse, typing.Awaitable[service.ListCaPoolsResponse] - ], + Union[service.ListCaPoolsResponse, Awaitable[service.ListCaPoolsResponse]], ]: raise NotImplementedError() @property def delete_ca_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [service.DeleteCaPoolRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def fetch_ca_certs( self, - ) -> typing.Callable[ + ) -> Callable[ [service.FetchCaCertsRequest], - typing.Union[ - service.FetchCaCertsResponse, typing.Awaitable[service.FetchCaCertsResponse] - ], + Union[service.FetchCaCertsResponse, Awaitable[service.FetchCaCertsResponse]], ]: raise NotImplementedError() @property def get_certificate_revocation_list( self, - ) -> typing.Callable[ + ) -> Callable[ [service.GetCertificateRevocationListRequest], - typing.Union[ + Union[ resources.CertificateRevocationList, - typing.Awaitable[resources.CertificateRevocationList], + Awaitable[resources.CertificateRevocationList], ], ]: raise NotImplementedError() @@ -459,11 +513,11 @@ def get_certificate_revocation_list( @property def list_certificate_revocation_lists( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ListCertificateRevocationListsRequest], - typing.Union[ + Union[ service.ListCertificateRevocationListsResponse, - typing.Awaitable[service.ListCertificateRevocationListsResponse], + Awaitable[service.ListCertificateRevocationListsResponse], ], ]: raise NotImplementedError() @@ -471,50 +525,47 @@ def list_certificate_revocation_lists( @property def update_certificate_revocation_list( self, - ) -> typing.Callable[ + ) -> Callable[ [service.UpdateCertificateRevocationListRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def create_certificate_template( self, - ) -> typing.Callable[ + ) -> Callable[ [service.CreateCertificateTemplateRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def delete_certificate_template( self, - ) -> typing.Callable[ + ) -> Callable[ [service.DeleteCertificateTemplateRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_certificate_template( self, - ) -> typing.Callable[ + ) -> Callable[ [service.GetCertificateTemplateRequest], - typing.Union[ - resources.CertificateTemplate, - typing.Awaitable[resources.CertificateTemplate], - ], + Union[resources.CertificateTemplate, Awaitable[resources.CertificateTemplate]], ]: raise NotImplementedError() @property def list_certificate_templates( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ListCertificateTemplatesRequest], - typing.Union[ + Union[ service.ListCertificateTemplatesResponse, - typing.Awaitable[service.ListCertificateTemplatesResponse], + Awaitable[service.ListCertificateTemplatesResponse], ], ]: raise NotImplementedError() @@ -522,9 +573,9 @@ def list_certificate_templates( @property def update_certificate_template( self, - ) -> typing.Callable[ + ) -> Callable[ [service.UpdateCertificateTemplateRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() diff --git a/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py b/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py index b03498e..68885f4 100644 --- a/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py +++ b/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.security.privateca_v1.types import resources from google.cloud.security.privateca_v1.types import service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO @@ -55,7 +52,7 @@ def __init__( self, *, host: str = "privateca.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -69,7 +66,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + 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 @@ -180,7 +178,7 @@ def __init__( def create_channel( cls, host: str = "privateca.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -211,13 +209,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -384,7 +384,9 @@ def update_certificate( @property def activate_certificate_authority( self, - ) -> Callable[[service.ActivateCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.ActivateCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the activate certificate authority method over gRPC. Activate a @@ -414,14 +416,16 @@ def activate_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ActivateCertificateAuthority", request_serializer=service.ActivateCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["activate_certificate_authority"] @property def create_certificate_authority( self, - ) -> Callable[[service.CreateCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.CreateCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the create certificate authority method over gRPC. Create a new @@ -442,14 +446,16 @@ def create_certificate_authority( self._stubs["create_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateAuthority", request_serializer=service.CreateCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_certificate_authority"] @property def disable_certificate_authority( self, - ) -> Callable[[service.DisableCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.DisableCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the disable certificate authority method over gRPC. Disable a @@ -471,14 +477,16 @@ def disable_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DisableCertificateAuthority", request_serializer=service.DisableCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["disable_certificate_authority"] @property def enable_certificate_authority( self, - ) -> Callable[[service.EnableCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.EnableCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the enable certificate authority method over gRPC. Enable a @@ -498,7 +506,7 @@ def enable_certificate_authority( self._stubs["enable_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/EnableCertificateAuthority", request_serializer=service.EnableCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["enable_certificate_authority"] @@ -606,7 +614,9 @@ def list_certificate_authorities( @property def undelete_certificate_authority( self, - ) -> Callable[[service.UndeleteCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.UndeleteCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the undelete certificate authority method over gRPC. Undelete a @@ -629,14 +639,16 @@ def undelete_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UndeleteCertificateAuthority", request_serializer=service.UndeleteCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["undelete_certificate_authority"] @property def delete_certificate_authority( self, - ) -> Callable[[service.DeleteCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.DeleteCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the delete certificate authority method over gRPC. Delete a @@ -656,14 +668,16 @@ def delete_certificate_authority( self._stubs["delete_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateAuthority", request_serializer=service.DeleteCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_certificate_authority"] @property def update_certificate_authority( self, - ) -> Callable[[service.UpdateCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.UpdateCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the update certificate authority method over gRPC. Update a @@ -683,14 +697,14 @@ def update_certificate_authority( self._stubs["update_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateAuthority", request_serializer=service.UpdateCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_certificate_authority"] @property def create_ca_pool( self, - ) -> Callable[[service.CreateCaPoolRequest], operations.Operation]: + ) -> Callable[[service.CreateCaPoolRequest], operations_pb2.Operation]: r"""Return a callable for the create ca pool method over gRPC. Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -709,14 +723,14 @@ def create_ca_pool( self._stubs["create_ca_pool"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCaPool", request_serializer=service.CreateCaPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_ca_pool"] @property def update_ca_pool( self, - ) -> Callable[[service.UpdateCaPoolRequest], operations.Operation]: + ) -> Callable[[service.UpdateCaPoolRequest], operations_pb2.Operation]: r"""Return a callable for the update ca pool method over gRPC. Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -735,7 +749,7 @@ def update_ca_pool( self._stubs["update_ca_pool"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCaPool", request_serializer=service.UpdateCaPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_ca_pool"] @@ -792,7 +806,7 @@ def list_ca_pools( @property def delete_ca_pool( self, - ) -> Callable[[service.DeleteCaPoolRequest], operations.Operation]: + ) -> Callable[[service.DeleteCaPoolRequest], operations_pb2.Operation]: r"""Return a callable for the delete ca pool method over gRPC. Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -811,7 +825,7 @@ def delete_ca_pool( self._stubs["delete_ca_pool"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCaPool", request_serializer=service.DeleteCaPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_ca_pool"] @@ -916,7 +930,7 @@ def list_certificate_revocation_lists( def update_certificate_revocation_list( self, ) -> Callable[ - [service.UpdateCertificateRevocationListRequest], operations.Operation + [service.UpdateCertificateRevocationListRequest], operations_pb2.Operation ]: r"""Return a callable for the update certificate revocation list method over gRPC. @@ -940,14 +954,14 @@ def update_certificate_revocation_list( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateRevocationList", request_serializer=service.UpdateCertificateRevocationListRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_certificate_revocation_list"] @property def create_certificate_template( self, - ) -> Callable[[service.CreateCertificateTemplateRequest], operations.Operation]: + ) -> Callable[[service.CreateCertificateTemplateRequest], operations_pb2.Operation]: r"""Return a callable for the create certificate template method over gRPC. Create a new @@ -968,14 +982,14 @@ def create_certificate_template( self._stubs["create_certificate_template"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateTemplate", request_serializer=service.CreateCertificateTemplateRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_certificate_template"] @property def delete_certificate_template( self, - ) -> Callable[[service.DeleteCertificateTemplateRequest], operations.Operation]: + ) -> Callable[[service.DeleteCertificateTemplateRequest], operations_pb2.Operation]: r"""Return a callable for the delete certificate template method over gRPC. DeleteCertificateTemplate deletes a @@ -995,7 +1009,7 @@ def delete_certificate_template( self._stubs["delete_certificate_template"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateTemplate", request_serializer=service.DeleteCertificateTemplateRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_certificate_template"] @@ -1061,7 +1075,7 @@ def list_certificate_templates( @property def update_certificate_template( self, - ) -> Callable[[service.UpdateCertificateTemplateRequest], operations.Operation]: + ) -> Callable[[service.UpdateCertificateTemplateRequest], operations_pb2.Operation]: r"""Return a callable for the update certificate template method over gRPC. Update a @@ -1081,7 +1095,7 @@ def update_certificate_template( self._stubs["update_certificate_template"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateTemplate", request_serializer=service.UpdateCertificateTemplateRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_certificate_template"] diff --git a/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py b/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py index e64a0bd..738f641 100644 --- a/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py +++ b/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,24 +13,22 @@ # 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 +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.security.privateca_v1.types import resources from google.cloud.security.privateca_v1.types import service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO from .grpc import CertificateAuthorityServiceGrpcTransport @@ -60,7 +57,7 @@ class CertificateAuthorityServiceGrpcAsyncIOTransport( def create_channel( cls, host: str = "privateca.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -87,13 +84,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -101,7 +100,7 @@ def __init__( self, *, host: str = "privateca.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -115,7 +114,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + 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 @@ -174,7 +174,6 @@ def __init__( # 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 @@ -395,7 +394,8 @@ def update_certificate( def activate_certificate_authority( self, ) -> Callable[ - [service.ActivateCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.ActivateCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the activate certificate authority method over gRPC. @@ -426,7 +426,7 @@ def activate_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/ActivateCertificateAuthority", request_serializer=service.ActivateCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["activate_certificate_authority"] @@ -434,7 +434,7 @@ def activate_certificate_authority( def create_certificate_authority( self, ) -> Callable[ - [service.CreateCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.CreateCertificateAuthorityRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the create certificate authority method over gRPC. @@ -456,7 +456,7 @@ def create_certificate_authority( self._stubs["create_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateAuthority", request_serializer=service.CreateCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_certificate_authority"] @@ -464,7 +464,8 @@ def create_certificate_authority( def disable_certificate_authority( self, ) -> Callable[ - [service.DisableCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.DisableCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the disable certificate authority method over gRPC. @@ -487,7 +488,7 @@ def disable_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DisableCertificateAuthority", request_serializer=service.DisableCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["disable_certificate_authority"] @@ -495,7 +496,7 @@ def disable_certificate_authority( def enable_certificate_authority( self, ) -> Callable[ - [service.EnableCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.EnableCertificateAuthorityRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the enable certificate authority method over gRPC. @@ -516,7 +517,7 @@ def enable_certificate_authority( self._stubs["enable_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/EnableCertificateAuthority", request_serializer=service.EnableCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["enable_certificate_authority"] @@ -626,7 +627,8 @@ def list_certificate_authorities( def undelete_certificate_authority( self, ) -> Callable[ - [service.UndeleteCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.UndeleteCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the undelete certificate authority method over gRPC. @@ -650,7 +652,7 @@ def undelete_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UndeleteCertificateAuthority", request_serializer=service.UndeleteCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["undelete_certificate_authority"] @@ -658,7 +660,7 @@ def undelete_certificate_authority( def delete_certificate_authority( self, ) -> Callable[ - [service.DeleteCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.DeleteCertificateAuthorityRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete certificate authority method over gRPC. @@ -679,7 +681,7 @@ def delete_certificate_authority( self._stubs["delete_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateAuthority", request_serializer=service.DeleteCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_certificate_authority"] @@ -687,7 +689,7 @@ def delete_certificate_authority( def update_certificate_authority( self, ) -> Callable[ - [service.UpdateCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.UpdateCertificateAuthorityRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the update certificate authority method over gRPC. @@ -708,14 +710,14 @@ def update_certificate_authority( self._stubs["update_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateAuthority", request_serializer=service.UpdateCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_certificate_authority"] @property def create_ca_pool( self, - ) -> Callable[[service.CreateCaPoolRequest], Awaitable[operations.Operation]]: + ) -> Callable[[service.CreateCaPoolRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the create ca pool method over gRPC. Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -734,14 +736,14 @@ def create_ca_pool( self._stubs["create_ca_pool"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCaPool", request_serializer=service.CreateCaPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_ca_pool"] @property def update_ca_pool( self, - ) -> Callable[[service.UpdateCaPoolRequest], Awaitable[operations.Operation]]: + ) -> Callable[[service.UpdateCaPoolRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the update ca pool method over gRPC. Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -760,7 +762,7 @@ def update_ca_pool( self._stubs["update_ca_pool"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCaPool", request_serializer=service.UpdateCaPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_ca_pool"] @@ -819,7 +821,7 @@ def list_ca_pools( @property def delete_ca_pool( self, - ) -> Callable[[service.DeleteCaPoolRequest], Awaitable[operations.Operation]]: + ) -> Callable[[service.DeleteCaPoolRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the delete ca pool method over gRPC. Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. @@ -838,7 +840,7 @@ def delete_ca_pool( self._stubs["delete_ca_pool"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCaPool", request_serializer=service.DeleteCaPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_ca_pool"] @@ -946,7 +948,7 @@ def update_certificate_revocation_list( self, ) -> Callable[ [service.UpdateCertificateRevocationListRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the update certificate revocation list method over gRPC. @@ -970,7 +972,7 @@ def update_certificate_revocation_list( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateRevocationList", request_serializer=service.UpdateCertificateRevocationListRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_certificate_revocation_list"] @@ -978,7 +980,7 @@ def update_certificate_revocation_list( def create_certificate_template( self, ) -> Callable[ - [service.CreateCertificateTemplateRequest], Awaitable[operations.Operation] + [service.CreateCertificateTemplateRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the create certificate template method over gRPC. @@ -1000,7 +1002,7 @@ def create_certificate_template( self._stubs["create_certificate_template"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateTemplate", request_serializer=service.CreateCertificateTemplateRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_certificate_template"] @@ -1008,7 +1010,7 @@ def create_certificate_template( def delete_certificate_template( self, ) -> Callable[ - [service.DeleteCertificateTemplateRequest], Awaitable[operations.Operation] + [service.DeleteCertificateTemplateRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete certificate template method over gRPC. @@ -1029,7 +1031,7 @@ def delete_certificate_template( self._stubs["delete_certificate_template"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateTemplate", request_serializer=service.DeleteCertificateTemplateRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_certificate_template"] @@ -1097,7 +1099,7 @@ def list_certificate_templates( def update_certificate_template( self, ) -> Callable[ - [service.UpdateCertificateTemplateRequest], Awaitable[operations.Operation] + [service.UpdateCertificateTemplateRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the update certificate template method over gRPC. @@ -1118,7 +1120,7 @@ def update_certificate_template( self._stubs["update_certificate_template"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateTemplate", request_serializer=service.UpdateCertificateTemplateRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_certificate_template"] diff --git a/google/cloud/security/privateca_v1/types/__init__.py b/google/cloud/security/privateca_v1/types/__init__.py index e0743d1..331d6fb 100644 --- a/google/cloud/security/privateca_v1/types/__init__.py +++ b/google/cloud/security/privateca_v1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .resources import ( CaPool, Certificate, diff --git a/google/cloud/security/privateca_v1/types/resources.py b/google/cloud/security/privateca_v1/types/resources.py index 3852320..677600a 100644 --- a/google/cloud/security/privateca_v1/types/resources.py +++ b/google/cloud/security/privateca_v1/types/resources.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.type import expr_pb2 as expr # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import expr_pb2 # type: ignore __protobuf__ = proto.module( @@ -246,9 +243,8 @@ class AccessUrls(proto.Message): been activated. """ - ca_certificate_access_url = proto.Field(proto.STRING, number=1) - - crl_access_urls = proto.RepeatedField(proto.STRING, number=2) + ca_certificate_access_url = proto.Field(proto.STRING, number=1,) + crl_access_urls = proto.RepeatedField(proto.STRING, number=2,) class KeyVersionSpec(proto.Message): r"""A Cloud KMS key configuration that a @@ -270,8 +266,7 @@ class KeyVersionSpec(proto.Message): ``HSM``. """ - cloud_kms_key_version = proto.Field(proto.STRING, number=1, oneof="KeyVersion") - + cloud_kms_key_version = proto.Field(proto.STRING, number=1, oneof="KeyVersion",) algorithm = proto.Field( proto.ENUM, number=2, @@ -279,43 +274,35 @@ class KeyVersionSpec(proto.Message): enum="CertificateAuthority.SignHashAlgorithm", ) - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) type_ = proto.Field(proto.ENUM, number=2, enum=Type,) - config = proto.Field(proto.MESSAGE, number=3, message="CertificateConfig",) - - lifetime = proto.Field(proto.MESSAGE, number=4, message=duration.Duration,) - + lifetime = proto.Field(proto.MESSAGE, number=4, message=duration_pb2.Duration,) key_spec = proto.Field(proto.MESSAGE, number=5, message=KeyVersionSpec,) - subordinate_config = proto.Field( proto.MESSAGE, number=6, message="SubordinateConfig", ) - tier = proto.Field(proto.ENUM, number=7, enum="CaPool.Tier",) - state = proto.Field(proto.ENUM, number=8, enum=State,) - - pem_ca_certificates = proto.RepeatedField(proto.STRING, number=9) - + pem_ca_certificates = proto.RepeatedField(proto.STRING, number=9,) ca_certificate_descriptions = proto.RepeatedField( proto.MESSAGE, number=10, message="CertificateDescription", ) - - gcs_bucket = proto.Field(proto.STRING, number=11) - + gcs_bucket = proto.Field(proto.STRING, number=11,) access_urls = proto.Field(proto.MESSAGE, number=12, message=AccessUrls,) - - create_time = proto.Field(proto.MESSAGE, number=13, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=14, message=timestamp.Timestamp,) - - delete_time = proto.Field(proto.MESSAGE, number=15, message=timestamp.Timestamp,) - - expire_time = proto.Field(proto.MESSAGE, number=16, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=17) + create_time = proto.Field( + proto.MESSAGE, number=13, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=14, message=timestamp_pb2.Timestamp, + ) + delete_time = proto.Field( + proto.MESSAGE, number=15, message=timestamp_pb2.Timestamp, + ) + expire_time = proto.Field( + proto.MESSAGE, number=16, message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField(proto.STRING, proto.STRING, number=17,) class CaPool(proto.Message): @@ -397,9 +384,8 @@ class PublishingOptions(proto.Message): shortly after a certificate is revoked. """ - publish_ca_cert = proto.Field(proto.BOOL, number=1) - - publish_crl = proto.Field(proto.BOOL, number=2) + publish_ca_cert = proto.Field(proto.BOOL, number=1,) + publish_crl = proto.Field(proto.BOOL, number=2,) class IssuancePolicy(proto.Message): r"""Defines controls over all certificate issuance within a @@ -504,9 +490,8 @@ class RsaKeyType(proto.Message): upper bound on RSA modulus sizes. """ - min_modulus_size = proto.Field(proto.INT64, number=1) - - max_modulus_size = proto.Field(proto.INT64, number=2) + min_modulus_size = proto.Field(proto.INT64, number=1,) + max_modulus_size = proto.Field(proto.INT64, number=2,) class EcKeyType(proto.Message): r"""Describes an Elliptic Curve key that may be used in a @@ -543,7 +528,6 @@ class EcSignatureAlgorithm(proto.Enum): oneof="key_type", message="CaPool.IssuancePolicy.AllowedKeyType.RsaKeyType", ) - elliptic_curve = proto.Field( proto.MESSAGE, number=2, @@ -570,45 +554,35 @@ class IssuanceModes(proto.Message): [CertificateConfig][google.cloud.security.privateca.v1.CertificateConfig]. """ - allow_csr_based_issuance = proto.Field(proto.BOOL, number=1) - - allow_config_based_issuance = proto.Field(proto.BOOL, number=2) + allow_csr_based_issuance = proto.Field(proto.BOOL, number=1,) + allow_config_based_issuance = proto.Field(proto.BOOL, number=2,) allowed_key_types = proto.RepeatedField( proto.MESSAGE, number=1, message="CaPool.IssuancePolicy.AllowedKeyType", ) - maximum_lifetime = proto.Field( - proto.MESSAGE, number=2, message=duration.Duration, + proto.MESSAGE, number=2, message=duration_pb2.Duration, ) - allowed_issuance_modes = proto.Field( proto.MESSAGE, number=3, message="CaPool.IssuancePolicy.IssuanceModes", ) - baseline_values = proto.Field( proto.MESSAGE, number=4, message="X509Parameters", ) - identity_constraints = proto.Field( proto.MESSAGE, number=5, message="CertificateIdentityConstraints", ) - passthrough_extensions = proto.Field( proto.MESSAGE, number=6, message="CertificateExtensionConstraints", ) - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) tier = proto.Field(proto.ENUM, number=2, enum=Tier,) - issuance_policy = proto.Field(proto.MESSAGE, number=3, message=IssuancePolicy,) - publishing_options = proto.Field( proto.MESSAGE, number=4, message=PublishingOptions, ) - - labels = proto.MapField(proto.STRING, proto.STRING, number=5) + labels = proto.MapField(proto.STRING, proto.STRING, number=5,) class CertificateRevocationList(proto.Message): @@ -684,33 +658,22 @@ class RevokedCertificate(proto.Message): was revoked. """ - certificate = proto.Field(proto.STRING, number=1) - - hex_serial_number = proto.Field(proto.STRING, number=2) - + certificate = proto.Field(proto.STRING, number=1,) + hex_serial_number = proto.Field(proto.STRING, number=2,) revocation_reason = proto.Field(proto.ENUM, number=3, enum="RevocationReason",) - name = proto.Field(proto.STRING, number=1) - - sequence_number = proto.Field(proto.INT64, number=2) - + name = proto.Field(proto.STRING, number=1,) + sequence_number = proto.Field(proto.INT64, number=2,) revoked_certificates = proto.RepeatedField( proto.MESSAGE, number=3, message=RevokedCertificate, ) - - pem_crl = proto.Field(proto.STRING, number=4) - - access_url = proto.Field(proto.STRING, number=5) - + pem_crl = proto.Field(proto.STRING, number=4,) + access_url = proto.Field(proto.STRING, number=5,) state = proto.Field(proto.ENUM, number=6, enum=State,) - - create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - - revision_id = proto.Field(proto.STRING, number=9) - - labels = proto.MapField(proto.STRING, proto.STRING, number=10) + create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + revision_id = proto.Field(proto.STRING, number=9,) + labels = proto.MapField(proto.STRING, proto.STRING, number=10,) class Certificate(proto.Message): @@ -799,47 +762,37 @@ class RevocationDetails(proto.Message): """ revocation_state = proto.Field(proto.ENUM, number=1, enum="RevocationReason",) - revocation_time = proto.Field( - proto.MESSAGE, number=2, message=timestamp.Timestamp, + proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, ) - name = proto.Field(proto.STRING, number=1) - - pem_csr = proto.Field(proto.STRING, number=2, oneof="certificate_config") - + name = proto.Field(proto.STRING, number=1,) + pem_csr = proto.Field(proto.STRING, number=2, oneof="certificate_config",) config = proto.Field( proto.MESSAGE, number=3, oneof="certificate_config", message="CertificateConfig", ) - - issuer_certificate_authority = proto.Field(proto.STRING, number=4) - - lifetime = proto.Field(proto.MESSAGE, number=5, message=duration.Duration,) - - certificate_template = proto.Field(proto.STRING, number=6) - + issuer_certificate_authority = proto.Field(proto.STRING, number=4,) + lifetime = proto.Field(proto.MESSAGE, number=5, message=duration_pb2.Duration,) + certificate_template = proto.Field(proto.STRING, number=6,) subject_mode = proto.Field(proto.ENUM, number=7, enum="SubjectRequestMode",) - revocation_details = proto.Field( proto.MESSAGE, number=8, message=RevocationDetails, ) - - pem_certificate = proto.Field(proto.STRING, number=9) - + pem_certificate = proto.Field(proto.STRING, number=9,) certificate_description = proto.Field( proto.MESSAGE, number=10, message="CertificateDescription", ) - - pem_certificate_chain = proto.RepeatedField(proto.STRING, number=11) - - create_time = proto.Field(proto.MESSAGE, number=12, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=13, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=14) + pem_certificate_chain = proto.RepeatedField(proto.STRING, number=11,) + create_time = proto.Field( + proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=13, message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField(proto.STRING, proto.STRING, number=14,) class CertificateTemplate(proto.Message): @@ -907,25 +860,18 @@ class CertificateTemplate(proto.Message): Optional. Labels with user-defined metadata. """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) predefined_values = proto.Field(proto.MESSAGE, number=2, message="X509Parameters",) - identity_constraints = proto.Field( proto.MESSAGE, number=3, message="CertificateIdentityConstraints", ) - passthrough_extensions = proto.Field( proto.MESSAGE, number=4, message="CertificateExtensionConstraints", ) - - description = proto.Field(proto.STRING, number=5) - - create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=8) + description = proto.Field(proto.STRING, number=5,) + create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=8,) class X509Parameters(proto.Message): @@ -958,7 +904,6 @@ class X509Parameters(proto.Message): class CaOptions(proto.Message): r"""Describes values that are relevant in a CA certificate. - Attributes: is_ca (bool): Optional. Refers to the "CA" X.509 extension, @@ -975,18 +920,13 @@ class CaOptions(proto.Message): length will be omitted from the CA certificate. """ - is_ca = proto.Field(proto.BOOL, number=1, optional=True) - - max_issuer_path_length = proto.Field(proto.INT32, number=2, optional=True) + is_ca = proto.Field(proto.BOOL, number=1, optional=True,) + max_issuer_path_length = proto.Field(proto.INT32, number=2, optional=True,) key_usage = proto.Field(proto.MESSAGE, number=1, message="KeyUsage",) - ca_options = proto.Field(proto.MESSAGE, number=2, message=CaOptions,) - policy_ids = proto.RepeatedField(proto.MESSAGE, number=3, message="ObjectId",) - - aia_ocsp_servers = proto.RepeatedField(proto.STRING, number=4) - + aia_ocsp_servers = proto.RepeatedField(proto.STRING, number=4,) additional_extensions = proto.RepeatedField( proto.MESSAGE, number=5, message="X509Extension", ) @@ -1024,12 +964,11 @@ class SubordinateConfigChain(proto.Message): order according to RFC 5246. """ - pem_certificates = proto.RepeatedField(proto.STRING, number=1) + pem_certificates = proto.RepeatedField(proto.STRING, number=1,) certificate_authority = proto.Field( - proto.STRING, number=1, oneof="subordinate_config" + proto.STRING, number=1, oneof="subordinate_config", ) - pem_issuer_chain = proto.Field( proto.MESSAGE, number=2, @@ -1058,8 +997,7 @@ class KeyFormat(proto.Enum): KEY_FORMAT_UNSPECIFIED = 0 PEM = 1 - key = proto.Field(proto.BYTES, number=1) - + key = proto.Field(proto.BYTES, number=1,) format_ = proto.Field(proto.ENUM, number=2, enum=KeyFormat,) @@ -1103,15 +1041,12 @@ class SubjectConfig(proto.Message): """ subject = proto.Field(proto.MESSAGE, number=1, message="Subject",) - subject_alt_name = proto.Field( proto.MESSAGE, number=2, message="SubjectAltNames", ) subject_config = proto.Field(proto.MESSAGE, number=1, message=SubjectConfig,) - x509_config = proto.Field(proto.MESSAGE, number=2, message="X509Parameters",) - public_key = proto.Field(proto.MESSAGE, number=3, message="PublicKey",) @@ -1177,21 +1112,16 @@ class SubjectDescription(proto.Message): """ subject = proto.Field(proto.MESSAGE, number=1, message="Subject",) - subject_alt_name = proto.Field( proto.MESSAGE, number=2, message="SubjectAltNames", ) - - hex_serial_number = proto.Field(proto.STRING, number=3) - - lifetime = proto.Field(proto.MESSAGE, number=4, message=duration.Duration,) - + hex_serial_number = proto.Field(proto.STRING, number=3,) + lifetime = proto.Field(proto.MESSAGE, number=4, message=duration_pb2.Duration,) not_before_time = proto.Field( - proto.MESSAGE, number=5, message=timestamp.Timestamp, + proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp, ) - not_after_time = proto.Field( - proto.MESSAGE, number=6, message=timestamp.Timestamp, + proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp, ) class KeyId(proto.Message): @@ -1205,35 +1135,27 @@ class KeyId(proto.Message): 160 bit SHA-1 hash of the public key. """ - key_id = proto.Field(proto.STRING, number=1) + key_id = proto.Field(proto.STRING, number=1,) class CertificateFingerprint(proto.Message): r"""A group of fingerprints for the x509 certificate. - Attributes: sha256_hash (str): The SHA 256 hash, encoded in hexadecimal, of the DER x509 certificate. """ - sha256_hash = proto.Field(proto.STRING, number=1) + sha256_hash = proto.Field(proto.STRING, number=1,) subject_description = proto.Field( proto.MESSAGE, number=1, message=SubjectDescription, ) - x509_description = proto.Field(proto.MESSAGE, number=2, message="X509Parameters",) - public_key = proto.Field(proto.MESSAGE, number=3, message="PublicKey",) - subject_key_id = proto.Field(proto.MESSAGE, number=4, message=KeyId,) - authority_key_id = proto.Field(proto.MESSAGE, number=5, message=KeyId,) - - crl_distribution_points = proto.RepeatedField(proto.STRING, number=6) - - aia_issuing_certificate_urls = proto.RepeatedField(proto.STRING, number=7) - + crl_distribution_points = proto.RepeatedField(proto.STRING, number=6,) + aia_issuing_certificate_urls = proto.RepeatedField(proto.STRING, number=7,) cert_fingerprint = proto.Field( proto.MESSAGE, number=8, message=CertificateFingerprint, ) @@ -1250,7 +1172,7 @@ class ObjectId(proto.Message): significant parts of the path come first. """ - object_id_path = proto.RepeatedField(proto.INT32, number=1) + object_id_path = proto.RepeatedField(proto.INT32, number=1,) class X509Extension(proto.Message): @@ -1271,10 +1193,8 @@ class X509Extension(proto.Message): """ object_id = proto.Field(proto.MESSAGE, number=1, message="ObjectId",) - - critical = proto.Field(proto.BOOL, number=2) - - value = proto.Field(proto.BYTES, number=3) + critical = proto.Field(proto.BOOL, number=2,) + value = proto.Field(proto.BYTES, number=3,) class KeyUsage(proto.Message): @@ -1325,23 +1245,15 @@ class KeyUsageOptions(proto.Message): The key may be used to decipher only. """ - digital_signature = proto.Field(proto.BOOL, number=1) - - content_commitment = proto.Field(proto.BOOL, number=2) - - key_encipherment = proto.Field(proto.BOOL, number=3) - - data_encipherment = proto.Field(proto.BOOL, number=4) - - key_agreement = proto.Field(proto.BOOL, number=5) - - cert_sign = proto.Field(proto.BOOL, number=6) - - crl_sign = proto.Field(proto.BOOL, number=7) - - encipher_only = proto.Field(proto.BOOL, number=8) - - decipher_only = proto.Field(proto.BOOL, number=9) + digital_signature = proto.Field(proto.BOOL, number=1,) + content_commitment = proto.Field(proto.BOOL, number=2,) + key_encipherment = proto.Field(proto.BOOL, number=3,) + data_encipherment = proto.Field(proto.BOOL, number=4,) + key_agreement = proto.Field(proto.BOOL, number=5,) + cert_sign = proto.Field(proto.BOOL, number=6,) + crl_sign = proto.Field(proto.BOOL, number=7,) + encipher_only = proto.Field(proto.BOOL, number=8,) + decipher_only = proto.Field(proto.BOOL, number=9,) class ExtendedKeyUsageOptions(proto.Message): r"""[KeyUsage.ExtendedKeyUsageOptions][google.cloud.security.privateca.v1.KeyUsage.ExtendedKeyUsageOptions] @@ -1376,24 +1288,17 @@ class ExtendedKeyUsageOptions(proto.Message): responses". """ - server_auth = proto.Field(proto.BOOL, number=1) - - client_auth = proto.Field(proto.BOOL, number=2) - - code_signing = proto.Field(proto.BOOL, number=3) - - email_protection = proto.Field(proto.BOOL, number=4) - - time_stamping = proto.Field(proto.BOOL, number=5) - - ocsp_signing = proto.Field(proto.BOOL, number=6) + server_auth = proto.Field(proto.BOOL, number=1,) + client_auth = proto.Field(proto.BOOL, number=2,) + code_signing = proto.Field(proto.BOOL, number=3,) + email_protection = proto.Field(proto.BOOL, number=4,) + time_stamping = proto.Field(proto.BOOL, number=5,) + ocsp_signing = proto.Field(proto.BOOL, number=6,) base_key_usage = proto.Field(proto.MESSAGE, number=1, message=KeyUsageOptions,) - extended_key_usage = proto.Field( proto.MESSAGE, number=2, message=ExtendedKeyUsageOptions, ) - unknown_extended_key_usages = proto.RepeatedField( proto.MESSAGE, number=3, message="ObjectId", ) @@ -1424,21 +1329,14 @@ class Subject(proto.Message): The postal code of the subject. """ - common_name = proto.Field(proto.STRING, number=1) - - country_code = proto.Field(proto.STRING, number=2) - - organization = proto.Field(proto.STRING, number=3) - - organizational_unit = proto.Field(proto.STRING, number=4) - - locality = proto.Field(proto.STRING, number=5) - - province = proto.Field(proto.STRING, number=6) - - street_address = proto.Field(proto.STRING, number=7) - - postal_code = proto.Field(proto.STRING, number=8) + common_name = proto.Field(proto.STRING, number=1,) + country_code = proto.Field(proto.STRING, number=2,) + organization = proto.Field(proto.STRING, number=3,) + organizational_unit = proto.Field(proto.STRING, number=4,) + locality = proto.Field(proto.STRING, number=5,) + province = proto.Field(proto.STRING, number=6,) + street_address = proto.Field(proto.STRING, number=7,) + postal_code = proto.Field(proto.STRING, number=8,) class SubjectAltNames(proto.Message): @@ -1464,14 +1362,10 @@ class SubjectAltNames(proto.Message): values. """ - dns_names = proto.RepeatedField(proto.STRING, number=1) - - uris = proto.RepeatedField(proto.STRING, number=2) - - email_addresses = proto.RepeatedField(proto.STRING, number=3) - - ip_addresses = proto.RepeatedField(proto.STRING, number=4) - + dns_names = proto.RepeatedField(proto.STRING, number=1,) + uris = proto.RepeatedField(proto.STRING, number=2,) + email_addresses = proto.RepeatedField(proto.STRING, number=3,) + ip_addresses = proto.RepeatedField(proto.STRING, number=4,) custom_sans = proto.RepeatedField(proto.MESSAGE, number=5, message="X509Extension",) @@ -1491,26 +1385,30 @@ class CertificateIdentityConstraints(proto.Message): https://cloud.google.com/certificate-authority- service/docs/cel-guide allow_subject_passthrough (bool): - Optional. If this is set, the + Required. If this is true, the [Subject][google.cloud.security.privateca.v1.Subject] field may be copied from a certificate request into the signed certificate. Otherwise, the requested [Subject][google.cloud.security.privateca.v1.Subject] will - be discarded. + be discarded. The bool is optional to indicate an unset + field, which suggests a forgotten value that needs to be set + by the caller. allow_subject_alt_names_passthrough (bool): - Optional. If this is set, the + Required. If this is true, the [SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames] extension may be copied from a certificate request into the signed certificate. Otherwise, the requested [SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames] - will be discarded. + will be discarded. The bool is optional to indicate an unset + field, which suggests a forgotten value that needs to be set + by the caller. """ - cel_expression = proto.Field(proto.MESSAGE, number=1, message=expr.Expr,) - - allow_subject_passthrough = proto.Field(proto.BOOL, number=2) - - allow_subject_alt_names_passthrough = proto.Field(proto.BOOL, number=3) + cel_expression = proto.Field(proto.MESSAGE, number=1, message=expr_pb2.Expr,) + allow_subject_passthrough = proto.Field(proto.BOOL, number=2, optional=True,) + allow_subject_alt_names_passthrough = proto.Field( + proto.BOOL, number=3, optional=True, + ) class CertificateExtensionConstraints(proto.Message): @@ -1548,7 +1446,6 @@ class KnownCertificateExtension(proto.Enum): known_extensions = proto.RepeatedField( proto.ENUM, number=1, enum=KnownCertificateExtension, ) - additional_extensions = proto.RepeatedField( proto.MESSAGE, number=2, message="ObjectId", ) diff --git a/google/cloud/security/privateca_v1/types/service.py b/google/cloud/security/privateca_v1/types/service.py index ef02a01..e1c3142 100644 --- a/google/cloud/security/privateca_v1/types/service.py +++ b/google/cloud/security/privateca_v1/types/service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.security.privateca_v1.types import resources -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -145,17 +142,12 @@ class CreateCertificateRequest(proto.Message): to "my-ca". """ - parent = proto.Field(proto.STRING, number=1) - - certificate_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + certificate_id = proto.Field(proto.STRING, number=2,) certificate = proto.Field(proto.MESSAGE, number=3, message=resources.Certificate,) - - request_id = proto.Field(proto.STRING, number=4) - - validate_only = proto.Field(proto.BOOL, number=5) - - issuing_certificate_authority_id = proto.Field(proto.STRING, number=6) + request_id = proto.Field(proto.STRING, number=4,) + validate_only = proto.Field(proto.BOOL, number=5,) + issuing_certificate_authority_id = proto.Field(proto.STRING, number=6,) class GetCertificateRequest(proto.Message): @@ -171,7 +163,7 @@ class GetCertificateRequest(proto.Message): to get. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListCertificatesRequest(proto.Message): @@ -208,15 +200,11 @@ class ListCertificatesRequest(proto.Message): documentation `__. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListCertificatesResponse(proto.Message): @@ -243,10 +231,8 @@ def raw_page(self): certificates = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.Certificate, ) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable = proto.RepeatedField(proto.STRING, number=3,) class RevokeCertificateRequest(proto.Message): @@ -284,11 +270,9 @@ class RevokeCertificateRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) reason = proto.Field(proto.ENUM, number=2, enum=resources.RevocationReason,) - - request_id = proto.Field(proto.STRING, number=3) + request_id = proto.Field(proto.STRING, number=3,) class UpdateCertificateRequest(proto.Message): @@ -325,10 +309,10 @@ class UpdateCertificateRequest(proto.Message): """ certificate = proto.Field(proto.MESSAGE, number=1, message=resources.Certificate,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - request_id = proto.Field(proto.STRING, number=3) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field(proto.STRING, number=3,) class ActivateCertificateAuthorityRequest(proto.Message): @@ -369,15 +353,12 @@ class ActivateCertificateAuthorityRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - - pem_ca_certificate = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + pem_ca_certificate = proto.Field(proto.STRING, number=2,) subordinate_config = proto.Field( proto.MESSAGE, number=3, message=resources.SubordinateConfig, ) - - request_id = proto.Field(proto.STRING, number=4) + request_id = proto.Field(proto.STRING, number=4,) class CreateCertificateAuthorityRequest(proto.Message): @@ -419,15 +400,12 @@ class CreateCertificateAuthorityRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - parent = proto.Field(proto.STRING, number=1) - - certificate_authority_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + certificate_authority_id = proto.Field(proto.STRING, number=2,) certificate_authority = proto.Field( proto.MESSAGE, number=3, message=resources.CertificateAuthority, ) - - request_id = proto.Field(proto.STRING, number=4) + request_id = proto.Field(proto.STRING, number=4,) class DisableCertificateAuthorityRequest(proto.Message): @@ -461,9 +439,8 @@ class DisableCertificateAuthorityRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - - request_id = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + request_id = proto.Field(proto.STRING, number=2,) class EnableCertificateAuthorityRequest(proto.Message): @@ -497,9 +474,8 @@ class EnableCertificateAuthorityRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - - request_id = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + request_id = proto.Field(proto.STRING, number=2,) class FetchCertificateAuthorityCsrRequest(proto.Message): @@ -514,7 +490,7 @@ class FetchCertificateAuthorityCsrRequest(proto.Message): ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class FetchCertificateAuthorityCsrResponse(proto.Message): @@ -527,7 +503,7 @@ class FetchCertificateAuthorityCsrResponse(proto.Message): certificate signing request (CSR). """ - pem_csr = proto.Field(proto.STRING, number=1) + pem_csr = proto.Field(proto.STRING, number=1,) class GetCertificateAuthorityRequest(proto.Message): @@ -543,7 +519,7 @@ class GetCertificateAuthorityRequest(proto.Message): to get. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListCertificateAuthoritiesRequest(proto.Message): @@ -577,15 +553,11 @@ class ListCertificateAuthoritiesRequest(proto.Message): sorted. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListCertificateAuthoritiesResponse(proto.Message): @@ -612,10 +584,8 @@ def raw_page(self): certificate_authorities = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.CertificateAuthority, ) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable = proto.RepeatedField(proto.STRING, number=3,) class UndeleteCertificateAuthorityRequest(proto.Message): @@ -649,9 +619,8 @@ class UndeleteCertificateAuthorityRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - - request_id = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + request_id = proto.Field(proto.STRING, number=2,) class DeleteCertificateAuthorityRequest(proto.Message): @@ -690,11 +659,9 @@ class DeleteCertificateAuthorityRequest(proto.Message): certs. """ - name = proto.Field(proto.STRING, number=1) - - request_id = proto.Field(proto.STRING, number=2) - - ignore_active_certificates = proto.Field(proto.BOOL, number=4) + name = proto.Field(proto.STRING, number=1,) + request_id = proto.Field(proto.STRING, number=2,) + ignore_active_certificates = proto.Field(proto.BOOL, number=4,) class UpdateCertificateAuthorityRequest(proto.Message): @@ -733,10 +700,10 @@ class UpdateCertificateAuthorityRequest(proto.Message): certificate_authority = proto.Field( proto.MESSAGE, number=1, message=resources.CertificateAuthority, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - request_id = proto.Field(proto.STRING, number=3) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field(proto.STRING, number=3,) class CreateCaPoolRequest(proto.Message): @@ -776,13 +743,10 @@ class CreateCaPoolRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - parent = proto.Field(proto.STRING, number=1) - - ca_pool_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + ca_pool_id = proto.Field(proto.STRING, number=2,) ca_pool = proto.Field(proto.MESSAGE, number=3, message=resources.CaPool,) - - request_id = proto.Field(proto.STRING, number=4) + request_id = proto.Field(proto.STRING, number=4,) class UpdateCaPoolRequest(proto.Message): @@ -819,10 +783,10 @@ class UpdateCaPoolRequest(proto.Message): """ ca_pool = proto.Field(proto.MESSAGE, number=1, message=resources.CaPool,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - request_id = proto.Field(proto.STRING, number=3) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field(proto.STRING, number=3,) class DeleteCaPoolRequest(proto.Message): @@ -855,9 +819,8 @@ class DeleteCaPoolRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - - request_id = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + request_id = proto.Field(proto.STRING, number=2,) class FetchCaCertsRequest(proto.Message): @@ -890,9 +853,8 @@ class FetchCaCertsRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - ca_pool = proto.Field(proto.STRING, number=1) - - request_id = proto.Field(proto.STRING, number=2) + ca_pool = proto.Field(proto.STRING, number=1,) + request_id = proto.Field(proto.STRING, number=2,) class FetchCaCertsResponse(proto.Message): @@ -910,14 +872,13 @@ class FetchCaCertsResponse(proto.Message): class CertChain(proto.Message): r""" - Attributes: certificates (Sequence[str]): The certificates that form the CA chain, from leaf to root order. """ - certificates = proto.RepeatedField(proto.STRING, number=1) + certificates = proto.RepeatedField(proto.STRING, number=1,) ca_certs = proto.RepeatedField(proto.MESSAGE, number=1, message=CertChain,) @@ -934,7 +895,7 @@ class GetCaPoolRequest(proto.Message): get. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListCaPoolsRequest(proto.Message): @@ -966,15 +927,11 @@ class ListCaPoolsRequest(proto.Message): sorted. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListCaPoolsResponse(proto.Message): @@ -999,10 +956,8 @@ def raw_page(self): return self ca_pools = proto.RepeatedField(proto.MESSAGE, number=1, message=resources.CaPool,) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable = proto.RepeatedField(proto.STRING, number=3,) class GetCertificateRevocationListRequest(proto.Message): @@ -1018,7 +973,7 @@ class GetCertificateRevocationListRequest(proto.Message): to get. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListCertificateRevocationListsRequest(proto.Message): @@ -1052,15 +1007,11 @@ class ListCertificateRevocationListsRequest(proto.Message): sorted. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListCertificateRevocationListsResponse(proto.Message): @@ -1087,10 +1038,8 @@ def raw_page(self): certificate_revocation_lists = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.CertificateRevocationList, ) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable = proto.RepeatedField(proto.STRING, number=3,) class UpdateCertificateRevocationListRequest(proto.Message): @@ -1129,10 +1078,10 @@ class UpdateCertificateRevocationListRequest(proto.Message): certificate_revocation_list = proto.Field( proto.MESSAGE, number=1, message=resources.CertificateRevocationList, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - request_id = proto.Field(proto.STRING, number=3) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field(proto.STRING, number=3,) class CreateCertificateTemplateRequest(proto.Message): @@ -1173,15 +1122,12 @@ class CreateCertificateTemplateRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - parent = proto.Field(proto.STRING, number=1) - - certificate_template_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + certificate_template_id = proto.Field(proto.STRING, number=2,) certificate_template = proto.Field( proto.MESSAGE, number=3, message=resources.CertificateTemplate, ) - - request_id = proto.Field(proto.STRING, number=4) + request_id = proto.Field(proto.STRING, number=4,) class DeleteCertificateTemplateRequest(proto.Message): @@ -1215,9 +1161,8 @@ class DeleteCertificateTemplateRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - - request_id = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + request_id = proto.Field(proto.STRING, number=2,) class GetCertificateTemplateRequest(proto.Message): @@ -1233,7 +1178,7 @@ class GetCertificateTemplateRequest(proto.Message): to get. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListCertificateTemplatesRequest(proto.Message): @@ -1266,15 +1211,11 @@ class ListCertificateTemplatesRequest(proto.Message): sorted. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListCertificateTemplatesResponse(proto.Message): @@ -1301,10 +1242,8 @@ def raw_page(self): certificate_templates = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.CertificateTemplate, ) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable = proto.RepeatedField(proto.STRING, number=3,) class UpdateCertificateTemplateRequest(proto.Message): @@ -1343,15 +1282,14 @@ class UpdateCertificateTemplateRequest(proto.Message): certificate_template = proto.Field( proto.MESSAGE, number=1, message=resources.CertificateTemplate, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - request_id = proto.Field(proto.STRING, number=3) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field(proto.STRING, number=3,) class OperationMetadata(proto.Message): r"""Represents the metadata of the long-running operation. - Attributes: create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The time the operation was @@ -1379,19 +1317,13 @@ class OperationMetadata(proto.Message): operation. """ - create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - target = proto.Field(proto.STRING, number=3) - - verb = proto.Field(proto.STRING, number=4) - - status_message = proto.Field(proto.STRING, number=5) - - requested_cancellation = proto.Field(proto.BOOL, number=6) - - api_version = proto.Field(proto.STRING, number=7) + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + target = proto.Field(proto.STRING, number=3,) + verb = proto.Field(proto.STRING, number=4,) + status_message = proto.Field(proto.STRING, number=5,) + requested_cancellation = proto.Field(proto.BOOL, number=6,) + api_version = proto.Field(proto.STRING, number=7,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/security/privateca_v1beta1/__init__.py b/google/cloud/security/privateca_v1beta1/__init__.py index 9481b33..9258c1e 100644 --- a/google/cloud/security/privateca_v1beta1/__init__.py +++ b/google/cloud/security/privateca_v1beta1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +15,10 @@ # from .services.certificate_authority_service import CertificateAuthorityServiceClient +from .services.certificate_authority_service import ( + CertificateAuthorityServiceAsyncClient, +) + from .types.resources import Certificate from .types.resources import CertificateAuthority from .types.resources import CertificateConfig @@ -27,11 +30,11 @@ from .types.resources import ReusableConfig from .types.resources import ReusableConfigValues from .types.resources import ReusableConfigWrapper -from .types.resources import RevocationReason from .types.resources import Subject from .types.resources import SubjectAltNames from .types.resources import SubordinateConfig from .types.resources import X509Extension +from .types.resources import RevocationReason from .types.service import ActivateCertificateAuthorityRequest from .types.service import CreateCertificateAuthorityRequest from .types.service import CreateCertificateRequest @@ -59,11 +62,12 @@ from .types.service import UpdateCertificateRequest from .types.service import UpdateCertificateRevocationListRequest - __all__ = ( + "CertificateAuthorityServiceAsyncClient", "ActivateCertificateAuthorityRequest", "Certificate", "CertificateAuthority", + "CertificateAuthorityServiceClient", "CertificateConfig", "CertificateDescription", "CertificateRevocationList", @@ -103,5 +107,4 @@ "UpdateCertificateRequest", "UpdateCertificateRevocationListRequest", "X509Extension", - "CertificateAuthorityServiceClient", ) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/gapic_metadata.json b/google/cloud/security/privateca_v1beta1/gapic_metadata.json similarity index 100% rename from owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/gapic_metadata.json rename to google/cloud/security/privateca_v1beta1/gapic_metadata.json diff --git a/google/cloud/security/privateca_v1beta1/services/__init__.py b/google/cloud/security/privateca_v1beta1/services/__init__.py index 42ffdf2..4de6597 100644 --- a/google/cloud/security/privateca_v1beta1/services/__init__.py +++ b/google/cloud/security/privateca_v1beta1/services/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/__init__.py b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/__init__.py index d837719..f519622 100644 --- a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/__init__.py +++ b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import CertificateAuthorityServiceClient from .async_client import CertificateAuthorityServiceAsyncClient diff --git a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py index f55d241..409041d 100644 --- a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py +++ b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore @@ -35,10 +33,9 @@ ) from google.cloud.security.privateca_v1beta1.types import resources from google.cloud.security.privateca_v1beta1.types import service -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport from .client import CertificateAuthorityServiceClient @@ -77,35 +74,30 @@ class CertificateAuthorityServiceAsyncClient: parse_reusable_config_path = staticmethod( CertificateAuthorityServiceClient.parse_reusable_config_path ) - common_billing_account_path = staticmethod( CertificateAuthorityServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( CertificateAuthorityServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod( CertificateAuthorityServiceClient.common_folder_path ) parse_common_folder_path = staticmethod( CertificateAuthorityServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( CertificateAuthorityServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( CertificateAuthorityServiceClient.parse_common_organization_path ) - common_project_path = staticmethod( CertificateAuthorityServiceClient.common_project_path ) parse_common_project_path = staticmethod( CertificateAuthorityServiceClient.parse_common_project_path ) - common_location_path = staticmethod( CertificateAuthorityServiceClient.common_location_path ) @@ -115,7 +107,8 @@ class CertificateAuthorityServiceAsyncClient: @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -130,7 +123,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -147,7 +140,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> CertificateAuthorityServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: CertificateAuthorityServiceTransport: The transport used by the client instance. @@ -162,12 +155,12 @@ def transport(self) -> CertificateAuthorityServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, CertificateAuthorityServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the certificate authority service client. + """Instantiates the certificate authority service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -199,7 +192,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = CertificateAuthorityServiceClient( credentials=credentials, transport=transport, @@ -258,7 +250,6 @@ async def create_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. @@ -285,7 +276,6 @@ async def create_certificate( # 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: @@ -339,7 +329,6 @@ async def get_certificate( 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. @@ -366,7 +355,6 @@ async def get_certificate( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -416,7 +404,6 @@ async def list_certificates( 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. @@ -446,7 +433,6 @@ async def list_certificates( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -501,7 +487,6 @@ async def revoke_certificate( 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. @@ -528,7 +513,6 @@ async def revoke_certificate( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -557,7 +541,7 @@ async def update_certificate( request: service.UpdateCertificateRequest = None, *, certificate: resources.Certificate = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -587,7 +571,6 @@ async def update_certificate( 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. @@ -614,7 +597,6 @@ async def update_certificate( # 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: @@ -675,7 +657,6 @@ async def activate_certificate_authority( 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. @@ -707,7 +688,6 @@ async def activate_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -782,7 +762,6 @@ async def create_certificate_authority( This corresponds to the ``certificate_authority_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. @@ -816,7 +795,6 @@ async def create_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if certificate_authority is not None: @@ -877,7 +855,6 @@ async def disable_certificate_authority( 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. @@ -909,7 +886,6 @@ async def disable_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -966,7 +942,6 @@ async def enable_certificate_authority( 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. @@ -998,7 +973,6 @@ async def enable_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1064,7 +1038,6 @@ async def fetch_certificate_authority_csr( 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. @@ -1091,7 +1064,6 @@ async def fetch_certificate_authority_csr( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1141,7 +1113,6 @@ async def get_certificate_authority( 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. @@ -1171,7 +1142,6 @@ async def get_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1220,7 +1190,6 @@ async def list_certificate_authorities( 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. @@ -1250,7 +1219,6 @@ async def list_certificate_authorities( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1306,7 +1274,6 @@ async def restore_certificate_authority( 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. @@ -1338,7 +1305,6 @@ async def restore_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1396,7 +1362,6 @@ async def schedule_delete_certificate_authority( 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. @@ -1428,7 +1393,6 @@ async def schedule_delete_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1465,7 +1429,7 @@ async def update_certificate_authority( request: service.UpdateCertificateAuthorityRequest = None, *, certificate_authority: resources.CertificateAuthority = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1492,7 +1456,6 @@ async def update_certificate_authority( 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. @@ -1524,7 +1487,6 @@ async def update_certificate_authority( # If we have keyword arguments corresponding to fields on the # request, apply these. - if certificate_authority is not None: request.certificate_authority = certificate_authority if update_mask is not None: @@ -1586,7 +1548,6 @@ async def get_certificate_revocation_list( 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. @@ -1615,7 +1576,6 @@ async def get_certificate_revocation_list( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1665,7 +1625,6 @@ async def list_certificate_revocation_lists( 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. @@ -1695,7 +1654,6 @@ async def list_certificate_revocation_lists( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1730,7 +1688,7 @@ async def update_certificate_revocation_list( request: service.UpdateCertificateRevocationListRequest = None, *, certificate_revocation_list: resources.CertificateRevocationList = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1757,7 +1715,6 @@ async def update_certificate_revocation_list( 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. @@ -1788,7 +1745,6 @@ async def update_certificate_revocation_list( # If we have keyword arguments corresponding to fields on the # request, apply these. - if certificate_revocation_list is not None: request.certificate_revocation_list = certificate_revocation_list if update_mask is not None: @@ -1852,7 +1808,6 @@ async def get_reusable_config( 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. @@ -1882,7 +1837,6 @@ async def get_reusable_config( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1931,7 +1885,6 @@ async def list_reusable_configs( 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. @@ -1961,7 +1914,6 @@ async def list_reusable_configs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent diff --git a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py index f48b187..4187da0 100644 --- a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py +++ b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -39,10 +37,9 @@ ) from google.cloud.security.privateca_v1beta1.types import resources from google.cloud.security.privateca_v1beta1.types import service -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import CertificateAuthorityServiceGrpcTransport from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport @@ -67,7 +64,7 @@ class CertificateAuthorityServiceClientMeta(type): def get_transport_class( cls, label: str = None, ) -> Type[CertificateAuthorityServiceTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -95,7 +92,8 @@ class CertificateAuthorityServiceClient( @staticmethod def _get_default_mtls_endpoint(api_endpoint): - """Convert api endpoint to mTLS 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: @@ -129,7 +127,8 @@ def _get_default_mtls_endpoint(api_endpoint): @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -146,7 +145,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -165,10 +164,11 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> CertificateAuthorityServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - CertificateAuthorityServiceTransport: The transport used by the client instance. + CertificateAuthorityServiceTransport: The transport used by the client + instance. """ return self._transport @@ -176,7 +176,7 @@ def transport(self) -> CertificateAuthorityServiceTransport: def certificate_path( project: str, location: str, certificate_authority: str, certificate: str, ) -> str: - """Return a fully-qualified certificate string.""" + """Returns a fully-qualified certificate string.""" return "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}/certificates/{certificate}".format( project=project, location=location, @@ -186,7 +186,7 @@ def certificate_path( @staticmethod def parse_certificate_path(path: str) -> Dict[str, str]: - """Parse a certificate path into its component segments.""" + """Parses a certificate path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/certificateAuthorities/(?P.+?)/certificates/(?P.+?)$", path, @@ -197,7 +197,7 @@ def parse_certificate_path(path: str) -> Dict[str, str]: def certificate_authority_path( project: str, location: str, certificate_authority: str, ) -> str: - """Return a fully-qualified certificate_authority string.""" + """Returns a fully-qualified certificate_authority string.""" return "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}".format( project=project, location=location, @@ -206,7 +206,7 @@ def certificate_authority_path( @staticmethod def parse_certificate_authority_path(path: str) -> Dict[str, str]: - """Parse a certificate_authority path into its component segments.""" + """Parses a certificate_authority path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/certificateAuthorities/(?P.+?)$", path, @@ -220,7 +220,7 @@ def certificate_revocation_list_path( certificate_authority: str, certificate_revocation_list: str, ) -> str: - """Return a fully-qualified certificate_revocation_list string.""" + """Returns a fully-qualified certificate_revocation_list string.""" return "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list}".format( project=project, location=location, @@ -230,7 +230,7 @@ def certificate_revocation_list_path( @staticmethod def parse_certificate_revocation_list_path(path: str) -> Dict[str, str]: - """Parse a certificate_revocation_list path into its component segments.""" + """Parses a certificate_revocation_list path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/certificateAuthorities/(?P.+?)/certificateRevocationLists/(?P.+?)$", path, @@ -239,14 +239,14 @@ def parse_certificate_revocation_list_path(path: str) -> Dict[str, str]: @staticmethod def reusable_config_path(project: str, location: str, reusable_config: str,) -> str: - """Return a fully-qualified reusable_config string.""" + """Returns a fully-qualified reusable_config string.""" return "projects/{project}/locations/{location}/reusableConfigs/{reusable_config}".format( project=project, location=location, reusable_config=reusable_config, ) @staticmethod def parse_reusable_config_path(path: str) -> Dict[str, str]: - """Parse a reusable_config path into its component segments.""" + """Parses a reusable_config path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/reusableConfigs/(?P.+?)$", path, @@ -255,7 +255,7 @@ def parse_reusable_config_path(path: str) -> Dict[str, str]: @staticmethod def common_billing_account_path(billing_account: str,) -> str: - """Return a fully-qualified billing_account string.""" + """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -268,7 +268,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: @staticmethod def common_folder_path(folder: str,) -> str: - """Return a fully-qualified folder string.""" + """Returns a fully-qualified folder string.""" return "folders/{folder}".format(folder=folder,) @staticmethod @@ -279,7 +279,7 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: @staticmethod def common_organization_path(organization: str,) -> str: - """Return a fully-qualified organization string.""" + """Returns a fully-qualified organization string.""" return "organizations/{organization}".format(organization=organization,) @staticmethod @@ -290,7 +290,7 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: @staticmethod def common_project_path(project: str,) -> str: - """Return a fully-qualified project string.""" + """Returns a fully-qualified project string.""" return "projects/{project}".format(project=project,) @staticmethod @@ -301,7 +301,7 @@ def parse_common_project_path(path: str) -> Dict[str, str]: @staticmethod def common_location_path(project: str, location: str,) -> str: - """Return a fully-qualified location string.""" + """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -315,12 +315,12 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, CertificateAuthorityServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the certificate authority service client. + """Instantiates the certificate authority service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -375,9 +375,10 @@ def __init__( client_cert_source_func = client_options.client_cert_source else: is_mtls = mtls.has_default_client_cert_source() - client_cert_source_func = ( - mtls.default_client_cert_source() if is_mtls else None - ) + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None # Figure out which api endpoint to use. if client_options.api_endpoint is not None: @@ -389,12 +390,14 @@ def __init__( elif use_mtls_env == "always": api_endpoint = self.DEFAULT_MTLS_ENDPOINT elif use_mtls_env == "auto": - api_endpoint = ( - self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT - ) + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT else: raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always" + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" ) # Save or instantiate the transport. @@ -409,8 +412,8 @@ def __init__( ) if client_options.scopes: raise ValueError( - "When providing a transport instance, " - "provide its scopes directly." + "When providing a transport instance, provide its scopes " + "directly." ) self._transport = transport else: @@ -476,7 +479,6 @@ def create_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. @@ -505,10 +507,8 @@ def create_certificate( # there are no flattened fields. if not isinstance(request, service.CreateCertificateRequest): request = service.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: @@ -558,7 +558,6 @@ def get_certificate( 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. @@ -587,10 +586,8 @@ def get_certificate( # there are no flattened fields. if not isinstance(request, service.GetCertificateRequest): request = service.GetCertificateRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -636,7 +633,6 @@ def list_certificates( 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. @@ -668,10 +664,8 @@ def list_certificates( # there are no flattened fields. if not isinstance(request, service.ListCertificatesRequest): request = service.ListCertificatesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -722,7 +716,6 @@ def revoke_certificate( 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. @@ -751,10 +744,8 @@ def revoke_certificate( # there are no flattened fields. if not isinstance(request, service.RevokeCertificateRequest): request = service.RevokeCertificateRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -779,7 +770,7 @@ def update_certificate( request: service.UpdateCertificateRequest = None, *, certificate: resources.Certificate = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -809,7 +800,6 @@ def update_certificate( 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. @@ -838,10 +828,8 @@ def update_certificate( # there are no flattened fields. if not isinstance(request, service.UpdateCertificateRequest): request = service.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: @@ -898,7 +886,6 @@ def activate_certificate_authority( 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. @@ -932,10 +919,8 @@ def activate_certificate_authority( # there are no flattened fields. if not isinstance(request, service.ActivateCertificateAuthorityRequest): request = service.ActivateCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1008,7 +993,6 @@ def create_certificate_authority( This corresponds to the ``certificate_authority_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. @@ -1044,10 +1028,8 @@ def create_certificate_authority( # there are no flattened fields. if not isinstance(request, service.CreateCertificateAuthorityRequest): request = service.CreateCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if certificate_authority is not None: @@ -1106,7 +1088,6 @@ def disable_certificate_authority( 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. @@ -1140,10 +1121,8 @@ def disable_certificate_authority( # there are no flattened fields. if not isinstance(request, service.DisableCertificateAuthorityRequest): request = service.DisableCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1198,7 +1177,6 @@ def enable_certificate_authority( 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. @@ -1232,10 +1210,8 @@ def enable_certificate_authority( # there are no flattened fields. if not isinstance(request, service.EnableCertificateAuthorityRequest): request = service.EnableCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1299,7 +1275,6 @@ def fetch_certificate_authority_csr( 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. @@ -1328,10 +1303,8 @@ def fetch_certificate_authority_csr( # there are no flattened fields. if not isinstance(request, service.FetchCertificateAuthorityCsrRequest): request = service.FetchCertificateAuthorityCsrRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1379,7 +1352,6 @@ def get_certificate_authority( 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. @@ -1411,10 +1383,8 @@ def get_certificate_authority( # there are no flattened fields. if not isinstance(request, service.GetCertificateAuthorityRequest): request = service.GetCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1461,7 +1431,6 @@ def list_certificate_authorities( 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. @@ -1493,10 +1462,8 @@ def list_certificate_authorities( # there are no flattened fields. if not isinstance(request, service.ListCertificateAuthoritiesRequest): request = service.ListCertificateAuthoritiesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1550,7 +1517,6 @@ def restore_certificate_authority( 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. @@ -1584,10 +1550,8 @@ def restore_certificate_authority( # there are no flattened fields. if not isinstance(request, service.RestoreCertificateAuthorityRequest): request = service.RestoreCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1643,7 +1607,6 @@ def schedule_delete_certificate_authority( 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. @@ -1677,10 +1640,8 @@ def schedule_delete_certificate_authority( # there are no flattened fields. if not isinstance(request, service.ScheduleDeleteCertificateAuthorityRequest): request = service.ScheduleDeleteCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1715,7 +1676,7 @@ def update_certificate_authority( request: service.UpdateCertificateAuthorityRequest = None, *, certificate_authority: resources.CertificateAuthority = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1742,7 +1703,6 @@ def update_certificate_authority( 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. @@ -1776,10 +1736,8 @@ def update_certificate_authority( # there are no flattened fields. if not isinstance(request, service.UpdateCertificateAuthorityRequest): request = service.UpdateCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if certificate_authority is not None: request.certificate_authority = certificate_authority if update_mask is not None: @@ -1839,7 +1797,6 @@ def get_certificate_revocation_list( 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. @@ -1870,10 +1827,8 @@ def get_certificate_revocation_list( # there are no flattened fields. if not isinstance(request, service.GetCertificateRevocationListRequest): request = service.GetCertificateRevocationListRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1921,7 +1876,6 @@ def list_certificate_revocation_lists( 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. @@ -1953,10 +1907,8 @@ def list_certificate_revocation_lists( # there are no flattened fields. if not isinstance(request, service.ListCertificateRevocationListsRequest): request = service.ListCertificateRevocationListsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1989,7 +1941,7 @@ def update_certificate_revocation_list( request: service.UpdateCertificateRevocationListRequest = None, *, certificate_revocation_list: resources.CertificateRevocationList = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2016,7 +1968,6 @@ def update_certificate_revocation_list( 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. @@ -2049,10 +2000,8 @@ def update_certificate_revocation_list( # there are no flattened fields. if not isinstance(request, service.UpdateCertificateRevocationListRequest): request = service.UpdateCertificateRevocationListRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if certificate_revocation_list is not None: request.certificate_revocation_list = certificate_revocation_list if update_mask is not None: @@ -2114,7 +2063,6 @@ def get_reusable_config( 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. @@ -2146,10 +2094,8 @@ def get_reusable_config( # there are no flattened fields. if not isinstance(request, service.GetReusableConfigRequest): request = service.GetReusableConfigRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2194,7 +2140,6 @@ def list_reusable_configs( 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. @@ -2226,10 +2171,8 @@ def list_reusable_configs( # there are no flattened fields. if not isinstance(request, service.ListReusableConfigsRequest): request = service.ListReusableConfigsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent diff --git a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py index f315d76..d8c14ca 100644 --- a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py +++ b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, @@ -118,7 +116,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -246,7 +244,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -376,7 +374,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -506,7 +504,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and diff --git a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/__init__.py b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/__init__.py index 3a3aa46..ab66300 100644 --- a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/__init__.py +++ b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py index 3f444e1..e47a764 100644 --- a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py +++ b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.security.privateca_v1beta1.types import resources from google.cloud.security.privateca_v1beta1.types import service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -40,27 +39,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class CertificateAuthorityServiceTransport(abc.ABC): """Abstract transport class for CertificateAuthorityService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "privateca.googleapis.com" + def __init__( self, *, - host: str = "privateca.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + 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 @@ -69,7 +82,7 @@ def __init__( 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. - scope (Optional[Sequence[str]]): A list of scopes. + 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): @@ -83,29 +96,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -207,29 +267,29 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_certificate( self, - ) -> typing.Callable[ + ) -> Callable[ [service.CreateCertificateRequest], - typing.Union[resources.Certificate, typing.Awaitable[resources.Certificate]], + Union[resources.Certificate, Awaitable[resources.Certificate]], ]: raise NotImplementedError() @property def get_certificate( self, - ) -> typing.Callable[ + ) -> Callable[ [service.GetCertificateRequest], - typing.Union[resources.Certificate, typing.Awaitable[resources.Certificate]], + Union[resources.Certificate, Awaitable[resources.Certificate]], ]: raise NotImplementedError() @property def list_certificates( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ListCertificatesRequest], - typing.Union[ + Union[ service.ListCertificatesResponse, - typing.Awaitable[service.ListCertificatesResponse], + Awaitable[service.ListCertificatesResponse], ], ]: raise NotImplementedError() @@ -237,65 +297,65 @@ def list_certificates( @property def revoke_certificate( self, - ) -> typing.Callable[ + ) -> Callable[ [service.RevokeCertificateRequest], - typing.Union[resources.Certificate, typing.Awaitable[resources.Certificate]], + Union[resources.Certificate, Awaitable[resources.Certificate]], ]: raise NotImplementedError() @property def update_certificate( self, - ) -> typing.Callable[ + ) -> Callable[ [service.UpdateCertificateRequest], - typing.Union[resources.Certificate, typing.Awaitable[resources.Certificate]], + Union[resources.Certificate, Awaitable[resources.Certificate]], ]: raise NotImplementedError() @property def activate_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ActivateCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def create_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.CreateCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def disable_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.DisableCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def enable_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.EnableCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def fetch_certificate_authority_csr( self, - ) -> typing.Callable[ + ) -> Callable[ [service.FetchCertificateAuthorityCsrRequest], - typing.Union[ + Union[ service.FetchCertificateAuthorityCsrResponse, - typing.Awaitable[service.FetchCertificateAuthorityCsrResponse], + Awaitable[service.FetchCertificateAuthorityCsrResponse], ], ]: raise NotImplementedError() @@ -303,11 +363,10 @@ def fetch_certificate_authority_csr( @property def get_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.GetCertificateAuthorityRequest], - typing.Union[ - resources.CertificateAuthority, - typing.Awaitable[resources.CertificateAuthority], + Union[ + resources.CertificateAuthority, Awaitable[resources.CertificateAuthority] ], ]: raise NotImplementedError() @@ -315,11 +374,11 @@ def get_certificate_authority( @property def list_certificate_authorities( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ListCertificateAuthoritiesRequest], - typing.Union[ + Union[ service.ListCertificateAuthoritiesResponse, - typing.Awaitable[service.ListCertificateAuthoritiesResponse], + Awaitable[service.ListCertificateAuthoritiesResponse], ], ]: raise NotImplementedError() @@ -327,38 +386,38 @@ def list_certificate_authorities( @property def restore_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.RestoreCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def schedule_delete_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ScheduleDeleteCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def update_certificate_authority( self, - ) -> typing.Callable[ + ) -> Callable[ [service.UpdateCertificateAuthorityRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_certificate_revocation_list( self, - ) -> typing.Callable[ + ) -> Callable[ [service.GetCertificateRevocationListRequest], - typing.Union[ + Union[ resources.CertificateRevocationList, - typing.Awaitable[resources.CertificateRevocationList], + Awaitable[resources.CertificateRevocationList], ], ]: raise NotImplementedError() @@ -366,11 +425,11 @@ def get_certificate_revocation_list( @property def list_certificate_revocation_lists( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ListCertificateRevocationListsRequest], - typing.Union[ + Union[ service.ListCertificateRevocationListsResponse, - typing.Awaitable[service.ListCertificateRevocationListsResponse], + Awaitable[service.ListCertificateRevocationListsResponse], ], ]: raise NotImplementedError() @@ -378,31 +437,29 @@ def list_certificate_revocation_lists( @property def update_certificate_revocation_list( self, - ) -> typing.Callable[ + ) -> Callable[ [service.UpdateCertificateRevocationListRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_reusable_config( self, - ) -> typing.Callable[ + ) -> Callable[ [service.GetReusableConfigRequest], - typing.Union[ - resources.ReusableConfig, typing.Awaitable[resources.ReusableConfig] - ], + Union[resources.ReusableConfig, Awaitable[resources.ReusableConfig]], ]: raise NotImplementedError() @property def list_reusable_configs( self, - ) -> typing.Callable[ + ) -> Callable[ [service.ListReusableConfigsRequest], - typing.Union[ + Union[ service.ListReusableConfigsResponse, - typing.Awaitable[service.ListReusableConfigsResponse], + Awaitable[service.ListReusableConfigsResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py index 81f9aca..dfbd38f 100644 --- a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py +++ b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.security.privateca_v1beta1.types import resources from google.cloud.security.privateca_v1beta1.types import service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO @@ -55,7 +52,7 @@ def __init__( self, *, host: str = "privateca.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -69,7 +66,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + 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 @@ -180,7 +178,7 @@ def __init__( def create_channel( cls, host: str = "privateca.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -211,13 +209,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -384,7 +384,9 @@ def update_certificate( @property def activate_certificate_authority( self, - ) -> Callable[[service.ActivateCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.ActivateCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the activate certificate authority method over gRPC. Activate a @@ -414,14 +416,16 @@ def activate_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ActivateCertificateAuthority", request_serializer=service.ActivateCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["activate_certificate_authority"] @property def create_certificate_authority( self, - ) -> Callable[[service.CreateCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.CreateCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the create certificate authority method over gRPC. Create a new @@ -442,14 +446,16 @@ def create_certificate_authority( self._stubs["create_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificateAuthority", request_serializer=service.CreateCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_certificate_authority"] @property def disable_certificate_authority( self, - ) -> Callable[[service.DisableCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.DisableCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the disable certificate authority method over gRPC. Disable a @@ -471,14 +477,16 @@ def disable_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/DisableCertificateAuthority", request_serializer=service.DisableCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["disable_certificate_authority"] @property def enable_certificate_authority( self, - ) -> Callable[[service.EnableCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.EnableCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the enable certificate authority method over gRPC. Enable a @@ -498,7 +506,7 @@ def enable_certificate_authority( self._stubs["enable_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/EnableCertificateAuthority", request_serializer=service.EnableCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["enable_certificate_authority"] @@ -606,7 +614,9 @@ def list_certificate_authorities( @property def restore_certificate_authority( self, - ) -> Callable[[service.RestoreCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.RestoreCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the restore certificate authority method over gRPC. Restore a @@ -629,7 +639,7 @@ def restore_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RestoreCertificateAuthority", request_serializer=service.RestoreCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["restore_certificate_authority"] @@ -637,7 +647,7 @@ def restore_certificate_authority( def schedule_delete_certificate_authority( self, ) -> Callable[ - [service.ScheduleDeleteCertificateAuthorityRequest], operations.Operation + [service.ScheduleDeleteCertificateAuthorityRequest], operations_pb2.Operation ]: r"""Return a callable for the schedule delete certificate authority method over gRPC. @@ -662,14 +672,16 @@ def schedule_delete_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ScheduleDeleteCertificateAuthority", request_serializer=service.ScheduleDeleteCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["schedule_delete_certificate_authority"] @property def update_certificate_authority( self, - ) -> Callable[[service.UpdateCertificateAuthorityRequest], operations.Operation]: + ) -> Callable[ + [service.UpdateCertificateAuthorityRequest], operations_pb2.Operation + ]: r"""Return a callable for the update certificate authority method over gRPC. Update a @@ -689,7 +701,7 @@ def update_certificate_authority( self._stubs["update_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateAuthority", request_serializer=service.UpdateCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_certificate_authority"] @@ -763,7 +775,7 @@ def list_certificate_revocation_lists( def update_certificate_revocation_list( self, ) -> Callable[ - [service.UpdateCertificateRevocationListRequest], operations.Operation + [service.UpdateCertificateRevocationListRequest], operations_pb2.Operation ]: r"""Return a callable for the update certificate revocation list method over gRPC. @@ -787,7 +799,7 @@ def update_certificate_revocation_list( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateRevocationList", request_serializer=service.UpdateCertificateRevocationListRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_certificate_revocation_list"] diff --git a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py index 9b6a1e5..88f8ced 100644 --- a/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py +++ b/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,24 +13,22 @@ # 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 +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.security.privateca_v1beta1.types import resources from google.cloud.security.privateca_v1beta1.types import service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO from .grpc import CertificateAuthorityServiceGrpcTransport @@ -60,7 +57,7 @@ class CertificateAuthorityServiceGrpcAsyncIOTransport( def create_channel( cls, host: str = "privateca.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -87,13 +84,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -101,7 +100,7 @@ def __init__( self, *, host: str = "privateca.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -115,7 +114,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + 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 @@ -174,7 +174,6 @@ def __init__( # 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 @@ -395,7 +394,8 @@ def update_certificate( def activate_certificate_authority( self, ) -> Callable[ - [service.ActivateCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.ActivateCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the activate certificate authority method over gRPC. @@ -426,7 +426,7 @@ def activate_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ActivateCertificateAuthority", request_serializer=service.ActivateCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["activate_certificate_authority"] @@ -434,7 +434,7 @@ def activate_certificate_authority( def create_certificate_authority( self, ) -> Callable[ - [service.CreateCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.CreateCertificateAuthorityRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the create certificate authority method over gRPC. @@ -456,7 +456,7 @@ def create_certificate_authority( self._stubs["create_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificateAuthority", request_serializer=service.CreateCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_certificate_authority"] @@ -464,7 +464,8 @@ def create_certificate_authority( def disable_certificate_authority( self, ) -> Callable[ - [service.DisableCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.DisableCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the disable certificate authority method over gRPC. @@ -487,7 +488,7 @@ def disable_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/DisableCertificateAuthority", request_serializer=service.DisableCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["disable_certificate_authority"] @@ -495,7 +496,7 @@ def disable_certificate_authority( def enable_certificate_authority( self, ) -> Callable[ - [service.EnableCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.EnableCertificateAuthorityRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the enable certificate authority method over gRPC. @@ -516,7 +517,7 @@ def enable_certificate_authority( self._stubs["enable_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/EnableCertificateAuthority", request_serializer=service.EnableCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["enable_certificate_authority"] @@ -626,7 +627,8 @@ def list_certificate_authorities( def restore_certificate_authority( self, ) -> Callable[ - [service.RestoreCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.RestoreCertificateAuthorityRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the restore certificate authority method over gRPC. @@ -650,7 +652,7 @@ def restore_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RestoreCertificateAuthority", request_serializer=service.RestoreCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["restore_certificate_authority"] @@ -659,7 +661,7 @@ def schedule_delete_certificate_authority( self, ) -> Callable[ [service.ScheduleDeleteCertificateAuthorityRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the schedule delete certificate authority method over gRPC. @@ -684,7 +686,7 @@ def schedule_delete_certificate_authority( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ScheduleDeleteCertificateAuthority", request_serializer=service.ScheduleDeleteCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["schedule_delete_certificate_authority"] @@ -692,7 +694,7 @@ def schedule_delete_certificate_authority( def update_certificate_authority( self, ) -> Callable[ - [service.UpdateCertificateAuthorityRequest], Awaitable[operations.Operation] + [service.UpdateCertificateAuthorityRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the update certificate authority method over gRPC. @@ -713,7 +715,7 @@ def update_certificate_authority( self._stubs["update_certificate_authority"] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateAuthority", request_serializer=service.UpdateCertificateAuthorityRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_certificate_authority"] @@ -788,7 +790,7 @@ def update_certificate_revocation_list( self, ) -> Callable[ [service.UpdateCertificateRevocationListRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the update certificate revocation list method over gRPC. @@ -812,7 +814,7 @@ def update_certificate_revocation_list( ] = self.grpc_channel.unary_unary( "/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateRevocationList", request_serializer=service.UpdateCertificateRevocationListRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_certificate_revocation_list"] diff --git a/google/cloud/security/privateca_v1beta1/types/__init__.py b/google/cloud/security/privateca_v1beta1/types/__init__.py index 81ae506..af03f43 100644 --- a/google/cloud/security/privateca_v1beta1/types/__init__.py +++ b/google/cloud/security/privateca_v1beta1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .resources import ( Certificate, CertificateAuthority, diff --git a/google/cloud/security/privateca_v1beta1/types/resources.py b/google/cloud/security/privateca_v1beta1/types/resources.py index c045068..d8ebf2c 100644 --- a/google/cloud/security/privateca_v1beta1/types/resources.py +++ b/google/cloud/security/privateca_v1beta1/types/resources.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore __protobuf__ = proto.module( @@ -244,9 +241,8 @@ class IssuingOptions(proto.Message): certificate is revoked. """ - include_ca_cert_url = proto.Field(proto.BOOL, number=1) - - include_crl_access_url = proto.Field(proto.BOOL, number=2) + include_ca_cert_url = proto.Field(proto.BOOL, number=1,) + include_crl_access_url = proto.Field(proto.BOOL, number=2,) class CertificateAuthorityPolicy(proto.Message): r"""The issuing policy for a @@ -323,7 +319,6 @@ class CertificateAuthorityPolicy(proto.Message): class AllowedConfigList(proto.Message): r""" - Attributes: allowed_config_values (Sequence[google.cloud.security.privateca_v1beta1.types.ReusableConfigWrapper]): Required. All @@ -385,17 +380,12 @@ class AllowedSubjectAltNames(proto.Message): X509Extension values. """ - allowed_dns_names = proto.RepeatedField(proto.STRING, number=1) - - allowed_uris = proto.RepeatedField(proto.STRING, number=2) - - allowed_email_addresses = proto.RepeatedField(proto.STRING, number=3) - - allowed_ips = proto.RepeatedField(proto.STRING, number=4) - - allow_globbing_dns_wildcards = proto.Field(proto.BOOL, number=5) - - allow_custom_sans = proto.Field(proto.BOOL, number=6) + allowed_dns_names = proto.RepeatedField(proto.STRING, number=1,) + allowed_uris = proto.RepeatedField(proto.STRING, number=2,) + allowed_email_addresses = proto.RepeatedField(proto.STRING, number=3,) + allowed_ips = proto.RepeatedField(proto.STRING, number=4,) + allow_globbing_dns_wildcards = proto.Field(proto.BOOL, number=5,) + allow_custom_sans = proto.Field(proto.BOOL, number=6,) class IssuanceModes(proto.Message): r"""[IssuanceModes][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.IssuanceModes] @@ -416,9 +406,8 @@ class IssuanceModes(proto.Message): [CertificateConfig][google.cloud.security.privateca.v1beta1.CertificateConfig]. """ - allow_csr_based_issuance = proto.Field(proto.BOOL, number=1) - - allow_config_based_issuance = proto.Field(proto.BOOL, number=2) + allow_csr_based_issuance = proto.Field(proto.BOOL, number=1,) + allow_config_based_issuance = proto.Field(proto.BOOL, number=2,) allowed_config_list = proto.Field( proto.MESSAGE, @@ -426,30 +415,24 @@ class IssuanceModes(proto.Message): oneof="config_policy", message="CertificateAuthority.CertificateAuthorityPolicy.AllowedConfigList", ) - overwrite_config_values = proto.Field( proto.MESSAGE, number=2, oneof="config_policy", message="ReusableConfigWrapper", ) - allowed_locations_and_organizations = proto.RepeatedField( proto.MESSAGE, number=3, message="Subject", ) - - allowed_common_names = proto.RepeatedField(proto.STRING, number=4) - + allowed_common_names = proto.RepeatedField(proto.STRING, number=4,) allowed_sans = proto.Field( proto.MESSAGE, number=5, message="CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames", ) - maximum_lifetime = proto.Field( - proto.MESSAGE, number=6, message=duration.Duration, + proto.MESSAGE, number=6, message=duration_pb2.Duration, ) - allowed_issuance_modes = proto.Field( proto.MESSAGE, number=8, @@ -474,9 +457,8 @@ class AccessUrls(proto.Message): been activated. """ - ca_certificate_access_url = proto.Field(proto.STRING, number=1) - - crl_access_url = proto.Field(proto.STRING, number=2) + ca_certificate_access_url = proto.Field(proto.STRING, number=1,) + crl_access_url = proto.Field(proto.STRING, number=2,) class KeyVersionSpec(proto.Message): r"""A Cloud KMS key configuration that a @@ -498,8 +480,7 @@ class KeyVersionSpec(proto.Message): ``HSM``. """ - cloud_kms_key_version = proto.Field(proto.STRING, number=1, oneof="KeyVersion") - + cloud_kms_key_version = proto.Field(proto.STRING, number=1, oneof="KeyVersion",) algorithm = proto.Field( proto.ENUM, number=2, @@ -507,47 +488,36 @@ class KeyVersionSpec(proto.Message): enum="CertificateAuthority.SignHashAlgorithm", ) - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) type_ = proto.Field(proto.ENUM, number=2, enum=Type,) - tier = proto.Field(proto.ENUM, number=3, enum=Tier,) - config = proto.Field(proto.MESSAGE, number=4, message="CertificateConfig",) - - lifetime = proto.Field(proto.MESSAGE, number=5, message=duration.Duration,) - + lifetime = proto.Field(proto.MESSAGE, number=5, message=duration_pb2.Duration,) key_spec = proto.Field(proto.MESSAGE, number=6, message=KeyVersionSpec,) - certificate_policy = proto.Field( proto.MESSAGE, number=7, message=CertificateAuthorityPolicy, ) - issuing_options = proto.Field(proto.MESSAGE, number=8, message=IssuingOptions,) - subordinate_config = proto.Field( proto.MESSAGE, number=19, message="SubordinateConfig", ) - state = proto.Field(proto.ENUM, number=10, enum=State,) - - pem_ca_certificates = proto.RepeatedField(proto.STRING, number=9) - + pem_ca_certificates = proto.RepeatedField(proto.STRING, number=9,) ca_certificate_descriptions = proto.RepeatedField( proto.MESSAGE, number=12, message="CertificateDescription", ) - - gcs_bucket = proto.Field(proto.STRING, number=13) - + gcs_bucket = proto.Field(proto.STRING, number=13,) access_urls = proto.Field(proto.MESSAGE, number=14, message=AccessUrls,) - - create_time = proto.Field(proto.MESSAGE, number=15, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=16, message=timestamp.Timestamp,) - - delete_time = proto.Field(proto.MESSAGE, number=17, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=18) + create_time = proto.Field( + proto.MESSAGE, number=15, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=16, message=timestamp_pb2.Timestamp, + ) + delete_time = proto.Field( + proto.MESSAGE, number=17, message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField(proto.STRING, proto.STRING, number=18,) class CertificateRevocationList(proto.Message): @@ -618,31 +588,21 @@ class RevokedCertificate(proto.Message): was revoked. """ - certificate = proto.Field(proto.STRING, number=1) - - hex_serial_number = proto.Field(proto.STRING, number=2) - + certificate = proto.Field(proto.STRING, number=1,) + hex_serial_number = proto.Field(proto.STRING, number=2,) revocation_reason = proto.Field(proto.ENUM, number=3, enum="RevocationReason",) - name = proto.Field(proto.STRING, number=1) - - sequence_number = proto.Field(proto.INT64, number=2) - + name = proto.Field(proto.STRING, number=1,) + sequence_number = proto.Field(proto.INT64, number=2,) revoked_certificates = proto.RepeatedField( proto.MESSAGE, number=3, message=RevokedCertificate, ) - - pem_crl = proto.Field(proto.STRING, number=4) - - access_url = proto.Field(proto.STRING, number=5) - + pem_crl = proto.Field(proto.STRING, number=4,) + access_url = proto.Field(proto.STRING, number=5,) state = proto.Field(proto.ENUM, number=6, enum=State,) - - create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=9) + create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=9,) class Certificate(proto.Message): @@ -712,41 +672,32 @@ class RevocationDetails(proto.Message): """ revocation_state = proto.Field(proto.ENUM, number=1, enum="RevocationReason",) - revocation_time = proto.Field( - proto.MESSAGE, number=2, message=timestamp.Timestamp, + proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, ) - name = proto.Field(proto.STRING, number=1) - - pem_csr = proto.Field(proto.STRING, number=2, oneof="certificate_config") - + name = proto.Field(proto.STRING, number=1,) + pem_csr = proto.Field(proto.STRING, number=2, oneof="certificate_config",) config = proto.Field( proto.MESSAGE, number=3, oneof="certificate_config", message="CertificateConfig", ) - - lifetime = proto.Field(proto.MESSAGE, number=4, message=duration.Duration,) - + lifetime = proto.Field(proto.MESSAGE, number=4, message=duration_pb2.Duration,) revocation_details = proto.Field( proto.MESSAGE, number=5, message=RevocationDetails, ) - - pem_certificate = proto.Field(proto.STRING, number=6) - + pem_certificate = proto.Field(proto.STRING, number=6,) certificate_description = proto.Field( proto.MESSAGE, number=7, message="CertificateDescription", ) - - pem_certificate_chain = proto.RepeatedField(proto.STRING, number=8) - - create_time = proto.Field(proto.MESSAGE, number=9, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=10, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=11) + pem_certificate_chain = proto.RepeatedField(proto.STRING, number=8,) + create_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) + update_time = proto.Field( + proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField(proto.STRING, proto.STRING, number=11,) class ReusableConfig(proto.Message): @@ -781,17 +732,12 @@ class ReusableConfig(proto.Message): Optional. Labels with user-defined metadata. """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) values = proto.Field(proto.MESSAGE, number=2, message="ReusableConfigValues",) - - description = proto.Field(proto.STRING, number=3) - - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=6) + description = proto.Field(proto.STRING, number=3,) + create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=6,) class ReusableConfigValues(proto.Message): @@ -824,7 +770,6 @@ class ReusableConfigValues(proto.Message): class CaOptions(proto.Message): r"""Describes values that are relevant in a CA certificate. - Attributes: is_ca (google.protobuf.wrappers_pb2.BoolValue): Optional. Refers to the "CA" X.509 extension, @@ -841,20 +786,15 @@ class CaOptions(proto.Message): length will be omitted from the CA certificate. """ - is_ca = proto.Field(proto.MESSAGE, number=1, message=wrappers.BoolValue,) - + is_ca = proto.Field(proto.MESSAGE, number=1, message=wrappers_pb2.BoolValue,) max_issuer_path_length = proto.Field( - proto.MESSAGE, number=2, message=wrappers.Int32Value, + proto.MESSAGE, number=2, message=wrappers_pb2.Int32Value, ) key_usage = proto.Field(proto.MESSAGE, number=1, message="KeyUsage",) - ca_options = proto.Field(proto.MESSAGE, number=2, message=CaOptions,) - policy_ids = proto.RepeatedField(proto.MESSAGE, number=3, message="ObjectId",) - - aia_ocsp_servers = proto.RepeatedField(proto.STRING, number=4) - + aia_ocsp_servers = proto.RepeatedField(proto.STRING, number=4,) additional_extensions = proto.RepeatedField( proto.MESSAGE, number=5, message="X509Extension", ) @@ -876,8 +816,7 @@ class ReusableConfigWrapper(proto.Message): [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues]. """ - reusable_config = proto.Field(proto.STRING, number=1, oneof="config_values") - + reusable_config = proto.Field(proto.STRING, number=1, oneof="config_values",) reusable_config_values = proto.Field( proto.MESSAGE, number=2, oneof="config_values", message="ReusableConfigValues", ) @@ -915,12 +854,11 @@ class SubordinateConfigChain(proto.Message): order according to RFC 5246. """ - pem_certificates = proto.RepeatedField(proto.STRING, number=1) + pem_certificates = proto.RepeatedField(proto.STRING, number=1,) certificate_authority = proto.Field( - proto.STRING, number=1, oneof="subordinate_config" + proto.STRING, number=1, oneof="subordinate_config", ) - pem_issuer_chain = proto.Field( proto.MESSAGE, number=2, @@ -952,8 +890,7 @@ class KeyType(proto.Enum): PEM_EC_KEY = 2 type_ = proto.Field(proto.ENUM, number=1, enum=KeyType,) - - key = proto.Field(proto.BYTES, number=2) + key = proto.Field(proto.BYTES, number=2,) class CertificateConfig(proto.Message): @@ -997,19 +934,15 @@ class SubjectConfig(proto.Message): """ subject = proto.Field(proto.MESSAGE, number=1, message="Subject",) - - common_name = proto.Field(proto.STRING, number=2) - + common_name = proto.Field(proto.STRING, number=2,) subject_alt_name = proto.Field( proto.MESSAGE, number=3, message="SubjectAltNames", ) subject_config = proto.Field(proto.MESSAGE, number=1, message=SubjectConfig,) - reusable_config = proto.Field( proto.MESSAGE, number=2, message="ReusableConfigWrapper", ) - public_key = proto.Field(proto.MESSAGE, number=3, message="PublicKey",) @@ -1077,23 +1010,17 @@ class SubjectDescription(proto.Message): """ subject = proto.Field(proto.MESSAGE, number=1, message="Subject",) - - common_name = proto.Field(proto.STRING, number=2) - + common_name = proto.Field(proto.STRING, number=2,) subject_alt_name = proto.Field( proto.MESSAGE, number=3, message="SubjectAltNames", ) - - hex_serial_number = proto.Field(proto.STRING, number=4) - - lifetime = proto.Field(proto.MESSAGE, number=5, message=duration.Duration,) - + hex_serial_number = proto.Field(proto.STRING, number=4,) + lifetime = proto.Field(proto.MESSAGE, number=5, message=duration_pb2.Duration,) not_before_time = proto.Field( - proto.MESSAGE, number=6, message=timestamp.Timestamp, + proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp, ) - not_after_time = proto.Field( - proto.MESSAGE, number=7, message=timestamp.Timestamp, + proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp, ) class KeyId(proto.Message): @@ -1107,37 +1034,29 @@ class KeyId(proto.Message): 160 bit SHA-1 hash of the public key. """ - key_id = proto.Field(proto.STRING, number=1) + key_id = proto.Field(proto.STRING, number=1,) class CertificateFingerprint(proto.Message): r"""A group of fingerprints for the x509 certificate. - Attributes: sha256_hash (str): The SHA 256 hash, encoded in hexadecimal, of the DER x509 certificate. """ - sha256_hash = proto.Field(proto.STRING, number=1) + sha256_hash = proto.Field(proto.STRING, number=1,) subject_description = proto.Field( proto.MESSAGE, number=1, message=SubjectDescription, ) - config_values = proto.Field( proto.MESSAGE, number=2, message="ReusableConfigValues", ) - public_key = proto.Field(proto.MESSAGE, number=3, message="PublicKey",) - subject_key_id = proto.Field(proto.MESSAGE, number=4, message=KeyId,) - authority_key_id = proto.Field(proto.MESSAGE, number=5, message=KeyId,) - - crl_distribution_points = proto.RepeatedField(proto.STRING, number=6) - - aia_issuing_certificate_urls = proto.RepeatedField(proto.STRING, number=7) - + crl_distribution_points = proto.RepeatedField(proto.STRING, number=6,) + aia_issuing_certificate_urls = proto.RepeatedField(proto.STRING, number=7,) cert_fingerprint = proto.Field( proto.MESSAGE, number=8, message=CertificateFingerprint, ) @@ -1154,7 +1073,7 @@ class ObjectId(proto.Message): significant parts of the path come first. """ - object_id_path = proto.RepeatedField(proto.INT32, number=1) + object_id_path = proto.RepeatedField(proto.INT32, number=1,) class X509Extension(proto.Message): @@ -1176,10 +1095,8 @@ class X509Extension(proto.Message): """ object_id = proto.Field(proto.MESSAGE, number=1, message="ObjectId",) - - critical = proto.Field(proto.BOOL, number=2) - - value = proto.Field(proto.BYTES, number=3) + critical = proto.Field(proto.BOOL, number=2,) + value = proto.Field(proto.BYTES, number=3,) class KeyUsage(proto.Message): @@ -1230,23 +1147,15 @@ class KeyUsageOptions(proto.Message): The key may be used to decipher only. """ - digital_signature = proto.Field(proto.BOOL, number=1) - - content_commitment = proto.Field(proto.BOOL, number=2) - - key_encipherment = proto.Field(proto.BOOL, number=3) - - data_encipherment = proto.Field(proto.BOOL, number=4) - - key_agreement = proto.Field(proto.BOOL, number=5) - - cert_sign = proto.Field(proto.BOOL, number=6) - - crl_sign = proto.Field(proto.BOOL, number=7) - - encipher_only = proto.Field(proto.BOOL, number=8) - - decipher_only = proto.Field(proto.BOOL, number=9) + digital_signature = proto.Field(proto.BOOL, number=1,) + content_commitment = proto.Field(proto.BOOL, number=2,) + key_encipherment = proto.Field(proto.BOOL, number=3,) + data_encipherment = proto.Field(proto.BOOL, number=4,) + key_agreement = proto.Field(proto.BOOL, number=5,) + cert_sign = proto.Field(proto.BOOL, number=6,) + crl_sign = proto.Field(proto.BOOL, number=7,) + encipher_only = proto.Field(proto.BOOL, number=8,) + decipher_only = proto.Field(proto.BOOL, number=9,) class ExtendedKeyUsageOptions(proto.Message): r"""[KeyUsage.ExtendedKeyUsageOptions][google.cloud.security.privateca.v1beta1.KeyUsage.ExtendedKeyUsageOptions] @@ -1281,24 +1190,17 @@ class ExtendedKeyUsageOptions(proto.Message): responses". """ - server_auth = proto.Field(proto.BOOL, number=1) - - client_auth = proto.Field(proto.BOOL, number=2) - - code_signing = proto.Field(proto.BOOL, number=3) - - email_protection = proto.Field(proto.BOOL, number=4) - - time_stamping = proto.Field(proto.BOOL, number=5) - - ocsp_signing = proto.Field(proto.BOOL, number=6) + server_auth = proto.Field(proto.BOOL, number=1,) + client_auth = proto.Field(proto.BOOL, number=2,) + code_signing = proto.Field(proto.BOOL, number=3,) + email_protection = proto.Field(proto.BOOL, number=4,) + time_stamping = proto.Field(proto.BOOL, number=5,) + ocsp_signing = proto.Field(proto.BOOL, number=6,) base_key_usage = proto.Field(proto.MESSAGE, number=1, message=KeyUsageOptions,) - extended_key_usage = proto.Field( proto.MESSAGE, number=2, message=ExtendedKeyUsageOptions, ) - unknown_extended_key_usages = proto.RepeatedField( proto.MESSAGE, number=3, message="ObjectId", ) @@ -1327,19 +1229,13 @@ class Subject(proto.Message): The postal code of the subject. """ - country_code = proto.Field(proto.STRING, number=1) - - organization = proto.Field(proto.STRING, number=2) - - organizational_unit = proto.Field(proto.STRING, number=3) - - locality = proto.Field(proto.STRING, number=4) - - province = proto.Field(proto.STRING, number=5) - - street_address = proto.Field(proto.STRING, number=6) - - postal_code = proto.Field(proto.STRING, number=7) + country_code = proto.Field(proto.STRING, number=1,) + organization = proto.Field(proto.STRING, number=2,) + organizational_unit = proto.Field(proto.STRING, number=3,) + locality = proto.Field(proto.STRING, number=4,) + province = proto.Field(proto.STRING, number=5,) + street_address = proto.Field(proto.STRING, number=6,) + postal_code = proto.Field(proto.STRING, number=7,) class SubjectAltNames(proto.Message): @@ -1365,14 +1261,10 @@ class SubjectAltNames(proto.Message): values. """ - dns_names = proto.RepeatedField(proto.STRING, number=1) - - uris = proto.RepeatedField(proto.STRING, number=2) - - email_addresses = proto.RepeatedField(proto.STRING, number=3) - - ip_addresses = proto.RepeatedField(proto.STRING, number=4) - + dns_names = proto.RepeatedField(proto.STRING, number=1,) + uris = proto.RepeatedField(proto.STRING, number=2,) + email_addresses = proto.RepeatedField(proto.STRING, number=3,) + ip_addresses = proto.RepeatedField(proto.STRING, number=4,) custom_sans = proto.RepeatedField(proto.MESSAGE, number=5, message="X509Extension",) diff --git a/google/cloud/security/privateca_v1beta1/types/service.py b/google/cloud/security/privateca_v1beta1/types/service.py index 1c5977c..8296e84 100644 --- a/google/cloud/security/privateca_v1beta1/types/service.py +++ b/google/cloud/security/privateca_v1beta1/types/service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.security.privateca_v1beta1.types import resources -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -101,13 +98,10 @@ class CreateCertificateRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - parent = proto.Field(proto.STRING, number=1) - - certificate_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + certificate_id = proto.Field(proto.STRING, number=2,) certificate = proto.Field(proto.MESSAGE, number=3, message=resources.Certificate,) - - request_id = proto.Field(proto.STRING, number=4) + request_id = proto.Field(proto.STRING, number=4,) class GetCertificateRequest(proto.Message): @@ -123,7 +117,7 @@ class GetCertificateRequest(proto.Message): to get. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListCertificatesRequest(proto.Message): @@ -161,15 +155,11 @@ class ListCertificatesRequest(proto.Message): documentation `__. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListCertificatesResponse(proto.Message): @@ -196,10 +186,8 @@ def raw_page(self): certificates = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.Certificate, ) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable = proto.RepeatedField(proto.STRING, number=3,) class RevokeCertificateRequest(proto.Message): @@ -237,11 +225,9 @@ class RevokeCertificateRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) reason = proto.Field(proto.ENUM, number=2, enum=resources.RevocationReason,) - - request_id = proto.Field(proto.STRING, number=3) + request_id = proto.Field(proto.STRING, number=3,) class UpdateCertificateRequest(proto.Message): @@ -278,10 +264,10 @@ class UpdateCertificateRequest(proto.Message): """ certificate = proto.Field(proto.MESSAGE, number=1, message=resources.Certificate,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - request_id = proto.Field(proto.STRING, number=3) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field(proto.STRING, number=3,) class ActivateCertificateAuthorityRequest(proto.Message): @@ -322,15 +308,12 @@ class ActivateCertificateAuthorityRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - - pem_ca_certificate = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + pem_ca_certificate = proto.Field(proto.STRING, number=2,) subordinate_config = proto.Field( proto.MESSAGE, number=3, message=resources.SubordinateConfig, ) - - request_id = proto.Field(proto.STRING, number=4) + request_id = proto.Field(proto.STRING, number=4,) class CreateCertificateAuthorityRequest(proto.Message): @@ -371,15 +354,12 @@ class CreateCertificateAuthorityRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - parent = proto.Field(proto.STRING, number=1) - - certificate_authority_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + certificate_authority_id = proto.Field(proto.STRING, number=2,) certificate_authority = proto.Field( proto.MESSAGE, number=3, message=resources.CertificateAuthority, ) - - request_id = proto.Field(proto.STRING, number=4) + request_id = proto.Field(proto.STRING, number=4,) class DisableCertificateAuthorityRequest(proto.Message): @@ -413,9 +393,8 @@ class DisableCertificateAuthorityRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - - request_id = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + request_id = proto.Field(proto.STRING, number=2,) class EnableCertificateAuthorityRequest(proto.Message): @@ -449,9 +428,8 @@ class EnableCertificateAuthorityRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - - request_id = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + request_id = proto.Field(proto.STRING, number=2,) class FetchCertificateAuthorityCsrRequest(proto.Message): @@ -466,7 +444,7 @@ class FetchCertificateAuthorityCsrRequest(proto.Message): ``projects/*/locations/*/certificateAuthorities/*``. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class FetchCertificateAuthorityCsrResponse(proto.Message): @@ -479,7 +457,7 @@ class FetchCertificateAuthorityCsrResponse(proto.Message): certificate signing request (CSR). """ - pem_csr = proto.Field(proto.STRING, number=1) + pem_csr = proto.Field(proto.STRING, number=1,) class GetCertificateAuthorityRequest(proto.Message): @@ -495,7 +473,7 @@ class GetCertificateAuthorityRequest(proto.Message): to get. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListCertificateAuthoritiesRequest(proto.Message): @@ -528,15 +506,11 @@ class ListCertificateAuthoritiesRequest(proto.Message): sorted. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListCertificateAuthoritiesResponse(proto.Message): @@ -563,10 +537,8 @@ def raw_page(self): certificate_authorities = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.CertificateAuthority, ) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable = proto.RepeatedField(proto.STRING, number=3,) class RestoreCertificateAuthorityRequest(proto.Message): @@ -600,9 +572,8 @@ class RestoreCertificateAuthorityRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - - request_id = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + request_id = proto.Field(proto.STRING, number=2,) class ScheduleDeleteCertificateAuthorityRequest(proto.Message): @@ -636,9 +607,8 @@ class ScheduleDeleteCertificateAuthorityRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1) - - request_id = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + request_id = proto.Field(proto.STRING, number=2,) class UpdateCertificateAuthorityRequest(proto.Message): @@ -677,10 +647,10 @@ class UpdateCertificateAuthorityRequest(proto.Message): certificate_authority = proto.Field( proto.MESSAGE, number=1, message=resources.CertificateAuthority, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - request_id = proto.Field(proto.STRING, number=3) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field(proto.STRING, number=3,) class GetCertificateRevocationListRequest(proto.Message): @@ -696,7 +666,7 @@ class GetCertificateRevocationListRequest(proto.Message): to get. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListCertificateRevocationListsRequest(proto.Message): @@ -730,15 +700,11 @@ class ListCertificateRevocationListsRequest(proto.Message): sorted. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListCertificateRevocationListsResponse(proto.Message): @@ -765,10 +731,8 @@ def raw_page(self): certificate_revocation_lists = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.CertificateRevocationList, ) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable = proto.RepeatedField(proto.STRING, number=3,) class UpdateCertificateRevocationListRequest(proto.Message): @@ -807,10 +771,10 @@ class UpdateCertificateRevocationListRequest(proto.Message): certificate_revocation_list = proto.Field( proto.MESSAGE, number=1, message=resources.CertificateRevocationList, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - request_id = proto.Field(proto.STRING, number=3) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + request_id = proto.Field(proto.STRING, number=3,) class GetReusableConfigRequest(proto.Message): @@ -823,7 +787,7 @@ class GetReusableConfigRequest(proto.Message): [ReusableConfigs][] to get. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListReusableConfigsRequest(proto.Message): @@ -856,15 +820,11 @@ class ListReusableConfigsRequest(proto.Message): sorted. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListReusableConfigsResponse(proto.Message): @@ -891,15 +851,12 @@ def raw_page(self): reusable_configs = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.ReusableConfig, ) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable = proto.RepeatedField(proto.STRING, number=3,) class OperationMetadata(proto.Message): r"""Represents the metadata of the long-running operation. - Attributes: create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The time the operation was @@ -927,19 +884,13 @@ class OperationMetadata(proto.Message): operation. """ - create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - target = proto.Field(proto.STRING, number=3) - - verb = proto.Field(proto.STRING, number=4) - - status_message = proto.Field(proto.STRING, number=5) - - requested_cancellation = proto.Field(proto.BOOL, number=6) - - api_version = proto.Field(proto.STRING, number=7) + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + target = proto.Field(proto.STRING, number=3,) + verb = proto.Field(proto.STRING, number=4,) + status_message = proto.Field(proto.STRING, number=5,) + requested_cancellation = proto.Field(proto.BOOL, number=6,) + api_version = proto.Field(proto.STRING, number=7,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/MANIFEST.in b/owl-bot-staging/v1/MANIFEST.in deleted file mode 100644 index 3b6449c..0000000 --- a/owl-bot-staging/v1/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/security/privateca *.py -recursive-include google/cloud/security/privateca_v1 *.py diff --git a/owl-bot-staging/v1/README.rst b/owl-bot-staging/v1/README.rst deleted file mode 100644 index d1e676b..0000000 --- a/owl-bot-staging/v1/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Security Privateca 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 Security Privateca API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1/docs/conf.py b/owl-bot-staging/v1/docs/conf.py deleted file mode 100644 index a29fc06..0000000 --- a/owl-bot-staging/v1/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# google-cloud-security-privateca documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "1.6.3" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = "index" - -# General information about the project. -project = u"google-cloud-security-privateca" -copyright = u"2020, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Security 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-security-privateca-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - master_doc, - "google-cloud-security-privateca.tex", - u"google-cloud-security-privateca Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - master_doc, - "google-cloud-security-privateca", - u"Google Cloud Security Privateca Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - master_doc, - "google-cloud-security-privateca", - u"google-cloud-security-privateca Documentation", - author, - "google-cloud-security-privateca", - "GAPIC library for Google Cloud Security Privateca 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 eadcd6d..0000000 --- a/owl-bot-staging/v1/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - privateca_v1/services - privateca_v1/types diff --git a/owl-bot-staging/v1/docs/privateca_v1/certificate_authority_service.rst b/owl-bot-staging/v1/docs/privateca_v1/certificate_authority_service.rst deleted file mode 100644 index 00601bc..0000000 --- a/owl-bot-staging/v1/docs/privateca_v1/certificate_authority_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -CertificateAuthorityService ---------------------------------------------- - -.. automodule:: google.cloud.security.privateca_v1.services.certificate_authority_service - :members: - :inherited-members: - -.. automodule:: google.cloud.security.privateca_v1.services.certificate_authority_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v1/docs/privateca_v1/services.rst b/owl-bot-staging/v1/docs/privateca_v1/services.rst deleted file mode 100644 index 6b8d380..0000000 --- a/owl-bot-staging/v1/docs/privateca_v1/services.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Security Privateca v1 API -=================================================== -.. toctree:: - :maxdepth: 2 - - certificate_authority_service diff --git a/owl-bot-staging/v1/docs/privateca_v1/types.rst b/owl-bot-staging/v1/docs/privateca_v1/types.rst deleted file mode 100644 index 52719f3..0000000 --- a/owl-bot-staging/v1/docs/privateca_v1/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Security Privateca v1 API -================================================ - -.. automodule:: google.cloud.security.privateca_v1.types - :members: - :undoc-members: - :show-inheritance: diff --git a/owl-bot-staging/v1/google/cloud/security/privateca/__init__.py b/owl-bot-staging/v1/google/cloud/security/privateca/__init__.py deleted file mode 100644 index 6799d6e..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca/__init__.py +++ /dev/null @@ -1,135 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from google.cloud.security.privateca_v1.services.certificate_authority_service.client import CertificateAuthorityServiceClient -from google.cloud.security.privateca_v1.services.certificate_authority_service.async_client import CertificateAuthorityServiceAsyncClient - -from google.cloud.security.privateca_v1.types.resources import CaPool -from google.cloud.security.privateca_v1.types.resources import Certificate -from google.cloud.security.privateca_v1.types.resources import CertificateAuthority -from google.cloud.security.privateca_v1.types.resources import CertificateConfig -from google.cloud.security.privateca_v1.types.resources import CertificateDescription -from google.cloud.security.privateca_v1.types.resources import CertificateExtensionConstraints -from google.cloud.security.privateca_v1.types.resources import CertificateIdentityConstraints -from google.cloud.security.privateca_v1.types.resources import CertificateRevocationList -from google.cloud.security.privateca_v1.types.resources import CertificateTemplate -from google.cloud.security.privateca_v1.types.resources import KeyUsage -from google.cloud.security.privateca_v1.types.resources import ObjectId -from google.cloud.security.privateca_v1.types.resources import PublicKey -from google.cloud.security.privateca_v1.types.resources import Subject -from google.cloud.security.privateca_v1.types.resources import SubjectAltNames -from google.cloud.security.privateca_v1.types.resources import SubordinateConfig -from google.cloud.security.privateca_v1.types.resources import X509Extension -from google.cloud.security.privateca_v1.types.resources import X509Parameters -from google.cloud.security.privateca_v1.types.resources import RevocationReason -from google.cloud.security.privateca_v1.types.resources import SubjectRequestMode -from google.cloud.security.privateca_v1.types.service import ActivateCertificateAuthorityRequest -from google.cloud.security.privateca_v1.types.service import CreateCaPoolRequest -from google.cloud.security.privateca_v1.types.service import CreateCertificateAuthorityRequest -from google.cloud.security.privateca_v1.types.service import CreateCertificateRequest -from google.cloud.security.privateca_v1.types.service import CreateCertificateTemplateRequest -from google.cloud.security.privateca_v1.types.service import DeleteCaPoolRequest -from google.cloud.security.privateca_v1.types.service import DeleteCertificateAuthorityRequest -from google.cloud.security.privateca_v1.types.service import DeleteCertificateTemplateRequest -from google.cloud.security.privateca_v1.types.service import DisableCertificateAuthorityRequest -from google.cloud.security.privateca_v1.types.service import EnableCertificateAuthorityRequest -from google.cloud.security.privateca_v1.types.service import FetchCaCertsRequest -from google.cloud.security.privateca_v1.types.service import FetchCaCertsResponse -from google.cloud.security.privateca_v1.types.service import FetchCertificateAuthorityCsrRequest -from google.cloud.security.privateca_v1.types.service import FetchCertificateAuthorityCsrResponse -from google.cloud.security.privateca_v1.types.service import GetCaPoolRequest -from google.cloud.security.privateca_v1.types.service import GetCertificateAuthorityRequest -from google.cloud.security.privateca_v1.types.service import GetCertificateRequest -from google.cloud.security.privateca_v1.types.service import GetCertificateRevocationListRequest -from google.cloud.security.privateca_v1.types.service import GetCertificateTemplateRequest -from google.cloud.security.privateca_v1.types.service import ListCaPoolsRequest -from google.cloud.security.privateca_v1.types.service import ListCaPoolsResponse -from google.cloud.security.privateca_v1.types.service import ListCertificateAuthoritiesRequest -from google.cloud.security.privateca_v1.types.service import ListCertificateAuthoritiesResponse -from google.cloud.security.privateca_v1.types.service import ListCertificateRevocationListsRequest -from google.cloud.security.privateca_v1.types.service import ListCertificateRevocationListsResponse -from google.cloud.security.privateca_v1.types.service import ListCertificatesRequest -from google.cloud.security.privateca_v1.types.service import ListCertificatesResponse -from google.cloud.security.privateca_v1.types.service import ListCertificateTemplatesRequest -from google.cloud.security.privateca_v1.types.service import ListCertificateTemplatesResponse -from google.cloud.security.privateca_v1.types.service import OperationMetadata -from google.cloud.security.privateca_v1.types.service import RevokeCertificateRequest -from google.cloud.security.privateca_v1.types.service import UndeleteCertificateAuthorityRequest -from google.cloud.security.privateca_v1.types.service import UpdateCaPoolRequest -from google.cloud.security.privateca_v1.types.service import UpdateCertificateAuthorityRequest -from google.cloud.security.privateca_v1.types.service import UpdateCertificateRequest -from google.cloud.security.privateca_v1.types.service import UpdateCertificateRevocationListRequest -from google.cloud.security.privateca_v1.types.service import UpdateCertificateTemplateRequest - -__all__ = ('CertificateAuthorityServiceClient', - 'CertificateAuthorityServiceAsyncClient', - 'CaPool', - 'Certificate', - 'CertificateAuthority', - 'CertificateConfig', - 'CertificateDescription', - 'CertificateExtensionConstraints', - 'CertificateIdentityConstraints', - 'CertificateRevocationList', - 'CertificateTemplate', - 'KeyUsage', - 'ObjectId', - 'PublicKey', - 'Subject', - 'SubjectAltNames', - 'SubordinateConfig', - 'X509Extension', - 'X509Parameters', - 'RevocationReason', - 'SubjectRequestMode', - 'ActivateCertificateAuthorityRequest', - 'CreateCaPoolRequest', - 'CreateCertificateAuthorityRequest', - 'CreateCertificateRequest', - 'CreateCertificateTemplateRequest', - 'DeleteCaPoolRequest', - 'DeleteCertificateAuthorityRequest', - 'DeleteCertificateTemplateRequest', - 'DisableCertificateAuthorityRequest', - 'EnableCertificateAuthorityRequest', - 'FetchCaCertsRequest', - 'FetchCaCertsResponse', - 'FetchCertificateAuthorityCsrRequest', - 'FetchCertificateAuthorityCsrResponse', - 'GetCaPoolRequest', - 'GetCertificateAuthorityRequest', - 'GetCertificateRequest', - 'GetCertificateRevocationListRequest', - 'GetCertificateTemplateRequest', - 'ListCaPoolsRequest', - 'ListCaPoolsResponse', - 'ListCertificateAuthoritiesRequest', - 'ListCertificateAuthoritiesResponse', - 'ListCertificateRevocationListsRequest', - 'ListCertificateRevocationListsResponse', - 'ListCertificatesRequest', - 'ListCertificatesResponse', - 'ListCertificateTemplatesRequest', - 'ListCertificateTemplatesResponse', - 'OperationMetadata', - 'RevokeCertificateRequest', - 'UndeleteCertificateAuthorityRequest', - 'UpdateCaPoolRequest', - 'UpdateCertificateAuthorityRequest', - 'UpdateCertificateRequest', - 'UpdateCertificateRevocationListRequest', - 'UpdateCertificateTemplateRequest', -) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca/py.typed b/owl-bot-staging/v1/google/cloud/security/privateca/py.typed deleted file mode 100644 index 866f40f..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-security-privateca package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/__init__.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/__init__.py deleted file mode 100644 index 62f3fee..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/__init__.py +++ /dev/null @@ -1,136 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from .services.certificate_authority_service import CertificateAuthorityServiceClient -from .services.certificate_authority_service import CertificateAuthorityServiceAsyncClient - -from .types.resources import CaPool -from .types.resources import Certificate -from .types.resources import CertificateAuthority -from .types.resources import CertificateConfig -from .types.resources import CertificateDescription -from .types.resources import CertificateExtensionConstraints -from .types.resources import CertificateIdentityConstraints -from .types.resources import CertificateRevocationList -from .types.resources import CertificateTemplate -from .types.resources import KeyUsage -from .types.resources import ObjectId -from .types.resources import PublicKey -from .types.resources import Subject -from .types.resources import SubjectAltNames -from .types.resources import SubordinateConfig -from .types.resources import X509Extension -from .types.resources import X509Parameters -from .types.resources import RevocationReason -from .types.resources import SubjectRequestMode -from .types.service import ActivateCertificateAuthorityRequest -from .types.service import CreateCaPoolRequest -from .types.service import CreateCertificateAuthorityRequest -from .types.service import CreateCertificateRequest -from .types.service import CreateCertificateTemplateRequest -from .types.service import DeleteCaPoolRequest -from .types.service import DeleteCertificateAuthorityRequest -from .types.service import DeleteCertificateTemplateRequest -from .types.service import DisableCertificateAuthorityRequest -from .types.service import EnableCertificateAuthorityRequest -from .types.service import FetchCaCertsRequest -from .types.service import FetchCaCertsResponse -from .types.service import FetchCertificateAuthorityCsrRequest -from .types.service import FetchCertificateAuthorityCsrResponse -from .types.service import GetCaPoolRequest -from .types.service import GetCertificateAuthorityRequest -from .types.service import GetCertificateRequest -from .types.service import GetCertificateRevocationListRequest -from .types.service import GetCertificateTemplateRequest -from .types.service import ListCaPoolsRequest -from .types.service import ListCaPoolsResponse -from .types.service import ListCertificateAuthoritiesRequest -from .types.service import ListCertificateAuthoritiesResponse -from .types.service import ListCertificateRevocationListsRequest -from .types.service import ListCertificateRevocationListsResponse -from .types.service import ListCertificatesRequest -from .types.service import ListCertificatesResponse -from .types.service import ListCertificateTemplatesRequest -from .types.service import ListCertificateTemplatesResponse -from .types.service import OperationMetadata -from .types.service import RevokeCertificateRequest -from .types.service import UndeleteCertificateAuthorityRequest -from .types.service import UpdateCaPoolRequest -from .types.service import UpdateCertificateAuthorityRequest -from .types.service import UpdateCertificateRequest -from .types.service import UpdateCertificateRevocationListRequest -from .types.service import UpdateCertificateTemplateRequest - -__all__ = ( - 'CertificateAuthorityServiceAsyncClient', -'ActivateCertificateAuthorityRequest', -'CaPool', -'Certificate', -'CertificateAuthority', -'CertificateAuthorityServiceClient', -'CertificateConfig', -'CertificateDescription', -'CertificateExtensionConstraints', -'CertificateIdentityConstraints', -'CertificateRevocationList', -'CertificateTemplate', -'CreateCaPoolRequest', -'CreateCertificateAuthorityRequest', -'CreateCertificateRequest', -'CreateCertificateTemplateRequest', -'DeleteCaPoolRequest', -'DeleteCertificateAuthorityRequest', -'DeleteCertificateTemplateRequest', -'DisableCertificateAuthorityRequest', -'EnableCertificateAuthorityRequest', -'FetchCaCertsRequest', -'FetchCaCertsResponse', -'FetchCertificateAuthorityCsrRequest', -'FetchCertificateAuthorityCsrResponse', -'GetCaPoolRequest', -'GetCertificateAuthorityRequest', -'GetCertificateRequest', -'GetCertificateRevocationListRequest', -'GetCertificateTemplateRequest', -'KeyUsage', -'ListCaPoolsRequest', -'ListCaPoolsResponse', -'ListCertificateAuthoritiesRequest', -'ListCertificateAuthoritiesResponse', -'ListCertificateRevocationListsRequest', -'ListCertificateRevocationListsResponse', -'ListCertificateTemplatesRequest', -'ListCertificateTemplatesResponse', -'ListCertificatesRequest', -'ListCertificatesResponse', -'ObjectId', -'OperationMetadata', -'PublicKey', -'RevocationReason', -'RevokeCertificateRequest', -'Subject', -'SubjectAltNames', -'SubjectRequestMode', -'SubordinateConfig', -'UndeleteCertificateAuthorityRequest', -'UpdateCaPoolRequest', -'UpdateCertificateAuthorityRequest', -'UpdateCertificateRequest', -'UpdateCertificateRevocationListRequest', -'UpdateCertificateTemplateRequest', -'X509Extension', -'X509Parameters', -) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/py.typed b/owl-bot-staging/v1/google/cloud/security/privateca_v1/py.typed deleted file mode 100644 index 866f40f..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-security-privateca package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/__init__.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/__init__.py deleted file mode 100644 index 33b4459..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from .client import CertificateAuthorityServiceClient -from .async_client import CertificateAuthorityServiceAsyncClient - -__all__ = ( - 'CertificateAuthorityServiceClient', - 'CertificateAuthorityServiceAsyncClient', -) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py deleted file mode 100644 index 4221a97..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/async_client.py +++ /dev/null @@ -1,2874 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -import functools -import re -from typing import Dict, Sequence, Tuple, Type, Union -import pkg_resources - -import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.security.privateca_v1.services.certificate_authority_service import pagers -from google.cloud.security.privateca_v1.types import resources -from google.cloud.security.privateca_v1.types import service -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 CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport -from .client import CertificateAuthorityServiceClient - - -class CertificateAuthorityServiceAsyncClient: - """[Certificate Authority - Service][google.cloud.security.privateca.v1.CertificateAuthorityService] - manages private certificate authorities and issued certificates. - """ - - _client: CertificateAuthorityServiceClient - - DEFAULT_ENDPOINT = CertificateAuthorityServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = CertificateAuthorityServiceClient.DEFAULT_MTLS_ENDPOINT - - ca_pool_path = staticmethod(CertificateAuthorityServiceClient.ca_pool_path) - parse_ca_pool_path = staticmethod(CertificateAuthorityServiceClient.parse_ca_pool_path) - certificate_path = staticmethod(CertificateAuthorityServiceClient.certificate_path) - parse_certificate_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_path) - certificate_authority_path = staticmethod(CertificateAuthorityServiceClient.certificate_authority_path) - parse_certificate_authority_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_authority_path) - certificate_revocation_list_path = staticmethod(CertificateAuthorityServiceClient.certificate_revocation_list_path) - parse_certificate_revocation_list_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_revocation_list_path) - certificate_template_path = staticmethod(CertificateAuthorityServiceClient.certificate_template_path) - parse_certificate_template_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_template_path) - common_billing_account_path = staticmethod(CertificateAuthorityServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(CertificateAuthorityServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(CertificateAuthorityServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(CertificateAuthorityServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(CertificateAuthorityServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(CertificateAuthorityServiceClient.parse_common_organization_path) - common_project_path = staticmethod(CertificateAuthorityServiceClient.common_project_path) - parse_common_project_path = staticmethod(CertificateAuthorityServiceClient.parse_common_project_path) - common_location_path = staticmethod(CertificateAuthorityServiceClient.common_location_path) - parse_common_location_path = staticmethod(CertificateAuthorityServiceClient.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: - CertificateAuthorityServiceAsyncClient: The constructed client. - """ - return CertificateAuthorityServiceClient.from_service_account_info.__func__(CertificateAuthorityServiceAsyncClient, 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: - CertificateAuthorityServiceAsyncClient: The constructed client. - """ - return CertificateAuthorityServiceClient.from_service_account_file.__func__(CertificateAuthorityServiceAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> CertificateAuthorityServiceTransport: - """Returns the transport used by the client instance. - - Returns: - CertificateAuthorityServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(CertificateAuthorityServiceClient).get_transport_class, type(CertificateAuthorityServiceClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, CertificateAuthorityServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the certificate authority service client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ~.CertificateAuthorityServiceTransport]): 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 = CertificateAuthorityServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_certificate(self, - request: service.CreateCertificateRequest = None, - *, - parent: str = None, - certificate: resources.Certificate = None, - certificate_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Create a new - [Certificate][google.cloud.security.privateca.v1.Certificate] in - a given Project, Location from a particular - [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.CreateCertificateRequest`): - The request object. Request message for - [CertificateAuthorityService.CreateCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificate]. - parent (:class:`str`): - Required. The resource name of the - [CaPool][google.cloud.security.privateca.v1.CaPool] - associated with the - [Certificate][google.cloud.security.privateca.v1.Certificate], - in the format ``projects/*/locations/*/caPools/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate (:class:`google.cloud.security.privateca_v1.types.Certificate`): - Required. A - [Certificate][google.cloud.security.privateca.v1.Certificate] - with initial field values. - - This corresponds to the ``certificate`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_id (:class:`str`): - Optional. It must be unique within a location and match - the regular expression ``[a-zA-Z0-9_-]{1,63}``. This - field is required when using a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the Enterprise [CertificateAuthority.Tier][], but is - optional and its value is ignored otherwise. - - 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.cloud.security.privateca_v1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, 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 = service.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_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_certificate(self, - request: service.GetCertificateRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Returns a - [Certificate][google.cloud.security.privateca.v1.Certificate]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.GetCertificateRequest`): - The request object. Request message for - [CertificateAuthorityService.GetCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificate]. - name (:class:`str`): - Required. The - [name][google.cloud.security.privateca.v1.Certificate.name] - of the - [Certificate][google.cloud.security.privateca.v1.Certificate] - to get. - - 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.security.privateca_v1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.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_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_certificates(self, - request: service.ListCertificatesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificatesAsyncPager: - r"""Lists - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.ListCertificatesRequest`): - The request object. Request message for - [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificates]. - parent (:class:`str`): - Required. The resource name of the location associated - with the - [Certificates][google.cloud.security.privateca.v1.Certificate], - in the format ``projects/*/locations/*/caPools/*``. - - 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificatesAsyncPager: - Response message for - [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificates]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.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_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListCertificatesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def revoke_certificate(self, - request: service.RevokeCertificateRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Revoke a - [Certificate][google.cloud.security.privateca.v1.Certificate]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.RevokeCertificateRequest`): - The request object. Request message for - [CertificateAuthorityService.RevokeCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.RevokeCertificate]. - name (:class:`str`): - Required. The resource name for this - [Certificate][google.cloud.security.privateca.v1.Certificate] - in the format - ``projects/*/locations/*/caPools/*/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.security.privateca_v1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.RevokeCertificateRequest(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.revoke_certificate, - 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 update_certificate(self, - request: service.UpdateCertificateRequest = None, - *, - certificate: resources.Certificate = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Update a - [Certificate][google.cloud.security.privateca.v1.Certificate]. - Currently, the only field you can update is the - [labels][google.cloud.security.privateca.v1.Certificate.labels] - field. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.UpdateCertificateRequest`): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificate]. - certificate (:class:`google.cloud.security.privateca_v1.types.Certificate`): - Required. - [Certificate][google.cloud.security.privateca.v1.Certificate] - with updated values. - - 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. A list of fields to be - updated in this request. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.security.privateca_v1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([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 = service.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_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(( - ("certificate.name", request.certificate.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def activate_certificate_authority(self, - request: service.ActivateCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Activate a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that is in state - [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. - After the parent Certificate Authority signs a certificate - signing request from - [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr], - this method can complete the activation process. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.ActivateCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. - name (:class:`str`): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.ActivateCertificateAuthorityRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.activate_certificate_authority, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def create_certificate_authority(self, - request: service.CreateCertificateAuthorityRequest = None, - *, - parent: str = None, - certificate_authority: resources.CertificateAuthority = None, - certificate_authority_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Create a new - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in a given Project and Location. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.CreateCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.CreateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificateAuthority]. - parent (:class:`str`): - Required. The resource name of the - [CaPool][google.cloud.security.privateca.v1.CaPool] - associated with the - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority], - in the format ``projects/*/locations/*/caPools/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_authority (:class:`google.cloud.security.privateca_v1.types.CertificateAuthority`): - Required. A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - with initial field values. - - This corresponds to the ``certificate_authority`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_authority_id (:class:`str`): - Required. It must be unique within a location and match - the regular expression ``[a-zA-Z0-9_-]{1,63}`` - - This corresponds to the ``certificate_authority_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.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate_authority, certificate_authority_id]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.CreateCertificateAuthorityRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate_authority is not None: - request.certificate_authority = certificate_authority - if certificate_authority_id is not None: - request.certificate_authority_id = certificate_authority_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_authority, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def disable_certificate_authority(self, - request: service.DisableCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Disable a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.DisableCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.DisableCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.DisableCertificateAuthority]. - name (:class:`str`): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.DisableCertificateAuthorityRequest(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.disable_certificate_authority, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def enable_certificate_authority(self, - request: service.EnableCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Enable a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.EnableCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.EnableCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.EnableCertificateAuthority]. - name (:class:`str`): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.EnableCertificateAuthorityRequest(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.enable_certificate_authority, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def fetch_certificate_authority_csr(self, - request: service.FetchCertificateAuthorityCsrRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.FetchCertificateAuthorityCsrResponse: - r"""Fetch a certificate signing request (CSR) from a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that is in state - [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. - The CSR must then be signed by the desired parent Certificate - Authority, which could be another - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resource, or could be an on-prem certificate authority. See also - [ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.FetchCertificateAuthorityCsrRequest`): - The request object. Request message for - [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. - name (:class:`str`): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - 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.security.privateca_v1.types.FetchCertificateAuthorityCsrResponse: - Response message for - [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.FetchCertificateAuthorityCsrRequest(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.fetch_certificate_authority_csr, - 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_certificate_authority(self, - request: service.GetCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CertificateAuthority: - r"""Returns a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.GetCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.GetCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateAuthority]. - name (:class:`str`): - Required. The - [name][google.cloud.security.privateca.v1.CertificateAuthority.name] - of the - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - to get. - - 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.security.privateca_v1.types.CertificateAuthority: - A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.GetCertificateAuthorityRequest(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_authority, - 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_certificate_authorities(self, - request: service.ListCertificateAuthoritiesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateAuthoritiesAsyncPager: - r"""Lists - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesRequest`): - The request object. Request message for - [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateAuthorities]. - parent (:class:`str`): - Required. The resource name of the - [CaPool][google.cloud.security.privateca.v1.CaPool] - associated with the - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority], - in the format ``projects/*/locations/*/caPools/*``. - - 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesAsyncPager: - Response message for - [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateAuthorities]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.ListCertificateAuthoritiesRequest(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_authorities, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListCertificateAuthoritiesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def undelete_certificate_authority(self, - request: service.UndeleteCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Undelete a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that has been deleted. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.UndeleteCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.UndeleteCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.UndeleteCertificateAuthority]. - name (:class:`str`): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.UndeleteCertificateAuthorityRequest(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.undelete_certificate_authority, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_certificate_authority(self, - request: service.DeleteCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Delete a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.DeleteCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.DeleteCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCertificateAuthority]. - name (:class:`str`): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.DeleteCertificateAuthorityRequest(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_authority, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_certificate_authority(self, - request: service.UpdateCertificateAuthorityRequest = None, - *, - certificate_authority: resources.CertificateAuthority = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Update a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.UpdateCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateAuthority]. - certificate_authority (:class:`google.cloud.security.privateca_v1.types.CertificateAuthority`): - Required. - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - with updated values. - - This corresponds to the ``certificate_authority`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. A list of fields to be - updated in this request. - - 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.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_authority, update_mask]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.UpdateCertificateAuthorityRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_authority is not None: - request.certificate_authority = certificate_authority - 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_authority, - 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(( - ("certificate_authority.name", request.certificate_authority.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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def create_ca_pool(self, - request: service.CreateCaPoolRequest = None, - *, - parent: str = None, - ca_pool: resources.CaPool = None, - ca_pool_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.CreateCaPoolRequest`): - The request object. Request message for - [CertificateAuthorityService.CreateCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCaPool]. - parent (:class:`str`): - Required. The resource name of the location associated - with the - [CaPool][google.cloud.security.privateca.v1.CaPool], in - the format ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - ca_pool (:class:`google.cloud.security.privateca_v1.types.CaPool`): - Required. A - [CaPool][google.cloud.security.privateca.v1.CaPool] with - initial field values. - - This corresponds to the ``ca_pool`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - ca_pool_id (:class:`str`): - Required. It must be unique within a location and match - the regular expression ``[a-zA-Z0-9_-]{1,63}`` - - This corresponds to the ``ca_pool_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.security.privateca_v1.types.CaPool` A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] - that form a trust anchor. A - [CaPool][google.cloud.security.privateca.v1.CaPool] - can be used to manage issuance policies for one or - more - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources and to rotate CA certificates in and out of - the trust anchor. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, ca_pool, ca_pool_id]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.CreateCaPoolRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if ca_pool is not None: - request.ca_pool = ca_pool - if ca_pool_id is not None: - request.ca_pool_id = ca_pool_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_ca_pool, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CaPool, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_ca_pool(self, - request: service.UpdateCaPoolRequest = None, - *, - ca_pool: resources.CaPool = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.UpdateCaPoolRequest`): - The request object. Request message for - [CertificateAuthorityService.UpdateCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCaPool]. - ca_pool (:class:`google.cloud.security.privateca_v1.types.CaPool`): - Required. - [CaPool][google.cloud.security.privateca.v1.CaPool] with - updated values. - - This corresponds to the ``ca_pool`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. A list of fields to be - updated in this request. - - 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.security.privateca_v1.types.CaPool` A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] - that form a trust anchor. A - [CaPool][google.cloud.security.privateca.v1.CaPool] - can be used to manage issuance policies for one or - more - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources and to rotate CA certificates in and out of - the trust anchor. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([ca_pool, update_mask]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.UpdateCaPoolRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if ca_pool is not None: - request.ca_pool = ca_pool - 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_ca_pool, - 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(( - ("ca_pool.name", request.ca_pool.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, - resources.CaPool, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def get_ca_pool(self, - request: service.GetCaPoolRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CaPool: - r"""Returns a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.GetCaPoolRequest`): - The request object. Request message for - [CertificateAuthorityService.GetCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCaPool]. - name (:class:`str`): - Required. The - [name][google.cloud.security.privateca.v1.CaPool.name] - of the - [CaPool][google.cloud.security.privateca.v1.CaPool] to - get. - - 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.security.privateca_v1.types.CaPool: - A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] - that form a trust anchor. A - [CaPool][google.cloud.security.privateca.v1.CaPool] - can be used to manage issuance policies for one or - more - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources and to rotate CA certificates in and out of - the trust anchor. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.GetCaPoolRequest(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_ca_pool, - 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_ca_pools(self, - request: service.ListCaPoolsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCaPoolsAsyncPager: - r"""Lists [CaPools][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.ListCaPoolsRequest`): - The request object. Request message for - [CertificateAuthorityService.ListCaPools][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCaPools]. - parent (:class:`str`): - Required. The resource name of the location associated - with the - [CaPools][google.cloud.security.privateca.v1.CaPool], 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCaPoolsAsyncPager: - Response message for - [CertificateAuthorityService.ListCaPools][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCaPools]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.ListCaPoolsRequest(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_ca_pools, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListCaPoolsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_ca_pool(self, - request: service.DeleteCaPoolRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.DeleteCaPoolRequest`): - The request object. Request message for - [CertificateAuthorityService.DeleteCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCaPool]. - name (:class:`str`): - Required. The resource name for this - [CaPool][google.cloud.security.privateca.v1.CaPool] in - the format ``projects/*/locations/*/caPools/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CaPool` A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] - that form a trust anchor. A - [CaPool][google.cloud.security.privateca.v1.CaPool] - can be used to manage issuance policies for one or - more - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources and to rotate CA certificates in and out of - the trust anchor. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.DeleteCaPoolRequest(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_ca_pool, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CaPool, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def fetch_ca_certs(self, - request: service.FetchCaCertsRequest = None, - *, - ca_pool: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.FetchCaCertsResponse: - r"""FetchCaCerts returns the current trust anchor for the - [CaPool][google.cloud.security.privateca.v1.CaPool]. This will - include CA certificate chains for all ACTIVE - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources in the - [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.FetchCaCertsRequest`): - The request object. Request message for - [CertificateAuthorityService.FetchCaCerts][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCaCerts]. - ca_pool (:class:`str`): - Required. The resource name for the - [CaPool][google.cloud.security.privateca.v1.CaPool] in - the format ``projects/*/locations/*/caPools/*``. - - This corresponds to the ``ca_pool`` 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.security.privateca_v1.types.FetchCaCertsResponse: - Response message for - [CertificateAuthorityService.FetchCaCerts][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCaCerts]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([ca_pool]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.FetchCaCertsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if ca_pool is not None: - request.ca_pool = ca_pool - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.fetch_ca_certs, - 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(( - ("ca_pool", request.ca_pool), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_certificate_revocation_list(self, - request: service.GetCertificateRevocationListRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CertificateRevocationList: - r"""Returns a - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.GetCertificateRevocationListRequest`): - The request object. Request message for - [CertificateAuthorityService.GetCertificateRevocationList][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateRevocationList]. - name (:class:`str`): - Required. The - [name][google.cloud.security.privateca.v1.CertificateRevocationList.name] - of the - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] - to get. - - 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.security.privateca_v1.types.CertificateRevocationList: - A [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] corresponds to a signed X.509 certificate - Revocation List (CRL). A CRL contains the serial - numbers of certificates that should no longer be - trusted. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.GetCertificateRevocationListRequest(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_revocation_list, - 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_certificate_revocation_lists(self, - request: service.ListCertificateRevocationListsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateRevocationListsAsyncPager: - r"""Lists - [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.ListCertificateRevocationListsRequest`): - The request object. Request message for - [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateRevocationLists]. - parent (:class:`str`): - Required. The resource name of the location associated - with the - [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList], - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateRevocationListsAsyncPager: - Response message for - [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateRevocationLists]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.ListCertificateRevocationListsRequest(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_revocation_lists, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListCertificateRevocationListsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_certificate_revocation_list(self, - request: service.UpdateCertificateRevocationListRequest = None, - *, - certificate_revocation_list: resources.CertificateRevocationList = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Update a - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.UpdateCertificateRevocationListRequest`): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificateRevocationList][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateRevocationList]. - certificate_revocation_list (:class:`google.cloud.security.privateca_v1.types.CertificateRevocationList`): - Required. - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] - with updated values. - - This corresponds to the ``certificate_revocation_list`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. A list of fields to be - updated in this request. - - 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.security.privateca_v1.types.CertificateRevocationList` A [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] corresponds to a signed X.509 certificate - Revocation List (CRL). A CRL contains the serial - numbers of certificates that should no longer be - trusted. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_revocation_list, update_mask]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.UpdateCertificateRevocationListRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_revocation_list is not None: - request.certificate_revocation_list = certificate_revocation_list - 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_revocation_list, - 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(( - ("certificate_revocation_list.name", request.certificate_revocation_list.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, - resources.CertificateRevocationList, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def create_certificate_template(self, - request: service.CreateCertificateTemplateRequest = None, - *, - parent: str = None, - certificate_template: resources.CertificateTemplate = None, - certificate_template_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Create a new - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - in a given Project and Location. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.CreateCertificateTemplateRequest`): - The request object. Request message for - [CertificateAuthorityService.CreateCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificateTemplate]. - parent (:class:`str`): - Required. The resource name of the location associated - with the - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate], - 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_template (:class:`google.cloud.security.privateca_v1.types.CertificateTemplate`): - Required. A - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - with initial field values. - - This corresponds to the ``certificate_template`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_template_id (:class:`str`): - Required. It must be unique within a location and match - the regular expression ``[a-zA-Z0-9_-]{1,63}`` - - This corresponds to the ``certificate_template_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.security.privateca_v1.types.CertificateTemplate` A [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] refers to a managed template for certificate - issuance. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate_template, certificate_template_id]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.CreateCertificateTemplateRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate_template is not None: - request.certificate_template = certificate_template - if certificate_template_id is not None: - request.certificate_template_id = certificate_template_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_template, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateTemplate, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_certificate_template(self, - request: service.DeleteCertificateTemplateRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""DeleteCertificateTemplate deletes a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.DeleteCertificateTemplateRequest`): - The request object. Request message for - [CertificateAuthorityService.DeleteCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCertificateTemplate]. - name (:class:`str`): - Required. The resource name for this - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - in the format - ``projects/*/locations/*/certificateTemplates/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - The JSON representation for Empty is empty JSON - object {}. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.DeleteCertificateTemplateRequest(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_template, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def get_certificate_template(self, - request: service.GetCertificateTemplateRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CertificateTemplate: - r"""Returns a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.GetCertificateTemplateRequest`): - The request object. Request message for - [CertificateAuthorityService.GetCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateTemplate]. - name (:class:`str`): - Required. The - [name][google.cloud.security.privateca.v1.CertificateTemplate.name] - of the - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - to get. - - 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.security.privateca_v1.types.CertificateTemplate: - A [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] refers to a managed template for certificate - issuance. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.GetCertificateTemplateRequest(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_template, - 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_certificate_templates(self, - request: service.ListCertificateTemplatesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateTemplatesAsyncPager: - r"""Lists - [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.ListCertificateTemplatesRequest`): - The request object. Request message for - [CertificateAuthorityService.ListCertificateTemplates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateTemplates]. - parent (:class:`str`): - Required. The resource name of the location associated - with the - [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate], - 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateTemplatesAsyncPager: - Response message for - [CertificateAuthorityService.ListCertificateTemplates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateTemplates]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.ListCertificateTemplatesRequest(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_templates, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListCertificateTemplatesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_certificate_template(self, - request: service.UpdateCertificateTemplateRequest = None, - *, - certificate_template: resources.CertificateTemplate = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Update a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - - Args: - request (:class:`google.cloud.security.privateca_v1.types.UpdateCertificateTemplateRequest`): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateTemplate]. - certificate_template (:class:`google.cloud.security.privateca_v1.types.CertificateTemplate`): - Required. - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - with updated values. - - This corresponds to the ``certificate_template`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. A list of fields to be - updated in this request. - - 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.security.privateca_v1.types.CertificateTemplate` A [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] refers to a managed template for certificate - issuance. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_template, update_mask]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.UpdateCertificateTemplateRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_template is not None: - request.certificate_template = certificate_template - 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_template, - 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(( - ("certificate_template.name", request.certificate_template.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, - resources.CertificateTemplate, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - - - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-security-privateca", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "CertificateAuthorityServiceAsyncClient", -) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py deleted file mode 100644 index 74c7bae..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/client.py +++ /dev/null @@ -1,3097 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -from distutils import util -import os -import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources - -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.security.privateca_v1.services.certificate_authority_service import pagers -from google.cloud.security.privateca_v1.types import resources -from google.cloud.security.privateca_v1.types import service -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 CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import CertificateAuthorityServiceGrpcTransport -from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport - - -class CertificateAuthorityServiceClientMeta(type): - """Metaclass for the CertificateAuthorityService 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[CertificateAuthorityServiceTransport]] - _transport_registry["grpc"] = CertificateAuthorityServiceGrpcTransport - _transport_registry["grpc_asyncio"] = CertificateAuthorityServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[CertificateAuthorityServiceTransport]: - """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 CertificateAuthorityServiceClient(metaclass=CertificateAuthorityServiceClientMeta): - """[Certificate Authority - Service][google.cloud.security.privateca.v1.CertificateAuthorityService] - manages private certificate authorities and issued certificates. - """ - - @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 = "privateca.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: - CertificateAuthorityServiceClient: 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: - CertificateAuthorityServiceClient: 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) -> CertificateAuthorityServiceTransport: - """Returns the transport used by the client instance. - - Returns: - CertificateAuthorityServiceTransport: 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,ca_pool: str,certificate: str,) -> str: - """Returns a fully-qualified certificate string.""" - return "projects/{project}/locations/{location}/caPools/{ca_pool}/certificates/{certificate}".format(project=project, location=location, ca_pool=ca_pool, 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.+?)/caPools/(?P.+?)/certificates/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def certificate_authority_path(project: str,location: str,ca_pool: str,certificate_authority: str,) -> str: - """Returns a fully-qualified certificate_authority string.""" - return "projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}".format(project=project, location=location, ca_pool=ca_pool, certificate_authority=certificate_authority, ) - - @staticmethod - def parse_certificate_authority_path(path: str) -> Dict[str,str]: - """Parses a certificate_authority path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/caPools/(?P.+?)/certificateAuthorities/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def certificate_revocation_list_path(project: str,location: str,ca_pool: str,certificate_authority: str,certificate_revocation_list: str,) -> str: - """Returns a fully-qualified certificate_revocation_list string.""" - return "projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list}".format(project=project, location=location, ca_pool=ca_pool, certificate_authority=certificate_authority, certificate_revocation_list=certificate_revocation_list, ) - - @staticmethod - def parse_certificate_revocation_list_path(path: str) -> Dict[str,str]: - """Parses a certificate_revocation_list path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/caPools/(?P.+?)/certificateAuthorities/(?P.+?)/certificateRevocationLists/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def certificate_template_path(project: str,location: str,certificate_template: str,) -> str: - """Returns a fully-qualified certificate_template string.""" - return "projects/{project}/locations/{location}/certificateTemplates/{certificate_template}".format(project=project, location=location, certificate_template=certificate_template, ) - - @staticmethod - def parse_certificate_template_path(path: str) -> Dict[str,str]: - """Parses a certificate_template path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificateTemplates/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_billing_account_path(billing_account: str, ) -> str: - """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path(folder: str, ) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder, ) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str,str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path(organization: str, ) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization, ) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str,str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path(project: str, ) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project, ) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str,str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_location_path(project: str, location: str, ) -> str: - """Returns a fully-qualified location string.""" - return "projects/{project}/locations/{location}".format(project=project, location=location, ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, CertificateAuthorityServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the certificate authority service client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, CertificateAuthorityServiceTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) - if client_options is None: - client_options = client_options_lib.ClientOptions() - - # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) - - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - if isinstance(transport, CertificateAuthorityServiceTransport): - # transport is a CertificateAuthorityServiceTransport instance. - if credentials or client_options.credentials_file: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") - if client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = transport - else: - Transport = type(self).get_transport_class(transport) - self._transport = Transport( - credentials=credentials, - credentials_file=client_options.credentials_file, - host=api_endpoint, - scopes=client_options.scopes, - client_cert_source_for_mtls=client_cert_source_func, - quota_project_id=client_options.quota_project_id, - client_info=client_info, - ) - - def create_certificate(self, - request: service.CreateCertificateRequest = None, - *, - parent: str = None, - certificate: resources.Certificate = None, - certificate_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Create a new - [Certificate][google.cloud.security.privateca.v1.Certificate] in - a given Project, Location from a particular - [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (google.cloud.security.privateca_v1.types.CreateCertificateRequest): - The request object. Request message for - [CertificateAuthorityService.CreateCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificate]. - parent (str): - Required. The resource name of the - [CaPool][google.cloud.security.privateca.v1.CaPool] - associated with the - [Certificate][google.cloud.security.privateca.v1.Certificate], - in the format ``projects/*/locations/*/caPools/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate (google.cloud.security.privateca_v1.types.Certificate): - Required. A - [Certificate][google.cloud.security.privateca.v1.Certificate] - with initial field values. - - This corresponds to the ``certificate`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_id (str): - Optional. It must be unique within a location and match - the regular expression ``[a-zA-Z0-9_-]{1,63}``. This - field is required when using a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the Enterprise [CertificateAuthority.Tier][], but is - optional and its value is ignored otherwise. - - 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.cloud.security.privateca_v1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, 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 service.CreateCertificateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CreateCertificateRequest): - request = service.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, - ) - - # Done; return the response. - return response - - def get_certificate(self, - request: service.GetCertificateRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Returns a - [Certificate][google.cloud.security.privateca.v1.Certificate]. - - Args: - request (google.cloud.security.privateca_v1.types.GetCertificateRequest): - The request object. Request message for - [CertificateAuthorityService.GetCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificate]. - name (str): - Required. The - [name][google.cloud.security.privateca.v1.Certificate.name] - of the - [Certificate][google.cloud.security.privateca.v1.Certificate] - to get. - - 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.security.privateca_v1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.GetCertificateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetCertificateRequest): - request = service.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 list_certificates(self, - request: service.ListCertificatesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificatesPager: - r"""Lists - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - Args: - request (google.cloud.security.privateca_v1.types.ListCertificatesRequest): - The request object. Request message for - [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificates]. - parent (str): - Required. The resource name of the location associated - with the - [Certificates][google.cloud.security.privateca.v1.Certificate], - in the format ``projects/*/locations/*/caPools/*``. - - 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificatesPager: - Response message for - [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificates]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.ListCertificatesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListCertificatesRequest): - request = service.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 revoke_certificate(self, - request: service.RevokeCertificateRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Revoke a - [Certificate][google.cloud.security.privateca.v1.Certificate]. - - Args: - request (google.cloud.security.privateca_v1.types.RevokeCertificateRequest): - The request object. Request message for - [CertificateAuthorityService.RevokeCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.RevokeCertificate]. - name (str): - Required. The resource name for this - [Certificate][google.cloud.security.privateca.v1.Certificate] - in the format - ``projects/*/locations/*/caPools/*/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.security.privateca_v1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.RevokeCertificateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.RevokeCertificateRequest): - request = service.RevokeCertificateRequest(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.revoke_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 update_certificate(self, - request: service.UpdateCertificateRequest = None, - *, - certificate: resources.Certificate = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Update a - [Certificate][google.cloud.security.privateca.v1.Certificate]. - Currently, the only field you can update is the - [labels][google.cloud.security.privateca.v1.Certificate.labels] - field. - - Args: - request (google.cloud.security.privateca_v1.types.UpdateCertificateRequest): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificate]. - certificate (google.cloud.security.privateca_v1.types.Certificate): - Required. - [Certificate][google.cloud.security.privateca.v1.Certificate] - with updated values. - - 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. A list of fields to be - updated in this request. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.security.privateca_v1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([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 service.UpdateCertificateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UpdateCertificateRequest): - request = service.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, - ) - - # Done; return the response. - return response - - def activate_certificate_authority(self, - request: service.ActivateCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Activate a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that is in state - [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. - After the parent Certificate Authority signs a certificate - signing request from - [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr], - this method can complete the activation process. - - Args: - request (google.cloud.security.privateca_v1.types.ActivateCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.ActivateCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ActivateCertificateAuthorityRequest): - request = service.ActivateCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.activate_certificate_authority] - - # 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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def create_certificate_authority(self, - request: service.CreateCertificateAuthorityRequest = None, - *, - parent: str = None, - certificate_authority: resources.CertificateAuthority = None, - certificate_authority_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Create a new - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in a given Project and Location. - - Args: - request (google.cloud.security.privateca_v1.types.CreateCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.CreateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificateAuthority]. - parent (str): - Required. The resource name of the - [CaPool][google.cloud.security.privateca.v1.CaPool] - associated with the - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority], - in the format ``projects/*/locations/*/caPools/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_authority (google.cloud.security.privateca_v1.types.CertificateAuthority): - Required. A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - with initial field values. - - This corresponds to the ``certificate_authority`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_authority_id (str): - Required. It must be unique within a location and match - the regular expression ``[a-zA-Z0-9_-]{1,63}`` - - This corresponds to the ``certificate_authority_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.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate_authority, certificate_authority_id]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.CreateCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CreateCertificateAuthorityRequest): - request = service.CreateCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate_authority is not None: - request.certificate_authority = certificate_authority - if certificate_authority_id is not None: - request.certificate_authority_id = certificate_authority_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_certificate_authority] - - # 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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def disable_certificate_authority(self, - request: service.DisableCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Disable a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1.types.DisableCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.DisableCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.DisableCertificateAuthority]. - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.DisableCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.DisableCertificateAuthorityRequest): - request = service.DisableCertificateAuthorityRequest(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.disable_certificate_authority] - - # 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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def enable_certificate_authority(self, - request: service.EnableCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Enable a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1.types.EnableCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.EnableCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.EnableCertificateAuthority]. - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.EnableCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.EnableCertificateAuthorityRequest): - request = service.EnableCertificateAuthorityRequest(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.enable_certificate_authority] - - # 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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def fetch_certificate_authority_csr(self, - request: service.FetchCertificateAuthorityCsrRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.FetchCertificateAuthorityCsrResponse: - r"""Fetch a certificate signing request (CSR) from a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that is in state - [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. - The CSR must then be signed by the desired parent Certificate - Authority, which could be another - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resource, or could be an on-prem certificate authority. See also - [ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1.types.FetchCertificateAuthorityCsrRequest): - The request object. Request message for - [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - 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.security.privateca_v1.types.FetchCertificateAuthorityCsrResponse: - Response message for - [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.FetchCertificateAuthorityCsrRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.FetchCertificateAuthorityCsrRequest): - request = service.FetchCertificateAuthorityCsrRequest(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.fetch_certificate_authority_csr] - - # 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_certificate_authority(self, - request: service.GetCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CertificateAuthority: - r"""Returns a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1.types.GetCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.GetCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateAuthority]. - name (str): - Required. The - [name][google.cloud.security.privateca.v1.CertificateAuthority.name] - of the - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - to get. - - 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.security.privateca_v1.types.CertificateAuthority: - A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.GetCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetCertificateAuthorityRequest): - request = service.GetCertificateAuthorityRequest(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_authority] - - # 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_certificate_authorities(self, - request: service.ListCertificateAuthoritiesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateAuthoritiesPager: - r"""Lists - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesRequest): - The request object. Request message for - [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateAuthorities]. - parent (str): - Required. The resource name of the - [CaPool][google.cloud.security.privateca.v1.CaPool] - associated with the - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority], - in the format ``projects/*/locations/*/caPools/*``. - - 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesPager: - Response message for - [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateAuthorities]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.ListCertificateAuthoritiesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListCertificateAuthoritiesRequest): - request = service.ListCertificateAuthoritiesRequest(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_authorities] - - # 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.ListCertificateAuthoritiesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def undelete_certificate_authority(self, - request: service.UndeleteCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Undelete a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that has been deleted. - - Args: - request (google.cloud.security.privateca_v1.types.UndeleteCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.UndeleteCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.UndeleteCertificateAuthority]. - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.UndeleteCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UndeleteCertificateAuthorityRequest): - request = service.UndeleteCertificateAuthorityRequest(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.undelete_certificate_authority] - - # 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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_certificate_authority(self, - request: service.DeleteCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Delete a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1.types.DeleteCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.DeleteCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCertificateAuthority]. - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.DeleteCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.DeleteCertificateAuthorityRequest): - request = service.DeleteCertificateAuthorityRequest(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_authority] - - # 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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_certificate_authority(self, - request: service.UpdateCertificateAuthorityRequest = None, - *, - certificate_authority: resources.CertificateAuthority = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Update a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1.types.UpdateCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateAuthority]. - certificate_authority (google.cloud.security.privateca_v1.types.CertificateAuthority): - Required. - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - with updated values. - - This corresponds to the ``certificate_authority`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be - updated in this request. - - 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.security.privateca_v1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_authority, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.UpdateCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UpdateCertificateAuthorityRequest): - request = service.UpdateCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_authority is not None: - request.certificate_authority = certificate_authority - 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_authority] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("certificate_authority.name", request.certificate_authority.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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def create_ca_pool(self, - request: service.CreateCaPoolRequest = None, - *, - parent: str = None, - ca_pool: resources.CaPool = None, - ca_pool_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (google.cloud.security.privateca_v1.types.CreateCaPoolRequest): - The request object. Request message for - [CertificateAuthorityService.CreateCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCaPool]. - parent (str): - Required. The resource name of the location associated - with the - [CaPool][google.cloud.security.privateca.v1.CaPool], in - the format ``projects/*/locations/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - ca_pool (google.cloud.security.privateca_v1.types.CaPool): - Required. A - [CaPool][google.cloud.security.privateca.v1.CaPool] with - initial field values. - - This corresponds to the ``ca_pool`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - ca_pool_id (str): - Required. It must be unique within a location and match - the regular expression ``[a-zA-Z0-9_-]{1,63}`` - - This corresponds to the ``ca_pool_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.security.privateca_v1.types.CaPool` A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] - that form a trust anchor. A - [CaPool][google.cloud.security.privateca.v1.CaPool] - can be used to manage issuance policies for one or - more - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources and to rotate CA certificates in and out of - the trust anchor. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, ca_pool, ca_pool_id]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.CreateCaPoolRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CreateCaPoolRequest): - request = service.CreateCaPoolRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if ca_pool is not None: - request.ca_pool = ca_pool - if ca_pool_id is not None: - request.ca_pool_id = ca_pool_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_ca_pool] - - # 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, - resources.CaPool, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_ca_pool(self, - request: service.UpdateCaPoolRequest = None, - *, - ca_pool: resources.CaPool = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (google.cloud.security.privateca_v1.types.UpdateCaPoolRequest): - The request object. Request message for - [CertificateAuthorityService.UpdateCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCaPool]. - ca_pool (google.cloud.security.privateca_v1.types.CaPool): - Required. - [CaPool][google.cloud.security.privateca.v1.CaPool] with - updated values. - - This corresponds to the ``ca_pool`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be - updated in this request. - - 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.security.privateca_v1.types.CaPool` A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] - that form a trust anchor. A - [CaPool][google.cloud.security.privateca.v1.CaPool] - can be used to manage issuance policies for one or - more - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources and to rotate CA certificates in and out of - the trust anchor. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([ca_pool, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.UpdateCaPoolRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UpdateCaPoolRequest): - request = service.UpdateCaPoolRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if ca_pool is not None: - request.ca_pool = ca_pool - 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_ca_pool] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("ca_pool.name", request.ca_pool.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, - resources.CaPool, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def get_ca_pool(self, - request: service.GetCaPoolRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CaPool: - r"""Returns a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (google.cloud.security.privateca_v1.types.GetCaPoolRequest): - The request object. Request message for - [CertificateAuthorityService.GetCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCaPool]. - name (str): - Required. The - [name][google.cloud.security.privateca.v1.CaPool.name] - of the - [CaPool][google.cloud.security.privateca.v1.CaPool] to - get. - - 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.security.privateca_v1.types.CaPool: - A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] - that form a trust anchor. A - [CaPool][google.cloud.security.privateca.v1.CaPool] - can be used to manage issuance policies for one or - more - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources and to rotate CA certificates in and out of - the trust anchor. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.GetCaPoolRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetCaPoolRequest): - request = service.GetCaPoolRequest(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_ca_pool] - - # 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_ca_pools(self, - request: service.ListCaPoolsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCaPoolsPager: - r"""Lists [CaPools][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (google.cloud.security.privateca_v1.types.ListCaPoolsRequest): - The request object. Request message for - [CertificateAuthorityService.ListCaPools][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCaPools]. - parent (str): - Required. The resource name of the location associated - with the - [CaPools][google.cloud.security.privateca.v1.CaPool], 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCaPoolsPager: - Response message for - [CertificateAuthorityService.ListCaPools][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCaPools]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.ListCaPoolsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListCaPoolsRequest): - request = service.ListCaPoolsRequest(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_ca_pools] - - # 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.ListCaPoolsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_ca_pool(self, - request: service.DeleteCaPoolRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (google.cloud.security.privateca_v1.types.DeleteCaPoolRequest): - The request object. Request message for - [CertificateAuthorityService.DeleteCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCaPool]. - name (str): - Required. The resource name for this - [CaPool][google.cloud.security.privateca.v1.CaPool] in - the format ``projects/*/locations/*/caPools/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1.types.CaPool` A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a group of - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] - that form a trust anchor. A - [CaPool][google.cloud.security.privateca.v1.CaPool] - can be used to manage issuance policies for one or - more - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources and to rotate CA certificates in and out of - the trust anchor. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.DeleteCaPoolRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.DeleteCaPoolRequest): - request = service.DeleteCaPoolRequest(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_ca_pool] - - # 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, - resources.CaPool, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def fetch_ca_certs(self, - request: service.FetchCaCertsRequest = None, - *, - ca_pool: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.FetchCaCertsResponse: - r"""FetchCaCerts returns the current trust anchor for the - [CaPool][google.cloud.security.privateca.v1.CaPool]. This will - include CA certificate chains for all ACTIVE - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources in the - [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Args: - request (google.cloud.security.privateca_v1.types.FetchCaCertsRequest): - The request object. Request message for - [CertificateAuthorityService.FetchCaCerts][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCaCerts]. - ca_pool (str): - Required. The resource name for the - [CaPool][google.cloud.security.privateca.v1.CaPool] in - the format ``projects/*/locations/*/caPools/*``. - - This corresponds to the ``ca_pool`` 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.security.privateca_v1.types.FetchCaCertsResponse: - Response message for - [CertificateAuthorityService.FetchCaCerts][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCaCerts]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([ca_pool]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.FetchCaCertsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.FetchCaCertsRequest): - request = service.FetchCaCertsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if ca_pool is not None: - request.ca_pool = ca_pool - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.fetch_ca_certs] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("ca_pool", request.ca_pool), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_certificate_revocation_list(self, - request: service.GetCertificateRevocationListRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CertificateRevocationList: - r"""Returns a - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. - - Args: - request (google.cloud.security.privateca_v1.types.GetCertificateRevocationListRequest): - The request object. Request message for - [CertificateAuthorityService.GetCertificateRevocationList][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateRevocationList]. - name (str): - Required. The - [name][google.cloud.security.privateca.v1.CertificateRevocationList.name] - of the - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] - to get. - - 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.security.privateca_v1.types.CertificateRevocationList: - A [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] corresponds to a signed X.509 certificate - Revocation List (CRL). A CRL contains the serial - numbers of certificates that should no longer be - trusted. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.GetCertificateRevocationListRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetCertificateRevocationListRequest): - request = service.GetCertificateRevocationListRequest(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_revocation_list] - - # 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_certificate_revocation_lists(self, - request: service.ListCertificateRevocationListsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateRevocationListsPager: - r"""Lists - [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. - - Args: - request (google.cloud.security.privateca_v1.types.ListCertificateRevocationListsRequest): - The request object. Request message for - [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateRevocationLists]. - parent (str): - Required. The resource name of the location associated - with the - [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList], - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - - 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateRevocationListsPager: - Response message for - [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateRevocationLists]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.ListCertificateRevocationListsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListCertificateRevocationListsRequest): - request = service.ListCertificateRevocationListsRequest(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_revocation_lists] - - # 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.ListCertificateRevocationListsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_certificate_revocation_list(self, - request: service.UpdateCertificateRevocationListRequest = None, - *, - certificate_revocation_list: resources.CertificateRevocationList = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Update a - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. - - Args: - request (google.cloud.security.privateca_v1.types.UpdateCertificateRevocationListRequest): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificateRevocationList][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateRevocationList]. - certificate_revocation_list (google.cloud.security.privateca_v1.types.CertificateRevocationList): - Required. - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] - with updated values. - - This corresponds to the ``certificate_revocation_list`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be - updated in this request. - - 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.security.privateca_v1.types.CertificateRevocationList` A [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] corresponds to a signed X.509 certificate - Revocation List (CRL). A CRL contains the serial - numbers of certificates that should no longer be - trusted. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_revocation_list, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.UpdateCertificateRevocationListRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UpdateCertificateRevocationListRequest): - request = service.UpdateCertificateRevocationListRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_revocation_list is not None: - request.certificate_revocation_list = certificate_revocation_list - 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_revocation_list] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("certificate_revocation_list.name", request.certificate_revocation_list.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, - resources.CertificateRevocationList, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def create_certificate_template(self, - request: service.CreateCertificateTemplateRequest = None, - *, - parent: str = None, - certificate_template: resources.CertificateTemplate = None, - certificate_template_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Create a new - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - in a given Project and Location. - - Args: - request (google.cloud.security.privateca_v1.types.CreateCertificateTemplateRequest): - The request object. Request message for - [CertificateAuthorityService.CreateCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificateTemplate]. - parent (str): - Required. The resource name of the location associated - with the - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate], - 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_template (google.cloud.security.privateca_v1.types.CertificateTemplate): - Required. A - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - with initial field values. - - This corresponds to the ``certificate_template`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_template_id (str): - Required. It must be unique within a location and match - the regular expression ``[a-zA-Z0-9_-]{1,63}`` - - This corresponds to the ``certificate_template_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.security.privateca_v1.types.CertificateTemplate` A [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] refers to a managed template for certificate - issuance. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate_template, certificate_template_id]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.CreateCertificateTemplateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CreateCertificateTemplateRequest): - request = service.CreateCertificateTemplateRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate_template is not None: - request.certificate_template = certificate_template - if certificate_template_id is not None: - request.certificate_template_id = certificate_template_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_certificate_template] - - # 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, - resources.CertificateTemplate, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_certificate_template(self, - request: service.DeleteCertificateTemplateRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""DeleteCertificateTemplate deletes a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - - Args: - request (google.cloud.security.privateca_v1.types.DeleteCertificateTemplateRequest): - The request object. Request message for - [CertificateAuthorityService.DeleteCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCertificateTemplate]. - name (str): - Required. The resource name for this - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - in the format - ``projects/*/locations/*/certificateTemplates/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - The JSON representation for Empty is empty JSON - object {}. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.DeleteCertificateTemplateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.DeleteCertificateTemplateRequest): - request = service.DeleteCertificateTemplateRequest(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_template] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def get_certificate_template(self, - request: service.GetCertificateTemplateRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CertificateTemplate: - r"""Returns a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - - Args: - request (google.cloud.security.privateca_v1.types.GetCertificateTemplateRequest): - The request object. Request message for - [CertificateAuthorityService.GetCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateTemplate]. - name (str): - Required. The - [name][google.cloud.security.privateca.v1.CertificateTemplate.name] - of the - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - to get. - - 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.security.privateca_v1.types.CertificateTemplate: - A [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] refers to a managed template for certificate - issuance. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.GetCertificateTemplateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetCertificateTemplateRequest): - request = service.GetCertificateTemplateRequest(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_template] - - # 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_certificate_templates(self, - request: service.ListCertificateTemplatesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateTemplatesPager: - r"""Lists - [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. - - Args: - request (google.cloud.security.privateca_v1.types.ListCertificateTemplatesRequest): - The request object. Request message for - [CertificateAuthorityService.ListCertificateTemplates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateTemplates]. - parent (str): - Required. The resource name of the location associated - with the - [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate], - 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.security.privateca_v1.services.certificate_authority_service.pagers.ListCertificateTemplatesPager: - Response message for - [CertificateAuthorityService.ListCertificateTemplates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateTemplates]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.ListCertificateTemplatesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListCertificateTemplatesRequest): - request = service.ListCertificateTemplatesRequest(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_templates] - - # 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.ListCertificateTemplatesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_certificate_template(self, - request: service.UpdateCertificateTemplateRequest = None, - *, - certificate_template: resources.CertificateTemplate = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Update a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - - Args: - request (google.cloud.security.privateca_v1.types.UpdateCertificateTemplateRequest): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateTemplate]. - certificate_template (google.cloud.security.privateca_v1.types.CertificateTemplate): - Required. - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - with updated values. - - This corresponds to the ``certificate_template`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be - updated in this request. - - 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.security.privateca_v1.types.CertificateTemplate` A [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] refers to a managed template for certificate - issuance. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_template, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.UpdateCertificateTemplateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UpdateCertificateTemplateRequest): - request = service.UpdateCertificateTemplateRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_template is not None: - request.certificate_template = certificate_template - 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_template] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("certificate_template.name", request.certificate_template.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, - resources.CertificateTemplate, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - - - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-security-privateca", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "CertificateAuthorityServiceClient", -) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py deleted file mode 100644 index ae535cb..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/pagers.py +++ /dev/null @@ -1,629 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional - -from google.cloud.security.privateca_v1.types import resources -from google.cloud.security.privateca_v1.types import service - - -class ListCertificatesPager: - """A pager for iterating through ``list_certificates`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_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.security.privateca_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[..., service.ListCertificatesResponse], - request: service.ListCertificatesRequest, - response: service.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.security.privateca_v1.types.ListCertificatesRequest): - The initial request object. - response (google.cloud.security.privateca_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 = service.ListCertificatesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[service.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) -> Iterable[resources.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.security.privateca_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.security.privateca_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[service.ListCertificatesResponse]], - request: service.ListCertificatesRequest, - response: service.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.security.privateca_v1.types.ListCertificatesRequest): - The initial request object. - response (google.cloud.security.privateca_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 = service.ListCertificatesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[service.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) -> AsyncIterable[resources.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 ListCertificateAuthoritiesPager: - """A pager for iterating through ``list_certificate_authorities`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``certificate_authorities`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCertificateAuthorities`` requests and continue to iterate - through the ``certificate_authorities`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., service.ListCertificateAuthoritiesResponse], - request: service.ListCertificateAuthoritiesRequest, - response: service.ListCertificateAuthoritiesResponse, - *, - 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.security.privateca_v1.types.ListCertificateAuthoritiesRequest): - The initial request object. - response (google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListCertificateAuthoritiesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[service.ListCertificateAuthoritiesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.CertificateAuthority]: - for page in self.pages: - yield from page.certificate_authorities - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateAuthoritiesAsyncPager: - """A pager for iterating through ``list_certificate_authorities`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``certificate_authorities`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCertificateAuthorities`` requests and continue to iterate - through the ``certificate_authorities`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., Awaitable[service.ListCertificateAuthoritiesResponse]], - request: service.ListCertificateAuthoritiesRequest, - response: service.ListCertificateAuthoritiesResponse, - *, - 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.security.privateca_v1.types.ListCertificateAuthoritiesRequest): - The initial request object. - response (google.cloud.security.privateca_v1.types.ListCertificateAuthoritiesResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListCertificateAuthoritiesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[service.ListCertificateAuthoritiesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.CertificateAuthority]: - async def async_generator(): - async for page in self.pages: - for response in page.certificate_authorities: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCaPoolsPager: - """A pager for iterating through ``list_ca_pools`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1.types.ListCaPoolsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``ca_pools`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCaPools`` requests and continue to iterate - through the ``ca_pools`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1.types.ListCaPoolsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., service.ListCaPoolsResponse], - request: service.ListCaPoolsRequest, - response: service.ListCaPoolsResponse, - *, - 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.security.privateca_v1.types.ListCaPoolsRequest): - The initial request object. - response (google.cloud.security.privateca_v1.types.ListCaPoolsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListCaPoolsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[service.ListCaPoolsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.CaPool]: - for page in self.pages: - yield from page.ca_pools - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCaPoolsAsyncPager: - """A pager for iterating through ``list_ca_pools`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1.types.ListCaPoolsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``ca_pools`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCaPools`` requests and continue to iterate - through the ``ca_pools`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1.types.ListCaPoolsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., Awaitable[service.ListCaPoolsResponse]], - request: service.ListCaPoolsRequest, - response: service.ListCaPoolsResponse, - *, - 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.security.privateca_v1.types.ListCaPoolsRequest): - The initial request object. - response (google.cloud.security.privateca_v1.types.ListCaPoolsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListCaPoolsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[service.ListCaPoolsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.CaPool]: - async def async_generator(): - async for page in self.pages: - for response in page.ca_pools: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateRevocationListsPager: - """A pager for iterating through ``list_certificate_revocation_lists`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1.types.ListCertificateRevocationListsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``certificate_revocation_lists`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCertificateRevocationLists`` requests and continue to iterate - through the ``certificate_revocation_lists`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1.types.ListCertificateRevocationListsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., service.ListCertificateRevocationListsResponse], - request: service.ListCertificateRevocationListsRequest, - response: service.ListCertificateRevocationListsResponse, - *, - 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.security.privateca_v1.types.ListCertificateRevocationListsRequest): - The initial request object. - response (google.cloud.security.privateca_v1.types.ListCertificateRevocationListsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListCertificateRevocationListsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[service.ListCertificateRevocationListsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.CertificateRevocationList]: - for page in self.pages: - yield from page.certificate_revocation_lists - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateRevocationListsAsyncPager: - """A pager for iterating through ``list_certificate_revocation_lists`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1.types.ListCertificateRevocationListsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``certificate_revocation_lists`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCertificateRevocationLists`` requests and continue to iterate - through the ``certificate_revocation_lists`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1.types.ListCertificateRevocationListsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., Awaitable[service.ListCertificateRevocationListsResponse]], - request: service.ListCertificateRevocationListsRequest, - response: service.ListCertificateRevocationListsResponse, - *, - 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.security.privateca_v1.types.ListCertificateRevocationListsRequest): - The initial request object. - response (google.cloud.security.privateca_v1.types.ListCertificateRevocationListsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListCertificateRevocationListsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[service.ListCertificateRevocationListsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.CertificateRevocationList]: - async def async_generator(): - async for page in self.pages: - for response in page.certificate_revocation_lists: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateTemplatesPager: - """A pager for iterating through ``list_certificate_templates`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1.types.ListCertificateTemplatesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``certificate_templates`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCertificateTemplates`` requests and continue to iterate - through the ``certificate_templates`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1.types.ListCertificateTemplatesResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., service.ListCertificateTemplatesResponse], - request: service.ListCertificateTemplatesRequest, - response: service.ListCertificateTemplatesResponse, - *, - 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.security.privateca_v1.types.ListCertificateTemplatesRequest): - The initial request object. - response (google.cloud.security.privateca_v1.types.ListCertificateTemplatesResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListCertificateTemplatesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[service.ListCertificateTemplatesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.CertificateTemplate]: - for page in self.pages: - yield from page.certificate_templates - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateTemplatesAsyncPager: - """A pager for iterating through ``list_certificate_templates`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1.types.ListCertificateTemplatesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``certificate_templates`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCertificateTemplates`` requests and continue to iterate - through the ``certificate_templates`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1.types.ListCertificateTemplatesResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., Awaitable[service.ListCertificateTemplatesResponse]], - request: service.ListCertificateTemplatesRequest, - response: service.ListCertificateTemplatesResponse, - *, - 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.security.privateca_v1.types.ListCertificateTemplatesRequest): - The initial request object. - response (google.cloud.security.privateca_v1.types.ListCertificateTemplatesResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListCertificateTemplatesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[service.ListCertificateTemplatesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.CertificateTemplate]: - async def async_generator(): - async for page in self.pages: - for response in page.certificate_templates: - 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/security/privateca_v1/services/certificate_authority_service/transports/__init__.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/__init__.py deleted file mode 100644 index 8a08053..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -from typing import Dict, Type - -from .base import CertificateAuthorityServiceTransport -from .grpc import CertificateAuthorityServiceGrpcTransport -from .grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[CertificateAuthorityServiceTransport]] -_transport_registry['grpc'] = CertificateAuthorityServiceGrpcTransport -_transport_registry['grpc_asyncio'] = CertificateAuthorityServiceGrpcAsyncIOTransport - -__all__ = ( - 'CertificateAuthorityServiceTransport', - 'CertificateAuthorityServiceGrpcTransport', - 'CertificateAuthorityServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py deleted file mode 100644 index 262576c..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py +++ /dev/null @@ -1,582 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version -import pkg_resources - -import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore - -from google.cloud.security.privateca_v1.types import resources -from google.cloud.security.privateca_v1.types import service -from google.longrunning import operations_pb2 # type: ignore - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-cloud-security-privateca', - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - -_API_CORE_VERSION = google.api_core.__version__ - - -class CertificateAuthorityServiceTransport(abc.ABC): - """Abstract transport class for CertificateAuthorityService.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) - - DEFAULT_HOST: str = 'privateca.googleapis.com' - def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - **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. - """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' - self._host = host - - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) - - # Save the scopes. - self._scopes = scopes or self.AUTH_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) - - # Save the credentials. - self._credentials = credentials - - # TODO(busunkim): These two class methods are in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-api-core - # and google-auth are increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - - # TODO: Remove this function once google-api-core >= 1.26.0 is required - @classmethod - def _get_self_signed_jwt_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Union[Optional[Sequence[str]], str]]: - """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" - - self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} - - if _API_CORE_VERSION and ( - packaging.version.parse(_API_CORE_VERSION) - >= packaging.version.parse("1.26.0") - ): - self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES - self_signed_jwt_kwargs["scopes"] = scopes - self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST - else: - self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES - - return self_signed_jwt_kwargs - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.create_certificate: gapic_v1.method.wrap_method( - self.create_certificate, - default_timeout=None, - client_info=client_info, - ), - self.get_certificate: gapic_v1.method.wrap_method( - self.get_certificate, - default_timeout=None, - client_info=client_info, - ), - self.list_certificates: gapic_v1.method.wrap_method( - self.list_certificates, - default_timeout=None, - client_info=client_info, - ), - self.revoke_certificate: gapic_v1.method.wrap_method( - self.revoke_certificate, - default_timeout=None, - client_info=client_info, - ), - self.update_certificate: gapic_v1.method.wrap_method( - self.update_certificate, - default_timeout=None, - client_info=client_info, - ), - self.activate_certificate_authority: gapic_v1.method.wrap_method( - self.activate_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.create_certificate_authority: gapic_v1.method.wrap_method( - self.create_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.disable_certificate_authority: gapic_v1.method.wrap_method( - self.disable_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.enable_certificate_authority: gapic_v1.method.wrap_method( - self.enable_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.fetch_certificate_authority_csr: gapic_v1.method.wrap_method( - self.fetch_certificate_authority_csr, - default_timeout=None, - client_info=client_info, - ), - self.get_certificate_authority: gapic_v1.method.wrap_method( - self.get_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.list_certificate_authorities: gapic_v1.method.wrap_method( - self.list_certificate_authorities, - default_timeout=None, - client_info=client_info, - ), - self.undelete_certificate_authority: gapic_v1.method.wrap_method( - self.undelete_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.delete_certificate_authority: gapic_v1.method.wrap_method( - self.delete_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.update_certificate_authority: gapic_v1.method.wrap_method( - self.update_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.create_ca_pool: gapic_v1.method.wrap_method( - self.create_ca_pool, - default_timeout=None, - client_info=client_info, - ), - self.update_ca_pool: gapic_v1.method.wrap_method( - self.update_ca_pool, - default_timeout=None, - client_info=client_info, - ), - self.get_ca_pool: gapic_v1.method.wrap_method( - self.get_ca_pool, - default_timeout=None, - client_info=client_info, - ), - self.list_ca_pools: gapic_v1.method.wrap_method( - self.list_ca_pools, - default_timeout=None, - client_info=client_info, - ), - self.delete_ca_pool: gapic_v1.method.wrap_method( - self.delete_ca_pool, - default_timeout=None, - client_info=client_info, - ), - self.fetch_ca_certs: gapic_v1.method.wrap_method( - self.fetch_ca_certs, - default_timeout=None, - client_info=client_info, - ), - self.get_certificate_revocation_list: gapic_v1.method.wrap_method( - self.get_certificate_revocation_list, - default_timeout=None, - client_info=client_info, - ), - self.list_certificate_revocation_lists: gapic_v1.method.wrap_method( - self.list_certificate_revocation_lists, - default_timeout=None, - client_info=client_info, - ), - self.update_certificate_revocation_list: gapic_v1.method.wrap_method( - self.update_certificate_revocation_list, - default_timeout=None, - client_info=client_info, - ), - self.create_certificate_template: gapic_v1.method.wrap_method( - self.create_certificate_template, - default_timeout=None, - client_info=client_info, - ), - self.delete_certificate_template: gapic_v1.method.wrap_method( - self.delete_certificate_template, - default_timeout=None, - client_info=client_info, - ), - self.get_certificate_template: gapic_v1.method.wrap_method( - self.get_certificate_template, - default_timeout=None, - client_info=client_info, - ), - self.list_certificate_templates: gapic_v1.method.wrap_method( - self.list_certificate_templates, - default_timeout=None, - client_info=client_info, - ), - self.update_certificate_template: gapic_v1.method.wrap_method( - self.update_certificate_template, - default_timeout=None, - client_info=client_info, - ), - } - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def create_certificate(self) -> Callable[ - [service.CreateCertificateRequest], - Union[ - resources.Certificate, - Awaitable[resources.Certificate] - ]]: - raise NotImplementedError() - - @property - def get_certificate(self) -> Callable[ - [service.GetCertificateRequest], - Union[ - resources.Certificate, - Awaitable[resources.Certificate] - ]]: - raise NotImplementedError() - - @property - def list_certificates(self) -> Callable[ - [service.ListCertificatesRequest], - Union[ - service.ListCertificatesResponse, - Awaitable[service.ListCertificatesResponse] - ]]: - raise NotImplementedError() - - @property - def revoke_certificate(self) -> Callable[ - [service.RevokeCertificateRequest], - Union[ - resources.Certificate, - Awaitable[resources.Certificate] - ]]: - raise NotImplementedError() - - @property - def update_certificate(self) -> Callable[ - [service.UpdateCertificateRequest], - Union[ - resources.Certificate, - Awaitable[resources.Certificate] - ]]: - raise NotImplementedError() - - @property - def activate_certificate_authority(self) -> Callable[ - [service.ActivateCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def create_certificate_authority(self) -> Callable[ - [service.CreateCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def disable_certificate_authority(self) -> Callable[ - [service.DisableCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def enable_certificate_authority(self) -> Callable[ - [service.EnableCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def fetch_certificate_authority_csr(self) -> Callable[ - [service.FetchCertificateAuthorityCsrRequest], - Union[ - service.FetchCertificateAuthorityCsrResponse, - Awaitable[service.FetchCertificateAuthorityCsrResponse] - ]]: - raise NotImplementedError() - - @property - def get_certificate_authority(self) -> Callable[ - [service.GetCertificateAuthorityRequest], - Union[ - resources.CertificateAuthority, - Awaitable[resources.CertificateAuthority] - ]]: - raise NotImplementedError() - - @property - def list_certificate_authorities(self) -> Callable[ - [service.ListCertificateAuthoritiesRequest], - Union[ - service.ListCertificateAuthoritiesResponse, - Awaitable[service.ListCertificateAuthoritiesResponse] - ]]: - raise NotImplementedError() - - @property - def undelete_certificate_authority(self) -> Callable[ - [service.UndeleteCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_certificate_authority(self) -> Callable[ - [service.DeleteCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_certificate_authority(self) -> Callable[ - [service.UpdateCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def create_ca_pool(self) -> Callable[ - [service.CreateCaPoolRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_ca_pool(self) -> Callable[ - [service.UpdateCaPoolRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_ca_pool(self) -> Callable[ - [service.GetCaPoolRequest], - Union[ - resources.CaPool, - Awaitable[resources.CaPool] - ]]: - raise NotImplementedError() - - @property - def list_ca_pools(self) -> Callable[ - [service.ListCaPoolsRequest], - Union[ - service.ListCaPoolsResponse, - Awaitable[service.ListCaPoolsResponse] - ]]: - raise NotImplementedError() - - @property - def delete_ca_pool(self) -> Callable[ - [service.DeleteCaPoolRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def fetch_ca_certs(self) -> Callable[ - [service.FetchCaCertsRequest], - Union[ - service.FetchCaCertsResponse, - Awaitable[service.FetchCaCertsResponse] - ]]: - raise NotImplementedError() - - @property - def get_certificate_revocation_list(self) -> Callable[ - [service.GetCertificateRevocationListRequest], - Union[ - resources.CertificateRevocationList, - Awaitable[resources.CertificateRevocationList] - ]]: - raise NotImplementedError() - - @property - def list_certificate_revocation_lists(self) -> Callable[ - [service.ListCertificateRevocationListsRequest], - Union[ - service.ListCertificateRevocationListsResponse, - Awaitable[service.ListCertificateRevocationListsResponse] - ]]: - raise NotImplementedError() - - @property - def update_certificate_revocation_list(self) -> Callable[ - [service.UpdateCertificateRevocationListRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def create_certificate_template(self) -> Callable[ - [service.CreateCertificateTemplateRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_certificate_template(self) -> Callable[ - [service.DeleteCertificateTemplateRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_certificate_template(self) -> Callable[ - [service.GetCertificateTemplateRequest], - Union[ - resources.CertificateTemplate, - Awaitable[resources.CertificateTemplate] - ]]: - raise NotImplementedError() - - @property - def list_certificate_templates(self) -> Callable[ - [service.ListCertificateTemplatesRequest], - Union[ - service.ListCertificateTemplatesResponse, - Awaitable[service.ListCertificateTemplatesResponse] - ]]: - raise NotImplementedError() - - @property - def update_certificate_template(self) -> Callable[ - [service.UpdateCertificateTemplateRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - -__all__ = ( - 'CertificateAuthorityServiceTransport', -) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py deleted file mode 100644 index 4c91c5e..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py +++ /dev/null @@ -1,1055 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.security.privateca_v1.types import resources -from google.cloud.security.privateca_v1.types import service -from google.longrunning import operations_pb2 # type: ignore -from .base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO - - -class CertificateAuthorityServiceGrpcTransport(CertificateAuthorityServiceTransport): - """gRPC backend transport for CertificateAuthorityService. - - [Certificate Authority - Service][google.cloud.security.privateca.v1.CertificateAuthorityService] - manages private certificate authorities and issued certificates. - - 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 = 'privateca.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel(cls, - host: str = 'privateca.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - **self_signed_jwt_kwargs, - **kwargs - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def create_certificate(self) -> Callable[ - [service.CreateCertificateRequest], - resources.Certificate]: - r"""Return a callable for the create certificate method over gRPC. - - Create a new - [Certificate][google.cloud.security.privateca.v1.Certificate] in - a given Project, Location from a particular - [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.CreateCertificateRequest], - ~.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 'create_certificate' not in self._stubs: - self._stubs['create_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificate', - request_serializer=service.CreateCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['create_certificate'] - - @property - def get_certificate(self) -> Callable[ - [service.GetCertificateRequest], - resources.Certificate]: - r"""Return a callable for the get certificate method over gRPC. - - Returns a - [Certificate][google.cloud.security.privateca.v1.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.security.privateca.v1.CertificateAuthorityService/GetCertificate', - request_serializer=service.GetCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['get_certificate'] - - @property - def list_certificates(self) -> Callable[ - [service.ListCertificatesRequest], - service.ListCertificatesResponse]: - r"""Return a callable for the list certificates method over gRPC. - - Lists - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - 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.security.privateca.v1.CertificateAuthorityService/ListCertificates', - request_serializer=service.ListCertificatesRequest.serialize, - response_deserializer=service.ListCertificatesResponse.deserialize, - ) - return self._stubs['list_certificates'] - - @property - def revoke_certificate(self) -> Callable[ - [service.RevokeCertificateRequest], - resources.Certificate]: - r"""Return a callable for the revoke certificate method over gRPC. - - Revoke a - [Certificate][google.cloud.security.privateca.v1.Certificate]. - - Returns: - Callable[[~.RevokeCertificateRequest], - ~.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 'revoke_certificate' not in self._stubs: - self._stubs['revoke_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/RevokeCertificate', - request_serializer=service.RevokeCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['revoke_certificate'] - - @property - def update_certificate(self) -> Callable[ - [service.UpdateCertificateRequest], - resources.Certificate]: - r"""Return a callable for the update certificate method over gRPC. - - Update a - [Certificate][google.cloud.security.privateca.v1.Certificate]. - Currently, the only field you can update is the - [labels][google.cloud.security.privateca.v1.Certificate.labels] - field. - - Returns: - Callable[[~.UpdateCertificateRequest], - ~.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 'update_certificate' not in self._stubs: - self._stubs['update_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificate', - request_serializer=service.UpdateCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['update_certificate'] - - @property - def activate_certificate_authority(self) -> Callable[ - [service.ActivateCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the activate certificate authority method over gRPC. - - Activate a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that is in state - [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. - After the parent Certificate Authority signs a certificate - signing request from - [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr], - this method can complete the activation process. - - Returns: - Callable[[~.ActivateCertificateAuthorityRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'activate_certificate_authority' not in self._stubs: - self._stubs['activate_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/ActivateCertificateAuthority', - request_serializer=service.ActivateCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['activate_certificate_authority'] - - @property - def create_certificate_authority(self) -> Callable[ - [service.CreateCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the create certificate authority method over gRPC. - - Create a new - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in a given Project and Location. - - Returns: - Callable[[~.CreateCertificateAuthorityRequest], - ~.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_authority' not in self._stubs: - self._stubs['create_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateAuthority', - request_serializer=service.CreateCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate_authority'] - - @property - def disable_certificate_authority(self) -> Callable[ - [service.DisableCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the disable certificate authority method over gRPC. - - Disable a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Returns: - Callable[[~.DisableCertificateAuthorityRequest], - ~.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 'disable_certificate_authority' not in self._stubs: - self._stubs['disable_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/DisableCertificateAuthority', - request_serializer=service.DisableCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['disable_certificate_authority'] - - @property - def enable_certificate_authority(self) -> Callable[ - [service.EnableCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the enable certificate authority method over gRPC. - - Enable a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Returns: - Callable[[~.EnableCertificateAuthorityRequest], - ~.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 'enable_certificate_authority' not in self._stubs: - self._stubs['enable_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/EnableCertificateAuthority', - request_serializer=service.EnableCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['enable_certificate_authority'] - - @property - def fetch_certificate_authority_csr(self) -> Callable[ - [service.FetchCertificateAuthorityCsrRequest], - service.FetchCertificateAuthorityCsrResponse]: - r"""Return a callable for the fetch certificate authority - csr method over gRPC. - - Fetch a certificate signing request (CSR) from a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that is in state - [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. - The CSR must then be signed by the desired parent Certificate - Authority, which could be another - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resource, or could be an on-prem certificate authority. See also - [ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. - - Returns: - Callable[[~.FetchCertificateAuthorityCsrRequest], - ~.FetchCertificateAuthorityCsrResponse]: - 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 'fetch_certificate_authority_csr' not in self._stubs: - self._stubs['fetch_certificate_authority_csr'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/FetchCertificateAuthorityCsr', - request_serializer=service.FetchCertificateAuthorityCsrRequest.serialize, - response_deserializer=service.FetchCertificateAuthorityCsrResponse.deserialize, - ) - return self._stubs['fetch_certificate_authority_csr'] - - @property - def get_certificate_authority(self) -> Callable[ - [service.GetCertificateAuthorityRequest], - resources.CertificateAuthority]: - r"""Return a callable for the get certificate authority method over gRPC. - - Returns a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Returns: - Callable[[~.GetCertificateAuthorityRequest], - ~.CertificateAuthority]: - 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_authority' not in self._stubs: - self._stubs['get_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateAuthority', - request_serializer=service.GetCertificateAuthorityRequest.serialize, - response_deserializer=resources.CertificateAuthority.deserialize, - ) - return self._stubs['get_certificate_authority'] - - @property - def list_certificate_authorities(self) -> Callable[ - [service.ListCertificateAuthoritiesRequest], - service.ListCertificateAuthoritiesResponse]: - r"""Return a callable for the list certificate authorities method over gRPC. - - Lists - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. - - Returns: - Callable[[~.ListCertificateAuthoritiesRequest], - ~.ListCertificateAuthoritiesResponse]: - 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_authorities' not in self._stubs: - self._stubs['list_certificate_authorities'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateAuthorities', - request_serializer=service.ListCertificateAuthoritiesRequest.serialize, - response_deserializer=service.ListCertificateAuthoritiesResponse.deserialize, - ) - return self._stubs['list_certificate_authorities'] - - @property - def undelete_certificate_authority(self) -> Callable[ - [service.UndeleteCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the undelete certificate authority method over gRPC. - - Undelete a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that has been deleted. - - Returns: - Callable[[~.UndeleteCertificateAuthorityRequest], - ~.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 'undelete_certificate_authority' not in self._stubs: - self._stubs['undelete_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/UndeleteCertificateAuthority', - request_serializer=service.UndeleteCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['undelete_certificate_authority'] - - @property - def delete_certificate_authority(self) -> Callable[ - [service.DeleteCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete certificate authority method over gRPC. - - Delete a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Returns: - Callable[[~.DeleteCertificateAuthorityRequest], - ~.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_authority' not in self._stubs: - self._stubs['delete_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateAuthority', - request_serializer=service.DeleteCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_certificate_authority'] - - @property - def update_certificate_authority(self) -> Callable[ - [service.UpdateCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the update certificate authority method over gRPC. - - Update a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Returns: - Callable[[~.UpdateCertificateAuthorityRequest], - ~.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_authority' not in self._stubs: - self._stubs['update_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateAuthority', - request_serializer=service.UpdateCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_authority'] - - @property - def create_ca_pool(self) -> Callable[ - [service.CreateCaPoolRequest], - operations_pb2.Operation]: - r"""Return a callable for the create ca pool method over gRPC. - - Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.CreateCaPoolRequest], - ~.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_ca_pool' not in self._stubs: - self._stubs['create_ca_pool'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCaPool', - request_serializer=service.CreateCaPoolRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_ca_pool'] - - @property - def update_ca_pool(self) -> Callable[ - [service.UpdateCaPoolRequest], - operations_pb2.Operation]: - r"""Return a callable for the update ca pool method over gRPC. - - Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.UpdateCaPoolRequest], - ~.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_ca_pool' not in self._stubs: - self._stubs['update_ca_pool'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCaPool', - request_serializer=service.UpdateCaPoolRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_ca_pool'] - - @property - def get_ca_pool(self) -> Callable[ - [service.GetCaPoolRequest], - resources.CaPool]: - r"""Return a callable for the get ca pool method over gRPC. - - Returns a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.GetCaPoolRequest], - ~.CaPool]: - 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_ca_pool' not in self._stubs: - self._stubs['get_ca_pool'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCaPool', - request_serializer=service.GetCaPoolRequest.serialize, - response_deserializer=resources.CaPool.deserialize, - ) - return self._stubs['get_ca_pool'] - - @property - def list_ca_pools(self) -> Callable[ - [service.ListCaPoolsRequest], - service.ListCaPoolsResponse]: - r"""Return a callable for the list ca pools method over gRPC. - - Lists [CaPools][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.ListCaPoolsRequest], - ~.ListCaPoolsResponse]: - 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_ca_pools' not in self._stubs: - self._stubs['list_ca_pools'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCaPools', - request_serializer=service.ListCaPoolsRequest.serialize, - response_deserializer=service.ListCaPoolsResponse.deserialize, - ) - return self._stubs['list_ca_pools'] - - @property - def delete_ca_pool(self) -> Callable[ - [service.DeleteCaPoolRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete ca pool method over gRPC. - - Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.DeleteCaPoolRequest], - ~.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_ca_pool' not in self._stubs: - self._stubs['delete_ca_pool'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCaPool', - request_serializer=service.DeleteCaPoolRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_ca_pool'] - - @property - def fetch_ca_certs(self) -> Callable[ - [service.FetchCaCertsRequest], - service.FetchCaCertsResponse]: - r"""Return a callable for the fetch ca certs method over gRPC. - - FetchCaCerts returns the current trust anchor for the - [CaPool][google.cloud.security.privateca.v1.CaPool]. This will - include CA certificate chains for all ACTIVE - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources in the - [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.FetchCaCertsRequest], - ~.FetchCaCertsResponse]: - 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 'fetch_ca_certs' not in self._stubs: - self._stubs['fetch_ca_certs'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/FetchCaCerts', - request_serializer=service.FetchCaCertsRequest.serialize, - response_deserializer=service.FetchCaCertsResponse.deserialize, - ) - return self._stubs['fetch_ca_certs'] - - @property - def get_certificate_revocation_list(self) -> Callable[ - [service.GetCertificateRevocationListRequest], - resources.CertificateRevocationList]: - r"""Return a callable for the get certificate revocation - list method over gRPC. - - Returns a - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. - - Returns: - Callable[[~.GetCertificateRevocationListRequest], - ~.CertificateRevocationList]: - 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_revocation_list' not in self._stubs: - self._stubs['get_certificate_revocation_list'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateRevocationList', - request_serializer=service.GetCertificateRevocationListRequest.serialize, - response_deserializer=resources.CertificateRevocationList.deserialize, - ) - return self._stubs['get_certificate_revocation_list'] - - @property - def list_certificate_revocation_lists(self) -> Callable[ - [service.ListCertificateRevocationListsRequest], - service.ListCertificateRevocationListsResponse]: - r"""Return a callable for the list certificate revocation - lists method over gRPC. - - Lists - [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. - - Returns: - Callable[[~.ListCertificateRevocationListsRequest], - ~.ListCertificateRevocationListsResponse]: - 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_revocation_lists' not in self._stubs: - self._stubs['list_certificate_revocation_lists'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateRevocationLists', - request_serializer=service.ListCertificateRevocationListsRequest.serialize, - response_deserializer=service.ListCertificateRevocationListsResponse.deserialize, - ) - return self._stubs['list_certificate_revocation_lists'] - - @property - def update_certificate_revocation_list(self) -> Callable[ - [service.UpdateCertificateRevocationListRequest], - operations_pb2.Operation]: - r"""Return a callable for the update certificate revocation - list method over gRPC. - - Update a - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. - - Returns: - Callable[[~.UpdateCertificateRevocationListRequest], - ~.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_revocation_list' not in self._stubs: - self._stubs['update_certificate_revocation_list'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateRevocationList', - request_serializer=service.UpdateCertificateRevocationListRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_revocation_list'] - - @property - def create_certificate_template(self) -> Callable[ - [service.CreateCertificateTemplateRequest], - operations_pb2.Operation]: - r"""Return a callable for the create certificate template method over gRPC. - - Create a new - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - in a given Project and Location. - - Returns: - Callable[[~.CreateCertificateTemplateRequest], - ~.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_template' not in self._stubs: - self._stubs['create_certificate_template'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateTemplate', - request_serializer=service.CreateCertificateTemplateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate_template'] - - @property - def delete_certificate_template(self) -> Callable[ - [service.DeleteCertificateTemplateRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete certificate template method over gRPC. - - DeleteCertificateTemplate deletes a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - - Returns: - Callable[[~.DeleteCertificateTemplateRequest], - ~.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_template' not in self._stubs: - self._stubs['delete_certificate_template'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateTemplate', - request_serializer=service.DeleteCertificateTemplateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_certificate_template'] - - @property - def get_certificate_template(self) -> Callable[ - [service.GetCertificateTemplateRequest], - resources.CertificateTemplate]: - r"""Return a callable for the get certificate template method over gRPC. - - Returns a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - - Returns: - Callable[[~.GetCertificateTemplateRequest], - ~.CertificateTemplate]: - 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_template' not in self._stubs: - self._stubs['get_certificate_template'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateTemplate', - request_serializer=service.GetCertificateTemplateRequest.serialize, - response_deserializer=resources.CertificateTemplate.deserialize, - ) - return self._stubs['get_certificate_template'] - - @property - def list_certificate_templates(self) -> Callable[ - [service.ListCertificateTemplatesRequest], - service.ListCertificateTemplatesResponse]: - r"""Return a callable for the list certificate templates method over gRPC. - - Lists - [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. - - Returns: - Callable[[~.ListCertificateTemplatesRequest], - ~.ListCertificateTemplatesResponse]: - 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_templates' not in self._stubs: - self._stubs['list_certificate_templates'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateTemplates', - request_serializer=service.ListCertificateTemplatesRequest.serialize, - response_deserializer=service.ListCertificateTemplatesResponse.deserialize, - ) - return self._stubs['list_certificate_templates'] - - @property - def update_certificate_template(self) -> Callable[ - [service.UpdateCertificateTemplateRequest], - operations_pb2.Operation]: - r"""Return a callable for the update certificate template method over gRPC. - - Update a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - - Returns: - Callable[[~.UpdateCertificateTemplateRequest], - ~.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_template' not in self._stubs: - self._stubs['update_certificate_template'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateTemplate', - request_serializer=service.UpdateCertificateTemplateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_template'] - - -__all__ = ( - 'CertificateAuthorityServiceGrpcTransport', -) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py deleted file mode 100644 index ae7ed18..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,1059 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.security.privateca_v1.types import resources -from google.cloud.security.privateca_v1.types import service -from google.longrunning import operations_pb2 # type: ignore -from .base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import CertificateAuthorityServiceGrpcTransport - - -class CertificateAuthorityServiceGrpcAsyncIOTransport(CertificateAuthorityServiceTransport): - """gRPC AsyncIO backend transport for CertificateAuthorityService. - - [Certificate Authority - Service][google.cloud.security.privateca.v1.CertificateAuthorityService] - manages private certificate authorities and issued certificates. - - 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 = 'privateca.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - **self_signed_jwt_kwargs, - **kwargs - ) - - def __init__(self, *, - host: str = 'privateca.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsAsyncClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def create_certificate(self) -> Callable[ - [service.CreateCertificateRequest], - Awaitable[resources.Certificate]]: - r"""Return a callable for the create certificate method over gRPC. - - Create a new - [Certificate][google.cloud.security.privateca.v1.Certificate] in - a given Project, Location from a particular - [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.CreateCertificateRequest], - 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 'create_certificate' not in self._stubs: - self._stubs['create_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificate', - request_serializer=service.CreateCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['create_certificate'] - - @property - def get_certificate(self) -> Callable[ - [service.GetCertificateRequest], - Awaitable[resources.Certificate]]: - r"""Return a callable for the get certificate method over gRPC. - - Returns a - [Certificate][google.cloud.security.privateca.v1.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.security.privateca.v1.CertificateAuthorityService/GetCertificate', - request_serializer=service.GetCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['get_certificate'] - - @property - def list_certificates(self) -> Callable[ - [service.ListCertificatesRequest], - Awaitable[service.ListCertificatesResponse]]: - r"""Return a callable for the list certificates method over gRPC. - - Lists - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - 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.security.privateca.v1.CertificateAuthorityService/ListCertificates', - request_serializer=service.ListCertificatesRequest.serialize, - response_deserializer=service.ListCertificatesResponse.deserialize, - ) - return self._stubs['list_certificates'] - - @property - def revoke_certificate(self) -> Callable[ - [service.RevokeCertificateRequest], - Awaitable[resources.Certificate]]: - r"""Return a callable for the revoke certificate method over gRPC. - - Revoke a - [Certificate][google.cloud.security.privateca.v1.Certificate]. - - Returns: - Callable[[~.RevokeCertificateRequest], - 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 'revoke_certificate' not in self._stubs: - self._stubs['revoke_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/RevokeCertificate', - request_serializer=service.RevokeCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['revoke_certificate'] - - @property - def update_certificate(self) -> Callable[ - [service.UpdateCertificateRequest], - Awaitable[resources.Certificate]]: - r"""Return a callable for the update certificate method over gRPC. - - Update a - [Certificate][google.cloud.security.privateca.v1.Certificate]. - Currently, the only field you can update is the - [labels][google.cloud.security.privateca.v1.Certificate.labels] - field. - - Returns: - Callable[[~.UpdateCertificateRequest], - 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 'update_certificate' not in self._stubs: - self._stubs['update_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificate', - request_serializer=service.UpdateCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['update_certificate'] - - @property - def activate_certificate_authority(self) -> Callable[ - [service.ActivateCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the activate certificate authority method over gRPC. - - Activate a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that is in state - [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. - After the parent Certificate Authority signs a certificate - signing request from - [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr], - this method can complete the activation process. - - Returns: - Callable[[~.ActivateCertificateAuthorityRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'activate_certificate_authority' not in self._stubs: - self._stubs['activate_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/ActivateCertificateAuthority', - request_serializer=service.ActivateCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['activate_certificate_authority'] - - @property - def create_certificate_authority(self) -> Callable[ - [service.CreateCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create certificate authority method over gRPC. - - Create a new - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in a given Project and Location. - - Returns: - Callable[[~.CreateCertificateAuthorityRequest], - 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_authority' not in self._stubs: - self._stubs['create_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateAuthority', - request_serializer=service.CreateCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate_authority'] - - @property - def disable_certificate_authority(self) -> Callable[ - [service.DisableCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the disable certificate authority method over gRPC. - - Disable a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Returns: - Callable[[~.DisableCertificateAuthorityRequest], - 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 'disable_certificate_authority' not in self._stubs: - self._stubs['disable_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/DisableCertificateAuthority', - request_serializer=service.DisableCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['disable_certificate_authority'] - - @property - def enable_certificate_authority(self) -> Callable[ - [service.EnableCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the enable certificate authority method over gRPC. - - Enable a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Returns: - Callable[[~.EnableCertificateAuthorityRequest], - 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 'enable_certificate_authority' not in self._stubs: - self._stubs['enable_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/EnableCertificateAuthority', - request_serializer=service.EnableCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['enable_certificate_authority'] - - @property - def fetch_certificate_authority_csr(self) -> Callable[ - [service.FetchCertificateAuthorityCsrRequest], - Awaitable[service.FetchCertificateAuthorityCsrResponse]]: - r"""Return a callable for the fetch certificate authority - csr method over gRPC. - - Fetch a certificate signing request (CSR) from a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that is in state - [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. - The CSR must then be signed by the desired parent Certificate - Authority, which could be another - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resource, or could be an on-prem certificate authority. See also - [ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. - - Returns: - Callable[[~.FetchCertificateAuthorityCsrRequest], - Awaitable[~.FetchCertificateAuthorityCsrResponse]]: - 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 'fetch_certificate_authority_csr' not in self._stubs: - self._stubs['fetch_certificate_authority_csr'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/FetchCertificateAuthorityCsr', - request_serializer=service.FetchCertificateAuthorityCsrRequest.serialize, - response_deserializer=service.FetchCertificateAuthorityCsrResponse.deserialize, - ) - return self._stubs['fetch_certificate_authority_csr'] - - @property - def get_certificate_authority(self) -> Callable[ - [service.GetCertificateAuthorityRequest], - Awaitable[resources.CertificateAuthority]]: - r"""Return a callable for the get certificate authority method over gRPC. - - Returns a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Returns: - Callable[[~.GetCertificateAuthorityRequest], - Awaitable[~.CertificateAuthority]]: - 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_authority' not in self._stubs: - self._stubs['get_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateAuthority', - request_serializer=service.GetCertificateAuthorityRequest.serialize, - response_deserializer=resources.CertificateAuthority.deserialize, - ) - return self._stubs['get_certificate_authority'] - - @property - def list_certificate_authorities(self) -> Callable[ - [service.ListCertificateAuthoritiesRequest], - Awaitable[service.ListCertificateAuthoritiesResponse]]: - r"""Return a callable for the list certificate authorities method over gRPC. - - Lists - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. - - Returns: - Callable[[~.ListCertificateAuthoritiesRequest], - Awaitable[~.ListCertificateAuthoritiesResponse]]: - 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_authorities' not in self._stubs: - self._stubs['list_certificate_authorities'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateAuthorities', - request_serializer=service.ListCertificateAuthoritiesRequest.serialize, - response_deserializer=service.ListCertificateAuthoritiesResponse.deserialize, - ) - return self._stubs['list_certificate_authorities'] - - @property - def undelete_certificate_authority(self) -> Callable[ - [service.UndeleteCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the undelete certificate authority method over gRPC. - - Undelete a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that has been deleted. - - Returns: - Callable[[~.UndeleteCertificateAuthorityRequest], - 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 'undelete_certificate_authority' not in self._stubs: - self._stubs['undelete_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/UndeleteCertificateAuthority', - request_serializer=service.UndeleteCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['undelete_certificate_authority'] - - @property - def delete_certificate_authority(self) -> Callable[ - [service.DeleteCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete certificate authority method over gRPC. - - Delete a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Returns: - Callable[[~.DeleteCertificateAuthorityRequest], - 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_authority' not in self._stubs: - self._stubs['delete_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateAuthority', - request_serializer=service.DeleteCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_certificate_authority'] - - @property - def update_certificate_authority(self) -> Callable[ - [service.UpdateCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update certificate authority method over gRPC. - - Update a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Returns: - Callable[[~.UpdateCertificateAuthorityRequest], - 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_authority' not in self._stubs: - self._stubs['update_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateAuthority', - request_serializer=service.UpdateCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_authority'] - - @property - def create_ca_pool(self) -> Callable[ - [service.CreateCaPoolRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create ca pool method over gRPC. - - Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.CreateCaPoolRequest], - 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_ca_pool' not in self._stubs: - self._stubs['create_ca_pool'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCaPool', - request_serializer=service.CreateCaPoolRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_ca_pool'] - - @property - def update_ca_pool(self) -> Callable[ - [service.UpdateCaPoolRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update ca pool method over gRPC. - - Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.UpdateCaPoolRequest], - 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_ca_pool' not in self._stubs: - self._stubs['update_ca_pool'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCaPool', - request_serializer=service.UpdateCaPoolRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_ca_pool'] - - @property - def get_ca_pool(self) -> Callable[ - [service.GetCaPoolRequest], - Awaitable[resources.CaPool]]: - r"""Return a callable for the get ca pool method over gRPC. - - Returns a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.GetCaPoolRequest], - Awaitable[~.CaPool]]: - 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_ca_pool' not in self._stubs: - self._stubs['get_ca_pool'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCaPool', - request_serializer=service.GetCaPoolRequest.serialize, - response_deserializer=resources.CaPool.deserialize, - ) - return self._stubs['get_ca_pool'] - - @property - def list_ca_pools(self) -> Callable[ - [service.ListCaPoolsRequest], - Awaitable[service.ListCaPoolsResponse]]: - r"""Return a callable for the list ca pools method over gRPC. - - Lists [CaPools][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.ListCaPoolsRequest], - Awaitable[~.ListCaPoolsResponse]]: - 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_ca_pools' not in self._stubs: - self._stubs['list_ca_pools'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCaPools', - request_serializer=service.ListCaPoolsRequest.serialize, - response_deserializer=service.ListCaPoolsResponse.deserialize, - ) - return self._stubs['list_ca_pools'] - - @property - def delete_ca_pool(self) -> Callable[ - [service.DeleteCaPoolRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete ca pool method over gRPC. - - Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.DeleteCaPoolRequest], - 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_ca_pool' not in self._stubs: - self._stubs['delete_ca_pool'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCaPool', - request_serializer=service.DeleteCaPoolRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_ca_pool'] - - @property - def fetch_ca_certs(self) -> Callable[ - [service.FetchCaCertsRequest], - Awaitable[service.FetchCaCertsResponse]]: - r"""Return a callable for the fetch ca certs method over gRPC. - - FetchCaCerts returns the current trust anchor for the - [CaPool][google.cloud.security.privateca.v1.CaPool]. This will - include CA certificate chains for all ACTIVE - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources in the - [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Returns: - Callable[[~.FetchCaCertsRequest], - Awaitable[~.FetchCaCertsResponse]]: - 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 'fetch_ca_certs' not in self._stubs: - self._stubs['fetch_ca_certs'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/FetchCaCerts', - request_serializer=service.FetchCaCertsRequest.serialize, - response_deserializer=service.FetchCaCertsResponse.deserialize, - ) - return self._stubs['fetch_ca_certs'] - - @property - def get_certificate_revocation_list(self) -> Callable[ - [service.GetCertificateRevocationListRequest], - Awaitable[resources.CertificateRevocationList]]: - r"""Return a callable for the get certificate revocation - list method over gRPC. - - Returns a - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. - - Returns: - Callable[[~.GetCertificateRevocationListRequest], - Awaitable[~.CertificateRevocationList]]: - 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_revocation_list' not in self._stubs: - self._stubs['get_certificate_revocation_list'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateRevocationList', - request_serializer=service.GetCertificateRevocationListRequest.serialize, - response_deserializer=resources.CertificateRevocationList.deserialize, - ) - return self._stubs['get_certificate_revocation_list'] - - @property - def list_certificate_revocation_lists(self) -> Callable[ - [service.ListCertificateRevocationListsRequest], - Awaitable[service.ListCertificateRevocationListsResponse]]: - r"""Return a callable for the list certificate revocation - lists method over gRPC. - - Lists - [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. - - Returns: - Callable[[~.ListCertificateRevocationListsRequest], - Awaitable[~.ListCertificateRevocationListsResponse]]: - 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_revocation_lists' not in self._stubs: - self._stubs['list_certificate_revocation_lists'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateRevocationLists', - request_serializer=service.ListCertificateRevocationListsRequest.serialize, - response_deserializer=service.ListCertificateRevocationListsResponse.deserialize, - ) - return self._stubs['list_certificate_revocation_lists'] - - @property - def update_certificate_revocation_list(self) -> Callable[ - [service.UpdateCertificateRevocationListRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update certificate revocation - list method over gRPC. - - Update a - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. - - Returns: - Callable[[~.UpdateCertificateRevocationListRequest], - 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_revocation_list' not in self._stubs: - self._stubs['update_certificate_revocation_list'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateRevocationList', - request_serializer=service.UpdateCertificateRevocationListRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_revocation_list'] - - @property - def create_certificate_template(self) -> Callable[ - [service.CreateCertificateTemplateRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create certificate template method over gRPC. - - Create a new - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - in a given Project and Location. - - Returns: - Callable[[~.CreateCertificateTemplateRequest], - 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_template' not in self._stubs: - self._stubs['create_certificate_template'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/CreateCertificateTemplate', - request_serializer=service.CreateCertificateTemplateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate_template'] - - @property - def delete_certificate_template(self) -> Callable[ - [service.DeleteCertificateTemplateRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete certificate template method over gRPC. - - DeleteCertificateTemplate deletes a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - - Returns: - Callable[[~.DeleteCertificateTemplateRequest], - 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_template' not in self._stubs: - self._stubs['delete_certificate_template'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/DeleteCertificateTemplate', - request_serializer=service.DeleteCertificateTemplateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_certificate_template'] - - @property - def get_certificate_template(self) -> Callable[ - [service.GetCertificateTemplateRequest], - Awaitable[resources.CertificateTemplate]]: - r"""Return a callable for the get certificate template method over gRPC. - - Returns a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - - Returns: - Callable[[~.GetCertificateTemplateRequest], - Awaitable[~.CertificateTemplate]]: - 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_template' not in self._stubs: - self._stubs['get_certificate_template'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/GetCertificateTemplate', - request_serializer=service.GetCertificateTemplateRequest.serialize, - response_deserializer=resources.CertificateTemplate.deserialize, - ) - return self._stubs['get_certificate_template'] - - @property - def list_certificate_templates(self) -> Callable[ - [service.ListCertificateTemplatesRequest], - Awaitable[service.ListCertificateTemplatesResponse]]: - r"""Return a callable for the list certificate templates method over gRPC. - - Lists - [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. - - Returns: - Callable[[~.ListCertificateTemplatesRequest], - Awaitable[~.ListCertificateTemplatesResponse]]: - 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_templates' not in self._stubs: - self._stubs['list_certificate_templates'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/ListCertificateTemplates', - request_serializer=service.ListCertificateTemplatesRequest.serialize, - response_deserializer=service.ListCertificateTemplatesResponse.deserialize, - ) - return self._stubs['list_certificate_templates'] - - @property - def update_certificate_template(self) -> Callable[ - [service.UpdateCertificateTemplateRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update certificate template method over gRPC. - - Update a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - - Returns: - Callable[[~.UpdateCertificateTemplateRequest], - 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_template' not in self._stubs: - self._stubs['update_certificate_template'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1.CertificateAuthorityService/UpdateCertificateTemplate', - request_serializer=service.UpdateCertificateTemplateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_template'] - - -__all__ = ( - 'CertificateAuthorityServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/__init__.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/__init__.py deleted file mode 100644 index 1865e5a..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/__init__.py +++ /dev/null @@ -1,134 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from .resources import ( - CaPool, - Certificate, - CertificateAuthority, - CertificateConfig, - CertificateDescription, - CertificateExtensionConstraints, - CertificateIdentityConstraints, - CertificateRevocationList, - CertificateTemplate, - KeyUsage, - ObjectId, - PublicKey, - Subject, - SubjectAltNames, - SubordinateConfig, - X509Extension, - X509Parameters, - RevocationReason, - SubjectRequestMode, -) -from .service import ( - ActivateCertificateAuthorityRequest, - CreateCaPoolRequest, - CreateCertificateAuthorityRequest, - CreateCertificateRequest, - CreateCertificateTemplateRequest, - DeleteCaPoolRequest, - DeleteCertificateAuthorityRequest, - DeleteCertificateTemplateRequest, - DisableCertificateAuthorityRequest, - EnableCertificateAuthorityRequest, - FetchCaCertsRequest, - FetchCaCertsResponse, - FetchCertificateAuthorityCsrRequest, - FetchCertificateAuthorityCsrResponse, - GetCaPoolRequest, - GetCertificateAuthorityRequest, - GetCertificateRequest, - GetCertificateRevocationListRequest, - GetCertificateTemplateRequest, - ListCaPoolsRequest, - ListCaPoolsResponse, - ListCertificateAuthoritiesRequest, - ListCertificateAuthoritiesResponse, - ListCertificateRevocationListsRequest, - ListCertificateRevocationListsResponse, - ListCertificatesRequest, - ListCertificatesResponse, - ListCertificateTemplatesRequest, - ListCertificateTemplatesResponse, - OperationMetadata, - RevokeCertificateRequest, - UndeleteCertificateAuthorityRequest, - UpdateCaPoolRequest, - UpdateCertificateAuthorityRequest, - UpdateCertificateRequest, - UpdateCertificateRevocationListRequest, - UpdateCertificateTemplateRequest, -) - -__all__ = ( - 'CaPool', - 'Certificate', - 'CertificateAuthority', - 'CertificateConfig', - 'CertificateDescription', - 'CertificateExtensionConstraints', - 'CertificateIdentityConstraints', - 'CertificateRevocationList', - 'CertificateTemplate', - 'KeyUsage', - 'ObjectId', - 'PublicKey', - 'Subject', - 'SubjectAltNames', - 'SubordinateConfig', - 'X509Extension', - 'X509Parameters', - 'RevocationReason', - 'SubjectRequestMode', - 'ActivateCertificateAuthorityRequest', - 'CreateCaPoolRequest', - 'CreateCertificateAuthorityRequest', - 'CreateCertificateRequest', - 'CreateCertificateTemplateRequest', - 'DeleteCaPoolRequest', - 'DeleteCertificateAuthorityRequest', - 'DeleteCertificateTemplateRequest', - 'DisableCertificateAuthorityRequest', - 'EnableCertificateAuthorityRequest', - 'FetchCaCertsRequest', - 'FetchCaCertsResponse', - 'FetchCertificateAuthorityCsrRequest', - 'FetchCertificateAuthorityCsrResponse', - 'GetCaPoolRequest', - 'GetCertificateAuthorityRequest', - 'GetCertificateRequest', - 'GetCertificateRevocationListRequest', - 'GetCertificateTemplateRequest', - 'ListCaPoolsRequest', - 'ListCaPoolsResponse', - 'ListCertificateAuthoritiesRequest', - 'ListCertificateAuthoritiesResponse', - 'ListCertificateRevocationListsRequest', - 'ListCertificateRevocationListsResponse', - 'ListCertificatesRequest', - 'ListCertificatesResponse', - 'ListCertificateTemplatesRequest', - 'ListCertificateTemplatesResponse', - 'OperationMetadata', - 'RevokeCertificateRequest', - 'UndeleteCertificateAuthorityRequest', - 'UpdateCaPoolRequest', - 'UpdateCertificateAuthorityRequest', - 'UpdateCertificateRequest', - 'UpdateCertificateRevocationListRequest', - 'UpdateCertificateTemplateRequest', -) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/resources.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/resources.py deleted file mode 100644 index 85ea3dc..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/resources.py +++ /dev/null @@ -1,1896 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import proto # type: ignore - -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.type import expr_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.security.privateca.v1', - manifest={ - 'RevocationReason', - 'SubjectRequestMode', - 'CertificateAuthority', - 'CaPool', - 'CertificateRevocationList', - 'Certificate', - 'CertificateTemplate', - 'X509Parameters', - 'SubordinateConfig', - 'PublicKey', - 'CertificateConfig', - 'CertificateDescription', - 'ObjectId', - 'X509Extension', - 'KeyUsage', - 'Subject', - 'SubjectAltNames', - 'CertificateIdentityConstraints', - 'CertificateExtensionConstraints', - }, -) - - -class RevocationReason(proto.Enum): - r"""A - [RevocationReason][google.cloud.security.privateca.v1.RevocationReason] - indicates whether a - [Certificate][google.cloud.security.privateca.v1.Certificate] has - been revoked, and the reason for revocation. These correspond to - standard revocation reasons from RFC 5280. Note that the enum labels - and values in this definition are not the same ASN.1 values defined - in RFC 5280. These values will be translated to the correct ASN.1 - values when a CRL is created. - """ - REVOCATION_REASON_UNSPECIFIED = 0 - KEY_COMPROMISE = 1 - CERTIFICATE_AUTHORITY_COMPROMISE = 2 - AFFILIATION_CHANGED = 3 - SUPERSEDED = 4 - CESSATION_OF_OPERATION = 5 - CERTIFICATE_HOLD = 6 - PRIVILEGE_WITHDRAWN = 7 - ATTRIBUTE_AUTHORITY_COMPROMISE = 8 - - -class SubjectRequestMode(proto.Enum): - r"""Describes the way in which a - [Certificate][google.cloud.security.privateca.v1.Certificate]'s - [Subject][google.cloud.security.privateca.v1.Subject] and/or - [SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames] - will be resolved. - """ - SUBJECT_REQUEST_MODE_UNSPECIFIED = 0 - DEFAULT = 1 - REFLECTED_SPIFFE = 2 - - -class CertificateAuthority(proto.Message): - r"""A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - represents an individual Certificate Authority. A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1.Certificate]. - - Attributes: - name (str): - Output only. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - type_ (google.cloud.security.privateca_v1.types.CertificateAuthority.Type): - Required. Immutable. The - [Type][google.cloud.security.privateca.v1.CertificateAuthority.Type] - of this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - config (google.cloud.security.privateca_v1.types.CertificateConfig): - Required. Immutable. The config used to - create a self-signed X.509 certificate or CSR. - lifetime (google.protobuf.duration_pb2.Duration): - Required. The desired lifetime of the CA certificate. Used - to create the "not_before_time" and "not_after_time" fields - inside an X.509 certificate. - key_spec (google.cloud.security.privateca_v1.types.CertificateAuthority.KeyVersionSpec): - Required. Immutable. Used when issuing certificates for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - If this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - is a self-signed CertificateAuthority, this key is also used - to sign the self-signed CA certificate. Otherwise, it is - used to sign a CSR. - subordinate_config (google.cloud.security.privateca_v1.types.SubordinateConfig): - Optional. If this is a subordinate - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority], - this field will be set with the subordinate configuration, - which describes its issuers. This may be updated, but this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - must continue to validate. - tier (google.cloud.security.privateca_v1.types.CaPool.Tier): - Output only. The - [CaPool.Tier][google.cloud.security.privateca.v1.CaPool.Tier] - of the [CaPool][google.cloud.security.privateca.v1.CaPool] - that includes this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - state (google.cloud.security.privateca_v1.types.CertificateAuthority.State): - Output only. The - [State][google.cloud.security.privateca.v1.CertificateAuthority.State] - for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - pem_ca_certificates (Sequence[str]): - Output only. This - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s - certificate chain, including the current - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s - certificate. Ordered such that the root issuer is the final - element (consistent with RFC 5246). For a self-signed CA, - this will only list the current - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s - certificate. - ca_certificate_descriptions (Sequence[google.cloud.security.privateca_v1.types.CertificateDescription]): - Output only. A structured description of this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s - CA certificate and its issuers. Ordered as self-to-root. - gcs_bucket (str): - Immutable. The name of a Cloud Storage bucket where this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - will publish content, such as the CA certificate and CRLs. - This must be a bucket name, without any prefixes (such as - ``gs://``) or suffixes (such as ``.googleapis.com``). For - example, to use a bucket named ``my-bucket``, you would - simply specify ``my-bucket``. If not specified, a managed - bucket will be created. - access_urls (google.cloud.security.privateca_v1.types.CertificateAuthority.AccessUrls): - Output only. URLs for accessing content - published by this CA, such as the CA certificate - and CRLs. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - was last updated. - delete_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - was soft deleted, if it is in the - [DELETED][google.cloud.security.privateca.v1.CertificateAuthority.State.DELETED] - state. - expire_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - will be permanently purged, if it is in the - [DELETED][google.cloud.security.privateca.v1.CertificateAuthority.State.DELETED] - state. - labels (Sequence[google.cloud.security.privateca_v1.types.CertificateAuthority.LabelsEntry]): - Optional. Labels with user-defined metadata. - """ - class Type(proto.Enum): - r"""The type of a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority], - indicating its issuing chain. - """ - TYPE_UNSPECIFIED = 0 - SELF_SIGNED = 1 - SUBORDINATE = 2 - - class State(proto.Enum): - r"""The state of a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority], - indicating if it can be used. - """ - STATE_UNSPECIFIED = 0 - ENABLED = 1 - DISABLED = 2 - STAGED = 3 - AWAITING_USER_ACTIVATION = 4 - DELETED = 5 - - class SignHashAlgorithm(proto.Enum): - r"""The algorithm of a Cloud KMS CryptoKeyVersion of a - [CryptoKey][google.cloud.kms.v1.CryptoKey] with the - [CryptoKeyPurpose][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose] - value ``ASYMMETRIC_SIGN``. These values correspond to the - [CryptoKeyVersionAlgorithm][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionAlgorithm] - values. For RSA signing algorithms, the PSS algorithms should be - preferred, use PKCS1 algorithms if required for compatibility. For - further recommandations, see - https://cloud.google.com/kms/docs/algorithms#algorithm_recommendations. - """ - SIGN_HASH_ALGORITHM_UNSPECIFIED = 0 - RSA_PSS_2048_SHA256 = 1 - RSA_PSS_3072_SHA256 = 2 - RSA_PSS_4096_SHA256 = 3 - RSA_PKCS1_2048_SHA256 = 6 - RSA_PKCS1_3072_SHA256 = 7 - RSA_PKCS1_4096_SHA256 = 8 - EC_P256_SHA256 = 4 - EC_P384_SHA384 = 5 - - class AccessUrls(proto.Message): - r"""URLs where a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - will publish content. - - Attributes: - ca_certificate_access_url (str): - The URL where this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s - CA certificate is published. This will only be set for CAs - that have been activated. - crl_access_urls (Sequence[str]): - The URLs where this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s - CRLs are published. This will only be set for CAs that have - been activated. - """ - - ca_certificate_access_url = proto.Field( - proto.STRING, - number=1, - ) - crl_access_urls = proto.RepeatedField( - proto.STRING, - number=2, - ) - - class KeyVersionSpec(proto.Message): - r"""A Cloud KMS key configuration that a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - will use. - - Attributes: - cloud_kms_key_version (str): - The resource name for an existing Cloud KMS CryptoKeyVersion - in the format - ``projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*``. - This option enables full flexibility in the key's - capabilities and properties. - algorithm (google.cloud.security.privateca_v1.types.CertificateAuthority.SignHashAlgorithm): - The algorithm to use for creating a managed Cloud KMS key - for a for a simplified experience. All managed keys will be - have their - [ProtectionLevel][google.cloud.kms.v1.ProtectionLevel] as - ``HSM``. - """ - - cloud_kms_key_version = proto.Field( - proto.STRING, - number=1, - oneof='KeyVersion', - ) - algorithm = proto.Field( - proto.ENUM, - number=2, - oneof='KeyVersion', - enum='CertificateAuthority.SignHashAlgorithm', - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - type_ = proto.Field( - proto.ENUM, - number=2, - enum=Type, - ) - config = proto.Field( - proto.MESSAGE, - number=3, - message='CertificateConfig', - ) - lifetime = proto.Field( - proto.MESSAGE, - number=4, - message=duration_pb2.Duration, - ) - key_spec = proto.Field( - proto.MESSAGE, - number=5, - message=KeyVersionSpec, - ) - subordinate_config = proto.Field( - proto.MESSAGE, - number=6, - message='SubordinateConfig', - ) - tier = proto.Field( - proto.ENUM, - number=7, - enum='CaPool.Tier', - ) - state = proto.Field( - proto.ENUM, - number=8, - enum=State, - ) - pem_ca_certificates = proto.RepeatedField( - proto.STRING, - number=9, - ) - ca_certificate_descriptions = proto.RepeatedField( - proto.MESSAGE, - number=10, - message='CertificateDescription', - ) - gcs_bucket = proto.Field( - proto.STRING, - number=11, - ) - access_urls = proto.Field( - proto.MESSAGE, - number=12, - message=AccessUrls, - ) - create_time = proto.Field( - proto.MESSAGE, - number=13, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=14, - message=timestamp_pb2.Timestamp, - ) - delete_time = proto.Field( - proto.MESSAGE, - number=15, - message=timestamp_pb2.Timestamp, - ) - expire_time = proto.Field( - proto.MESSAGE, - number=16, - message=timestamp_pb2.Timestamp, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=17, - ) - - -class CaPool(proto.Message): - r"""A [CaPool][google.cloud.security.privateca.v1.CaPool] represents a - group of - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] - that form a trust anchor. A - [CaPool][google.cloud.security.privateca.v1.CaPool] can be used to - manage issuance policies for one or more - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources and to rotate CA certificates in and out of the trust - anchor. - - Attributes: - name (str): - Output only. The resource name for this - [CaPool][google.cloud.security.privateca.v1.CaPool] in the - format ``projects/*/locations/*/caPools/*``. - tier (google.cloud.security.privateca_v1.types.CaPool.Tier): - Required. Immutable. The - [Tier][google.cloud.security.privateca.v1.CaPool.Tier] of - this [CaPool][google.cloud.security.privateca.v1.CaPool]. - issuance_policy (google.cloud.security.privateca_v1.types.CaPool.IssuancePolicy): - Optional. The - [IssuancePolicy][google.cloud.security.privateca.v1.CaPool.IssuancePolicy] - to control how - [Certificates][google.cloud.security.privateca.v1.Certificate] - will be issued from this - [CaPool][google.cloud.security.privateca.v1.CaPool]. - publishing_options (google.cloud.security.privateca_v1.types.CaPool.PublishingOptions): - Optional. The - [PublishingOptions][google.cloud.security.privateca.v1.CaPool.PublishingOptions] - to follow when issuing - [Certificates][google.cloud.security.privateca.v1.Certificate] - from any - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in this [CaPool][google.cloud.security.privateca.v1.CaPool]. - labels (Sequence[google.cloud.security.privateca_v1.types.CaPool.LabelsEntry]): - Optional. Labels with user-defined metadata. - """ - class Tier(proto.Enum): - r"""The tier of a [CaPool][google.cloud.security.privateca.v1.CaPool], - indicating its supported functionality and/or billing SKU. - """ - TIER_UNSPECIFIED = 0 - ENTERPRISE = 1 - DEVOPS = 2 - - class PublishingOptions(proto.Message): - r"""Options relating to the publication of each - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s - CA certificate and CRLs and their inclusion as extensions in issued - [Certificates][google.cloud.security.privateca.v1.Certificate]. The - options set here apply to certificates issued by any - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Attributes: - publish_ca_cert (bool): - Required. When true, publishes each - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s - CA certificate and includes its URL in the "Authority - Information Access" X.509 extension in all issued - [Certificates][google.cloud.security.privateca.v1.Certificate]. - If this is false, the CA certificate will not be published - and the corresponding X.509 extension will not be written in - issued certificates. - publish_crl (bool): - Required. When true, publishes each - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]'s - CRL and includes its URL in the "CRL Distribution Points" - X.509 extension in all issued - [Certificates][google.cloud.security.privateca.v1.Certificate]. - If this is false, CRLs will not be published and the - corresponding X.509 extension will not be written in issued - certificates. CRLs will expire 7 days from their creation. - However, we will rebuild daily. CRLs are also rebuilt - shortly after a certificate is revoked. - """ - - publish_ca_cert = proto.Field( - proto.BOOL, - number=1, - ) - publish_crl = proto.Field( - proto.BOOL, - number=2, - ) - - class IssuancePolicy(proto.Message): - r"""Defines controls over all certificate issuance within a - [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Attributes: - allowed_key_types (Sequence[google.cloud.security.privateca_v1.types.CaPool.IssuancePolicy.AllowedKeyType]): - Optional. If any - [AllowedKeyType][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.AllowedKeyType] - is specified, then the certificate request's public key must - match one of the key types listed here. Otherwise, any key - may be used. - maximum_lifetime (google.protobuf.duration_pb2.Duration): - Optional. The maximum lifetime allowed for issued - [Certificates][google.cloud.security.privateca.v1.Certificate]. - Note that if the issuing - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - expires before a - [Certificate][google.cloud.security.privateca.v1.Certificate]'s - requested maximum_lifetime, the effective lifetime will be - explicitly truncated to match it. - allowed_issuance_modes (google.cloud.security.privateca_v1.types.CaPool.IssuancePolicy.IssuanceModes): - Optional. If specified, then only methods allowed in the - [IssuanceModes][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.IssuanceModes] - may be used to issue - [Certificates][google.cloud.security.privateca.v1.Certificate]. - baseline_values (google.cloud.security.privateca_v1.types.X509Parameters): - Optional. A set of X.509 values that will be applied to all - certificates issued through this - [CaPool][google.cloud.security.privateca.v1.CaPool]. If a - certificate request includes conflicting values for the same - properties, they will be overwritten by the values defined - here. If a certificate request uses a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - that defines conflicting - [predefined_values][google.cloud.security.privateca.v1.CertificateTemplate.predefined_values] - for the same properties, the certificate issuance request - will fail. - identity_constraints (google.cloud.security.privateca_v1.types.CertificateIdentityConstraints): - Optional. Describes constraints on identities that may - appear in - [Certificates][google.cloud.security.privateca.v1.Certificate] - issued through this - [CaPool][google.cloud.security.privateca.v1.CaPool]. If this - is omitted, then this - [CaPool][google.cloud.security.privateca.v1.CaPool] will not - add restrictions on a certificate's identity. - passthrough_extensions (google.cloud.security.privateca_v1.types.CertificateExtensionConstraints): - Optional. Describes the set of X.509 extensions that may - appear in a - [Certificate][google.cloud.security.privateca.v1.Certificate] - issued through this - [CaPool][google.cloud.security.privateca.v1.CaPool]. If a - certificate request sets extensions that don't appear in the - [passthrough_extensions][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.passthrough_extensions], - those extensions will be dropped. If a certificate request - uses a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - with - [predefined_values][google.cloud.security.privateca.v1.CertificateTemplate.predefined_values] - that don't appear here, the certificate issuance request - will fail. If this is omitted, then this - [CaPool][google.cloud.security.privateca.v1.CaPool] will not - add restrictions on a certificate's X.509 extensions. These - constraints do not apply to X.509 extensions set in this - [CaPool][google.cloud.security.privateca.v1.CaPool]'s - [baseline_values][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.baseline_values]. - """ - - class AllowedKeyType(proto.Message): - r"""Describes a "type" of key that may be used in a - [Certificate][google.cloud.security.privateca.v1.Certificate] issued - from a [CaPool][google.cloud.security.privateca.v1.CaPool]. Note - that a single - [AllowedKeyType][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.AllowedKeyType] - may refer to either a fully-qualified key algorithm, such as RSA - 4096, or a family of key algorithms, such as any RSA key. - - Attributes: - rsa (google.cloud.security.privateca_v1.types.CaPool.IssuancePolicy.AllowedKeyType.RsaKeyType): - Represents an allowed RSA key type. - elliptic_curve (google.cloud.security.privateca_v1.types.CaPool.IssuancePolicy.AllowedKeyType.EcKeyType): - Represents an allowed Elliptic Curve key - type. - """ - - class RsaKeyType(proto.Message): - r"""Describes an RSA key that may be used in a - [Certificate][google.cloud.security.privateca.v1.Certificate] issued - from a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Attributes: - min_modulus_size (int): - Optional. The minimum allowed RSA modulus - size, in bits. If this is not set, or if set to - zero, the service-level min RSA modulus size - will continue to apply. - max_modulus_size (int): - Optional. The maximum allowed RSA modulus - size, in bits. If this is not set, or if set to - zero, the service will not enforce an explicit - upper bound on RSA modulus sizes. - """ - - min_modulus_size = proto.Field( - proto.INT64, - number=1, - ) - max_modulus_size = proto.Field( - proto.INT64, - number=2, - ) - - class EcKeyType(proto.Message): - r"""Describes an Elliptic Curve key that may be used in a - [Certificate][google.cloud.security.privateca.v1.Certificate] issued - from a [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Attributes: - signature_algorithm (google.cloud.security.privateca_v1.types.CaPool.IssuancePolicy.AllowedKeyType.EcKeyType.EcSignatureAlgorithm): - Optional. A signature algorithm that must be - used. If this is omitted, any EC-based signature - algorithm will be allowed. - """ - class EcSignatureAlgorithm(proto.Enum): - r"""Describes an elliptic curve-based signature algorithm that may be - used in a - [Certificate][google.cloud.security.privateca.v1.Certificate] issued - from a [CaPool][google.cloud.security.privateca.v1.CaPool]. - """ - EC_SIGNATURE_ALGORITHM_UNSPECIFIED = 0 - ECDSA_P256 = 1 - ECDSA_P384 = 2 - EDDSA_25519 = 3 - - signature_algorithm = proto.Field( - proto.ENUM, - number=1, - enum='CaPool.IssuancePolicy.AllowedKeyType.EcKeyType.EcSignatureAlgorithm', - ) - - rsa = proto.Field( - proto.MESSAGE, - number=1, - oneof='key_type', - message='CaPool.IssuancePolicy.AllowedKeyType.RsaKeyType', - ) - elliptic_curve = proto.Field( - proto.MESSAGE, - number=2, - oneof='key_type', - message='CaPool.IssuancePolicy.AllowedKeyType.EcKeyType', - ) - - class IssuanceModes(proto.Message): - r"""[IssuanceModes][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.IssuanceModes] - specifies the allowed ways in which - [Certificates][google.cloud.security.privateca.v1.Certificate] may - be requested from this - [CaPool][google.cloud.security.privateca.v1.CaPool]. - - Attributes: - allow_csr_based_issuance (bool): - Required. When true, allows callers to create - [Certificates][google.cloud.security.privateca.v1.Certificate] - by specifying a CSR. - allow_config_based_issuance (bool): - Required. When true, allows callers to create - [Certificates][google.cloud.security.privateca.v1.Certificate] - by specifying a - [CertificateConfig][google.cloud.security.privateca.v1.CertificateConfig]. - """ - - allow_csr_based_issuance = proto.Field( - proto.BOOL, - number=1, - ) - allow_config_based_issuance = proto.Field( - proto.BOOL, - number=2, - ) - - allowed_key_types = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='CaPool.IssuancePolicy.AllowedKeyType', - ) - maximum_lifetime = proto.Field( - proto.MESSAGE, - number=2, - message=duration_pb2.Duration, - ) - allowed_issuance_modes = proto.Field( - proto.MESSAGE, - number=3, - message='CaPool.IssuancePolicy.IssuanceModes', - ) - baseline_values = proto.Field( - proto.MESSAGE, - number=4, - message='X509Parameters', - ) - identity_constraints = proto.Field( - proto.MESSAGE, - number=5, - message='CertificateIdentityConstraints', - ) - passthrough_extensions = proto.Field( - proto.MESSAGE, - number=6, - message='CertificateExtensionConstraints', - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - tier = proto.Field( - proto.ENUM, - number=2, - enum=Tier, - ) - issuance_policy = proto.Field( - proto.MESSAGE, - number=3, - message=IssuancePolicy, - ) - publishing_options = proto.Field( - proto.MESSAGE, - number=4, - message=PublishingOptions, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=5, - ) - - -class CertificateRevocationList(proto.Message): - r"""A - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] - corresponds to a signed X.509 certificate Revocation List (CRL). A - CRL contains the serial numbers of certificates that should no - longer be trusted. - - Attributes: - name (str): - Output only. The resource name for this - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] - in the format - ``projects/*/locations/*/caPools/*certificateAuthorities/*/ certificateRevocationLists/*``. - sequence_number (int): - Output only. The CRL sequence number that appears in - pem_crl. - revoked_certificates (Sequence[google.cloud.security.privateca_v1.types.CertificateRevocationList.RevokedCertificate]): - Output only. The revoked serial numbers that appear in - pem_crl. - pem_crl (str): - Output only. The PEM-encoded X.509 CRL. - access_url (str): - Output only. The location where 'pem_crl' can be accessed. - state (google.cloud.security.privateca_v1.types.CertificateRevocationList.State): - Output only. The - [State][google.cloud.security.privateca.v1.CertificateRevocationList.State] - for this - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] - was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] - was updated. - revision_id (str): - Output only. The revision ID of this - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. - A new revision is committed whenever a new CRL is published. - The format is an 8-character hexadecimal string. - labels (Sequence[google.cloud.security.privateca_v1.types.CertificateRevocationList.LabelsEntry]): - Optional. Labels with user-defined metadata. - """ - class State(proto.Enum): - r"""The state of a - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList], - indicating if it is current. - """ - STATE_UNSPECIFIED = 0 - ACTIVE = 1 - SUPERSEDED = 2 - - class RevokedCertificate(proto.Message): - r"""Describes a revoked - [Certificate][google.cloud.security.privateca.v1.Certificate]. - - Attributes: - certificate (str): - The resource name for the - [Certificate][google.cloud.security.privateca.v1.Certificate] - in the format - ``projects/*/locations/*/caPools/*/certificates/*``. - hex_serial_number (str): - The serial number of the - [Certificate][google.cloud.security.privateca.v1.Certificate]. - revocation_reason (google.cloud.security.privateca_v1.types.RevocationReason): - The reason the - [Certificate][google.cloud.security.privateca.v1.Certificate] - was revoked. - """ - - certificate = proto.Field( - proto.STRING, - number=1, - ) - hex_serial_number = proto.Field( - proto.STRING, - number=2, - ) - revocation_reason = proto.Field( - proto.ENUM, - number=3, - enum='RevocationReason', - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - sequence_number = proto.Field( - proto.INT64, - number=2, - ) - revoked_certificates = proto.RepeatedField( - proto.MESSAGE, - number=3, - message=RevokedCertificate, - ) - pem_crl = proto.Field( - proto.STRING, - number=4, - ) - access_url = proto.Field( - proto.STRING, - number=5, - ) - state = proto.Field( - proto.ENUM, - number=6, - enum=State, - ) - create_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - revision_id = proto.Field( - proto.STRING, - number=9, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=10, - ) - - -class Certificate(proto.Message): - r"""A [Certificate][google.cloud.security.privateca.v1.Certificate] - corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - - Attributes: - name (str): - Output only. The resource name for this - [Certificate][google.cloud.security.privateca.v1.Certificate] - in the format - ``projects/*/locations/*/caPools/*/certificates/*``. - pem_csr (str): - Immutable. A pem-encoded X.509 certificate - signing request (CSR). - config (google.cloud.security.privateca_v1.types.CertificateConfig): - Immutable. A description of the certificate - and key that does not require X.509 or ASN.1. - issuer_certificate_authority (str): - Output only. The resource name of the issuing - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - lifetime (google.protobuf.duration_pb2.Duration): - Required. Immutable. The desired lifetime of a certificate. - Used to create the "not_before_time" and "not_after_time" - fields inside an X.509 certificate. Note that the lifetime - may be truncated if it would extend past the life of any - certificate authority in the issuing chain. - certificate_template (str): - Immutable. The resource name for a - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - used to issue this certificate, in the format - ``projects/*/locations/*/certificateTemplates/*``. If this - is specified, the caller must have the necessary permission - to use this template. If this is omitted, no template will - be used. This template must be in the same location as the - [Certificate][google.cloud.security.privateca.v1.Certificate]. - subject_mode (google.cloud.security.privateca_v1.types.SubjectRequestMode): - Immutable. Specifies how the - [Certificate][google.cloud.security.privateca.v1.Certificate]'s - identity fields are to be decided. If this is omitted, the - ``DEFAULT`` subject mode will be used. - revocation_details (google.cloud.security.privateca_v1.types.Certificate.RevocationDetails): - Output only. Details regarding the revocation of this - [Certificate][google.cloud.security.privateca.v1.Certificate]. - This - [Certificate][google.cloud.security.privateca.v1.Certificate] - is considered revoked if and only if this field is present. - pem_certificate (str): - Output only. The pem-encoded, signed X.509 - certificate. - certificate_description (google.cloud.security.privateca_v1.types.CertificateDescription): - Output only. A structured description of the - issued X.509 certificate. - pem_certificate_chain (Sequence[str]): - Output only. The chain that may be used to - verify the X.509 certificate. Expected to be in - issuer-to-root order according to RFC 5246. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [Certificate][google.cloud.security.privateca.v1.Certificate] - was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [Certificate][google.cloud.security.privateca.v1.Certificate] - was updated. - labels (Sequence[google.cloud.security.privateca_v1.types.Certificate.LabelsEntry]): - Optional. Labels with user-defined metadata. - """ - - class RevocationDetails(proto.Message): - r"""Describes fields that are relavent to the revocation of a - [Certificate][google.cloud.security.privateca.v1.Certificate]. - - Attributes: - revocation_state (google.cloud.security.privateca_v1.types.RevocationReason): - Indicates why a - [Certificate][google.cloud.security.privateca.v1.Certificate] - was revoked. - revocation_time (google.protobuf.timestamp_pb2.Timestamp): - The time at which this - [Certificate][google.cloud.security.privateca.v1.Certificate] - was revoked. - """ - - revocation_state = proto.Field( - proto.ENUM, - number=1, - enum='RevocationReason', - ) - revocation_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - pem_csr = proto.Field( - proto.STRING, - number=2, - oneof='certificate_config', - ) - config = proto.Field( - proto.MESSAGE, - number=3, - oneof='certificate_config', - message='CertificateConfig', - ) - issuer_certificate_authority = proto.Field( - proto.STRING, - number=4, - ) - lifetime = proto.Field( - proto.MESSAGE, - number=5, - message=duration_pb2.Duration, - ) - certificate_template = proto.Field( - proto.STRING, - number=6, - ) - subject_mode = proto.Field( - proto.ENUM, - number=7, - enum='SubjectRequestMode', - ) - revocation_details = proto.Field( - proto.MESSAGE, - number=8, - message=RevocationDetails, - ) - pem_certificate = proto.Field( - proto.STRING, - number=9, - ) - certificate_description = proto.Field( - proto.MESSAGE, - number=10, - message='CertificateDescription', - ) - pem_certificate_chain = proto.RepeatedField( - proto.STRING, - number=11, - ) - create_time = proto.Field( - proto.MESSAGE, - number=12, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=13, - message=timestamp_pb2.Timestamp, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=14, - ) - - -class CertificateTemplate(proto.Message): - r"""A - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - refers to a managed template for certificate issuance. - - Attributes: - name (str): - Output only. The resource name for this - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - in the format - ``projects/*/locations/*/certificateTemplates/*``. - predefined_values (google.cloud.security.privateca_v1.types.X509Parameters): - Optional. A set of X.509 values that will be applied to all - issued certificates that use this template. If the - certificate request includes conflicting values for the same - properties, they will be overwritten by the values defined - here. If the issuing - [CaPool][google.cloud.security.privateca.v1.CaPool]'s - [IssuancePolicy][google.cloud.security.privateca.v1.CaPool.IssuancePolicy] - defines conflicting - [baseline_values][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.baseline_values] - for the same properties, the certificate issuance request - will fail. - identity_constraints (google.cloud.security.privateca_v1.types.CertificateIdentityConstraints): - Optional. Describes constraints on identities that may be - appear in - [Certificates][google.cloud.security.privateca.v1.Certificate] - issued using this template. If this is omitted, then this - template will not add restrictions on a certificate's - identity. - passthrough_extensions (google.cloud.security.privateca_v1.types.CertificateExtensionConstraints): - Optional. Describes the set of X.509 extensions that may - appear in a - [Certificate][google.cloud.security.privateca.v1.Certificate] - issued using this - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - If a certificate request sets extensions that don't appear - in the - [passthrough_extensions][google.cloud.security.privateca.v1.CertificateTemplate.passthrough_extensions], - those extensions will be dropped. If the issuing - [CaPool][google.cloud.security.privateca.v1.CaPool]'s - [IssuancePolicy][google.cloud.security.privateca.v1.CaPool.IssuancePolicy] - defines - [baseline_values][google.cloud.security.privateca.v1.CaPool.IssuancePolicy.baseline_values] - that don't appear here, the certificate issuance request - will fail. If this is omitted, then this template will not - add restrictions on a certificate's X.509 extensions. These - constraints do not apply to X.509 extensions set in this - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]'s - [predefined_values][google.cloud.security.privateca.v1.CertificateTemplate.predefined_values]. - description (str): - Optional. A human-readable description of - scenarios this template is intended for. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - was updated. - labels (Sequence[google.cloud.security.privateca_v1.types.CertificateTemplate.LabelsEntry]): - Optional. Labels with user-defined metadata. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - predefined_values = proto.Field( - proto.MESSAGE, - number=2, - message='X509Parameters', - ) - identity_constraints = proto.Field( - proto.MESSAGE, - number=3, - message='CertificateIdentityConstraints', - ) - passthrough_extensions = proto.Field( - proto.MESSAGE, - number=4, - message='CertificateExtensionConstraints', - ) - description = proto.Field( - proto.STRING, - number=5, - ) - create_time = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=8, - ) - - -class X509Parameters(proto.Message): - r"""An - [X509Parameters][google.cloud.security.privateca.v1.X509Parameters] - is used to describe certain fields of an X.509 certificate, such as - the key usage fields, fields specific to CA certificates, - certificate policy extensions and custom extensions. - - Attributes: - key_usage (google.cloud.security.privateca_v1.types.KeyUsage): - Optional. Indicates the intended use for keys - that correspond to a certificate. - ca_options (google.cloud.security.privateca_v1.types.X509Parameters.CaOptions): - Optional. Describes options in this - [X509Parameters][google.cloud.security.privateca.v1.X509Parameters] - that are relevant in a CA certificate. - policy_ids (Sequence[google.cloud.security.privateca_v1.types.ObjectId]): - Optional. Describes the X.509 certificate - policy object identifiers, per - https://tools.ietf.org/html/rfc5280#section-4.2.1.4. - aia_ocsp_servers (Sequence[str]): - Optional. Describes Online Certificate Status - Protocol (OCSP) endpoint addresses that appear - in the "Authority Information Access" extension - in the certificate. - additional_extensions (Sequence[google.cloud.security.privateca_v1.types.X509Extension]): - Optional. Describes custom X.509 extensions. - """ - - class CaOptions(proto.Message): - r"""Describes values that are relevant in a CA certificate. - Attributes: - is_ca (bool): - Optional. Refers to the "CA" X.509 extension, - which is a boolean value. When this value is - missing, the extension will be omitted from the - CA certificate. - max_issuer_path_length (int): - Optional. Refers to the path length - restriction X.509 extension. For a CA - certificate, this value describes the depth of - subordinate CA certificates that are allowed. - If this value is less than 0, the request will - fail. If this value is missing, the max path - length will be omitted from the CA certificate. - """ - - is_ca = proto.Field( - proto.BOOL, - number=1, - optional=True, - ) - max_issuer_path_length = proto.Field( - proto.INT32, - number=2, - optional=True, - ) - - key_usage = proto.Field( - proto.MESSAGE, - number=1, - message='KeyUsage', - ) - ca_options = proto.Field( - proto.MESSAGE, - number=2, - message=CaOptions, - ) - policy_ids = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='ObjectId', - ) - aia_ocsp_servers = proto.RepeatedField( - proto.STRING, - number=4, - ) - additional_extensions = proto.RepeatedField( - proto.MESSAGE, - number=5, - message='X509Extension', - ) - - -class SubordinateConfig(proto.Message): - r"""Describes a subordinate CA's issuers. This is either a resource name - to a known issuing - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority], - or a PEM issuer certificate chain. - - Attributes: - certificate_authority (str): - Required. This can refer to a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the same project that was used to create a subordinate - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - This field is used for information and usability purposes - only. The resource name is in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - pem_issuer_chain (google.cloud.security.privateca_v1.types.SubordinateConfig.SubordinateConfigChain): - Required. Contains the PEM certificate chain for the issuers - of this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority], - but not pem certificate for this CA itself. - """ - - class SubordinateConfigChain(proto.Message): - r"""This message describes a subordinate CA's issuer certificate - chain. This wrapper exists for compatibility reasons. - - Attributes: - pem_certificates (Sequence[str]): - Required. Expected to be in leaf-to-root - order according to RFC 5246. - """ - - pem_certificates = proto.RepeatedField( - proto.STRING, - number=1, - ) - - certificate_authority = proto.Field( - proto.STRING, - number=1, - oneof='subordinate_config', - ) - pem_issuer_chain = proto.Field( - proto.MESSAGE, - number=2, - oneof='subordinate_config', - message=SubordinateConfigChain, - ) - - -class PublicKey(proto.Message): - r"""A [PublicKey][google.cloud.security.privateca.v1.PublicKey] - describes a public key. - - Attributes: - key (bytes): - Required. A public key. The padding and encoding must match - with the ``KeyFormat`` value specified for the ``format`` - field. - format_ (google.cloud.security.privateca_v1.types.PublicKey.KeyFormat): - Required. The format of the public key. - """ - class KeyFormat(proto.Enum): - r"""Types of public keys formats that are supported. Currently, only - ``PEM`` format is supported. - """ - KEY_FORMAT_UNSPECIFIED = 0 - PEM = 1 - - key = proto.Field( - proto.BYTES, - number=1, - ) - format_ = proto.Field( - proto.ENUM, - number=2, - enum=KeyFormat, - ) - - -class CertificateConfig(proto.Message): - r"""A - [CertificateConfig][google.cloud.security.privateca.v1.CertificateConfig] - describes an X.509 certificate or CSR that is to be created, as an - alternative to using ASN.1. - - Attributes: - subject_config (google.cloud.security.privateca_v1.types.CertificateConfig.SubjectConfig): - Required. Specifies some of the values in a - certificate that are related to the subject. - x509_config (google.cloud.security.privateca_v1.types.X509Parameters): - Required. Describes how some of the technical - X.509 fields in a certificate should be - populated. - public_key (google.cloud.security.privateca_v1.types.PublicKey): - Optional. The public key that corresponds to this config. - This is, for example, used when issuing - [Certificates][google.cloud.security.privateca.v1.Certificate], - but not when creating a self-signed - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - or - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - CSR. - """ - - class SubjectConfig(proto.Message): - r"""These values are used to create the distinguished name and - subject alternative name fields in an X.509 certificate. - - Attributes: - subject (google.cloud.security.privateca_v1.types.Subject): - Required. Contains distinguished name fields - such as the common name, location and - organization. - subject_alt_name (google.cloud.security.privateca_v1.types.SubjectAltNames): - Optional. The subject alternative name - fields. - """ - - subject = proto.Field( - proto.MESSAGE, - number=1, - message='Subject', - ) - subject_alt_name = proto.Field( - proto.MESSAGE, - number=2, - message='SubjectAltNames', - ) - - subject_config = proto.Field( - proto.MESSAGE, - number=1, - message=SubjectConfig, - ) - x509_config = proto.Field( - proto.MESSAGE, - number=2, - message='X509Parameters', - ) - public_key = proto.Field( - proto.MESSAGE, - number=3, - message='PublicKey', - ) - - -class CertificateDescription(proto.Message): - r"""A - [CertificateDescription][google.cloud.security.privateca.v1.CertificateDescription] - describes an X.509 certificate or CSR that has been issued, as an - alternative to using ASN.1 / X.509. - - Attributes: - subject_description (google.cloud.security.privateca_v1.types.CertificateDescription.SubjectDescription): - Describes some of the values in a certificate - that are related to the subject and lifetime. - x509_description (google.cloud.security.privateca_v1.types.X509Parameters): - Describes some of the technical X.509 fields - in a certificate. - public_key (google.cloud.security.privateca_v1.types.PublicKey): - The public key that corresponds to an issued - certificate. - subject_key_id (google.cloud.security.privateca_v1.types.CertificateDescription.KeyId): - Provides a means of identifiying certificates - that contain a particular public key, per - https://tools.ietf.org/html/rfc5280#section-4.2.1.2. - authority_key_id (google.cloud.security.privateca_v1.types.CertificateDescription.KeyId): - Identifies the subject_key_id of the parent certificate, per - https://tools.ietf.org/html/rfc5280#section-4.2.1.1 - crl_distribution_points (Sequence[str]): - Describes a list of locations to obtain CRL - information, i.e. the DistributionPoint.fullName - described by - https://tools.ietf.org/html/rfc5280#section-4.2.1.13 - aia_issuing_certificate_urls (Sequence[str]): - Describes lists of issuer CA certificate URLs - that appear in the "Authority Information - Access" extension in the certificate. - cert_fingerprint (google.cloud.security.privateca_v1.types.CertificateDescription.CertificateFingerprint): - The hash of the x.509 certificate. - """ - - class SubjectDescription(proto.Message): - r"""These values describe fields in an issued X.509 certificate - such as the distinguished name, subject alternative names, - serial number, and lifetime. - - Attributes: - subject (google.cloud.security.privateca_v1.types.Subject): - Contains distinguished name fields such as - the common name, location and / organization. - subject_alt_name (google.cloud.security.privateca_v1.types.SubjectAltNames): - The subject alternative name fields. - hex_serial_number (str): - The serial number encoded in lowercase - hexadecimal. - lifetime (google.protobuf.duration_pb2.Duration): - For convenience, the actual lifetime of an issued - certificate. Corresponds to 'not_after_time' - - 'not_before_time'. - not_before_time (google.protobuf.timestamp_pb2.Timestamp): - The time at which the certificate becomes - valid. - not_after_time (google.protobuf.timestamp_pb2.Timestamp): - The time at which the certificate expires. - """ - - subject = proto.Field( - proto.MESSAGE, - number=1, - message='Subject', - ) - subject_alt_name = proto.Field( - proto.MESSAGE, - number=2, - message='SubjectAltNames', - ) - hex_serial_number = proto.Field( - proto.STRING, - number=3, - ) - lifetime = proto.Field( - proto.MESSAGE, - number=4, - message=duration_pb2.Duration, - ) - not_before_time = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - not_after_time = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - - class KeyId(proto.Message): - r"""A KeyId identifies a specific public key, usually by hashing - the public key. - - Attributes: - key_id (str): - Optional. The value of this KeyId encoded in - lowercase hexadecimal. This is most likely the - 160 bit SHA-1 hash of the public key. - """ - - key_id = proto.Field( - proto.STRING, - number=1, - ) - - class CertificateFingerprint(proto.Message): - r"""A group of fingerprints for the x509 certificate. - Attributes: - sha256_hash (str): - The SHA 256 hash, encoded in hexadecimal, of - the DER x509 certificate. - """ - - sha256_hash = proto.Field( - proto.STRING, - number=1, - ) - - subject_description = proto.Field( - proto.MESSAGE, - number=1, - message=SubjectDescription, - ) - x509_description = proto.Field( - proto.MESSAGE, - number=2, - message='X509Parameters', - ) - public_key = proto.Field( - proto.MESSAGE, - number=3, - message='PublicKey', - ) - subject_key_id = proto.Field( - proto.MESSAGE, - number=4, - message=KeyId, - ) - authority_key_id = proto.Field( - proto.MESSAGE, - number=5, - message=KeyId, - ) - crl_distribution_points = proto.RepeatedField( - proto.STRING, - number=6, - ) - aia_issuing_certificate_urls = proto.RepeatedField( - proto.STRING, - number=7, - ) - cert_fingerprint = proto.Field( - proto.MESSAGE, - number=8, - message=CertificateFingerprint, - ) - - -class ObjectId(proto.Message): - r"""An [ObjectId][google.cloud.security.privateca.v1.ObjectId] specifies - an object identifier (OID). These provide context and describe types - in ASN.1 messages. - - Attributes: - object_id_path (Sequence[int]): - Required. The parts of an OID path. The most - significant parts of the path come first. - """ - - object_id_path = proto.RepeatedField( - proto.INT32, - number=1, - ) - - -class X509Extension(proto.Message): - r"""An [X509Extension][google.cloud.security.privateca.v1.X509Extension] - specifies an X.509 extension, which may be used in different parts - of X.509 objects like certificates, CSRs, and CRLs. - - Attributes: - object_id (google.cloud.security.privateca_v1.types.ObjectId): - Required. The OID for this X.509 extension. - critical (bool): - Required. Indicates whether or not this - extension is critical (i.e., if the client does - not know how to handle this extension, the - client should consider this to be an error). - value (bytes): - Required. The value of this X.509 extension. - """ - - object_id = proto.Field( - proto.MESSAGE, - number=1, - message='ObjectId', - ) - critical = proto.Field( - proto.BOOL, - number=2, - ) - value = proto.Field( - proto.BYTES, - number=3, - ) - - -class KeyUsage(proto.Message): - r"""A [KeyUsage][google.cloud.security.privateca.v1.KeyUsage] describes - key usage values that may appear in an X.509 certificate. - - Attributes: - base_key_usage (google.cloud.security.privateca_v1.types.KeyUsage.KeyUsageOptions): - Describes high-level ways in which a key may - be used. - extended_key_usage (google.cloud.security.privateca_v1.types.KeyUsage.ExtendedKeyUsageOptions): - Detailed scenarios in which a key may be - used. - unknown_extended_key_usages (Sequence[google.cloud.security.privateca_v1.types.ObjectId]): - Used to describe extended key usages that are not listed in - the - [KeyUsage.ExtendedKeyUsageOptions][google.cloud.security.privateca.v1.KeyUsage.ExtendedKeyUsageOptions] - message. - """ - - class KeyUsageOptions(proto.Message): - r"""[KeyUsage.KeyUsageOptions][google.cloud.security.privateca.v1.KeyUsage.KeyUsageOptions] - corresponds to the key usage values described in - https://tools.ietf.org/html/rfc5280#section-4.2.1.3. - - Attributes: - digital_signature (bool): - The key may be used for digital signatures. - content_commitment (bool): - The key may be used for cryptographic - commitments. Note that this may also be referred - to as "non-repudiation". - key_encipherment (bool): - The key may be used to encipher other keys. - data_encipherment (bool): - The key may be used to encipher data. - key_agreement (bool): - The key may be used in a key agreement - protocol. - cert_sign (bool): - The key may be used to sign certificates. - crl_sign (bool): - The key may be used sign certificate - revocation lists. - encipher_only (bool): - The key may be used to encipher only. - decipher_only (bool): - The key may be used to decipher only. - """ - - digital_signature = proto.Field( - proto.BOOL, - number=1, - ) - content_commitment = proto.Field( - proto.BOOL, - number=2, - ) - key_encipherment = proto.Field( - proto.BOOL, - number=3, - ) - data_encipherment = proto.Field( - proto.BOOL, - number=4, - ) - key_agreement = proto.Field( - proto.BOOL, - number=5, - ) - cert_sign = proto.Field( - proto.BOOL, - number=6, - ) - crl_sign = proto.Field( - proto.BOOL, - number=7, - ) - encipher_only = proto.Field( - proto.BOOL, - number=8, - ) - decipher_only = proto.Field( - proto.BOOL, - number=9, - ) - - class ExtendedKeyUsageOptions(proto.Message): - r"""[KeyUsage.ExtendedKeyUsageOptions][google.cloud.security.privateca.v1.KeyUsage.ExtendedKeyUsageOptions] - has fields that correspond to certain common OIDs that could be - specified as an extended key usage value. - - Attributes: - server_auth (bool): - Corresponds to OID 1.3.6.1.5.5.7.3.1. - Officially described as "TLS WWW server - authentication", though regularly used for non- - WWW TLS. - client_auth (bool): - Corresponds to OID 1.3.6.1.5.5.7.3.2. - Officially described as "TLS WWW client - authentication", though regularly used for non- - WWW TLS. - code_signing (bool): - Corresponds to OID 1.3.6.1.5.5.7.3.3. - Officially described as "Signing of downloadable - executable code client authentication". - email_protection (bool): - Corresponds to OID 1.3.6.1.5.5.7.3.4. - Officially described as "Email protection". - time_stamping (bool): - Corresponds to OID 1.3.6.1.5.5.7.3.8. - Officially described as "Binding the hash of an - object to a time". - ocsp_signing (bool): - Corresponds to OID 1.3.6.1.5.5.7.3.9. - Officially described as "Signing OCSP - responses". - """ - - server_auth = proto.Field( - proto.BOOL, - number=1, - ) - client_auth = proto.Field( - proto.BOOL, - number=2, - ) - code_signing = proto.Field( - proto.BOOL, - number=3, - ) - email_protection = proto.Field( - proto.BOOL, - number=4, - ) - time_stamping = proto.Field( - proto.BOOL, - number=5, - ) - ocsp_signing = proto.Field( - proto.BOOL, - number=6, - ) - - base_key_usage = proto.Field( - proto.MESSAGE, - number=1, - message=KeyUsageOptions, - ) - extended_key_usage = proto.Field( - proto.MESSAGE, - number=2, - message=ExtendedKeyUsageOptions, - ) - unknown_extended_key_usages = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='ObjectId', - ) - - -class Subject(proto.Message): - r"""[Subject][google.cloud.security.privateca.v1.Subject] describes - parts of a distinguished name that, in turn, describes the subject - of the certificate. - - Attributes: - common_name (str): - The "common name" of the subject. - country_code (str): - The country code of the subject. - organization (str): - The organization of the subject. - organizational_unit (str): - The organizational_unit of the subject. - locality (str): - The locality or city of the subject. - province (str): - The province, territory, or regional state of - the subject. - street_address (str): - The street address of the subject. - postal_code (str): - The postal code of the subject. - """ - - common_name = proto.Field( - proto.STRING, - number=1, - ) - country_code = proto.Field( - proto.STRING, - number=2, - ) - organization = proto.Field( - proto.STRING, - number=3, - ) - organizational_unit = proto.Field( - proto.STRING, - number=4, - ) - locality = proto.Field( - proto.STRING, - number=5, - ) - province = proto.Field( - proto.STRING, - number=6, - ) - street_address = proto.Field( - proto.STRING, - number=7, - ) - postal_code = proto.Field( - proto.STRING, - number=8, - ) - - -class SubjectAltNames(proto.Message): - r"""[SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames] - corresponds to a more modern way of listing what the asserted - identity is in a certificate (i.e., compared to the "common name" in - the distinguished name). - - Attributes: - dns_names (Sequence[str]): - Contains only valid, fully-qualified host - names. - uris (Sequence[str]): - Contains only valid RFC 3986 URIs. - email_addresses (Sequence[str]): - Contains only valid RFC 2822 E-mail - addresses. - ip_addresses (Sequence[str]): - Contains only valid 32-bit IPv4 addresses or - RFC 4291 IPv6 addresses. - custom_sans (Sequence[google.cloud.security.privateca_v1.types.X509Extension]): - Contains additional subject alternative name - values. - """ - - dns_names = proto.RepeatedField( - proto.STRING, - number=1, - ) - uris = proto.RepeatedField( - proto.STRING, - number=2, - ) - email_addresses = proto.RepeatedField( - proto.STRING, - number=3, - ) - ip_addresses = proto.RepeatedField( - proto.STRING, - number=4, - ) - custom_sans = proto.RepeatedField( - proto.MESSAGE, - number=5, - message='X509Extension', - ) - - -class CertificateIdentityConstraints(proto.Message): - r"""Describes constraints on a - [Certificate][google.cloud.security.privateca.v1.Certificate]'s - [Subject][google.cloud.security.privateca.v1.Subject] and - [SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames]. - - Attributes: - cel_expression (google.type.expr_pb2.Expr): - Optional. A CEL expression that may be used - to validate the resolved X.509 Subject and/or - Subject Alternative Name before a certificate is - signed. To see the full allowed syntax and some - examples, see - https://cloud.google.com/certificate-authority- - service/docs/cel-guide - allow_subject_passthrough (bool): - Required. If this is true, the - [Subject][google.cloud.security.privateca.v1.Subject] field - may be copied from a certificate request into the signed - certificate. Otherwise, the requested - [Subject][google.cloud.security.privateca.v1.Subject] will - be discarded. The bool is optional to indicate an unset - field, which suggests a forgotten value that needs to be set - by the caller. - allow_subject_alt_names_passthrough (bool): - Required. If this is true, the - [SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames] - extension may be copied from a certificate request into the - signed certificate. Otherwise, the requested - [SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames] - will be discarded. The bool is optional to indicate an unset - field, which suggests a forgotten value that needs to be set - by the caller. - """ - - cel_expression = proto.Field( - proto.MESSAGE, - number=1, - message=expr_pb2.Expr, - ) - allow_subject_passthrough = proto.Field( - proto.BOOL, - number=2, - optional=True, - ) - allow_subject_alt_names_passthrough = proto.Field( - proto.BOOL, - number=3, - optional=True, - ) - - -class CertificateExtensionConstraints(proto.Message): - r"""Describes a set of X.509 extensions that may be part of some - certificate issuance controls. - - Attributes: - known_extensions (Sequence[google.cloud.security.privateca_v1.types.CertificateExtensionConstraints.KnownCertificateExtension]): - Optional. A set of named X.509 extensions. Will be combined - with - [additional_extensions][google.cloud.security.privateca.v1.CertificateExtensionConstraints.additional_extensions] - to determine the full set of X.509 extensions. - additional_extensions (Sequence[google.cloud.security.privateca_v1.types.ObjectId]): - Optional. A set of - [ObjectIds][google.cloud.security.privateca.v1.ObjectId] - identifying custom X.509 extensions. Will be combined with - [known_extensions][google.cloud.security.privateca.v1.CertificateExtensionConstraints.known_extensions] - to determine the full set of X.509 extensions. - """ - class KnownCertificateExtension(proto.Enum): - r"""Describes well-known X.509 extensions that can appear in a - [Certificate][google.cloud.security.privateca.v1.Certificate], not - including the - [SubjectAltNames][google.cloud.security.privateca.v1.SubjectAltNames] - extension. - """ - KNOWN_CERTIFICATE_EXTENSION_UNSPECIFIED = 0 - BASE_KEY_USAGE = 1 - EXTENDED_KEY_USAGE = 2 - CA_OPTIONS = 3 - POLICY_IDS = 4 - AIA_OCSP_SERVERS = 5 - - known_extensions = proto.RepeatedField( - proto.ENUM, - number=1, - enum=KnownCertificateExtension, - ) - additional_extensions = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='ObjectId', - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/service.py b/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/service.py deleted file mode 100644 index b4b7f43..0000000 --- a/owl-bot-staging/v1/google/cloud/security/privateca_v1/types/service.py +++ /dev/null @@ -1,1656 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import proto # type: ignore - -from google.cloud.security.privateca_v1.types import resources -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.security.privateca.v1', - manifest={ - 'CreateCertificateRequest', - 'GetCertificateRequest', - 'ListCertificatesRequest', - 'ListCertificatesResponse', - 'RevokeCertificateRequest', - 'UpdateCertificateRequest', - 'ActivateCertificateAuthorityRequest', - 'CreateCertificateAuthorityRequest', - 'DisableCertificateAuthorityRequest', - 'EnableCertificateAuthorityRequest', - 'FetchCertificateAuthorityCsrRequest', - 'FetchCertificateAuthorityCsrResponse', - 'GetCertificateAuthorityRequest', - 'ListCertificateAuthoritiesRequest', - 'ListCertificateAuthoritiesResponse', - 'UndeleteCertificateAuthorityRequest', - 'DeleteCertificateAuthorityRequest', - 'UpdateCertificateAuthorityRequest', - 'CreateCaPoolRequest', - 'UpdateCaPoolRequest', - 'DeleteCaPoolRequest', - 'FetchCaCertsRequest', - 'FetchCaCertsResponse', - 'GetCaPoolRequest', - 'ListCaPoolsRequest', - 'ListCaPoolsResponse', - 'GetCertificateRevocationListRequest', - 'ListCertificateRevocationListsRequest', - 'ListCertificateRevocationListsResponse', - 'UpdateCertificateRevocationListRequest', - 'CreateCertificateTemplateRequest', - 'DeleteCertificateTemplateRequest', - 'GetCertificateTemplateRequest', - 'ListCertificateTemplatesRequest', - 'ListCertificateTemplatesResponse', - 'UpdateCertificateTemplateRequest', - 'OperationMetadata', - }, -) - - -class CreateCertificateRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.CreateCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificate]. - - Attributes: - parent (str): - Required. The resource name of the - [CaPool][google.cloud.security.privateca.v1.CaPool] - associated with the - [Certificate][google.cloud.security.privateca.v1.Certificate], - in the format ``projects/*/locations/*/caPools/*``. - certificate_id (str): - Optional. It must be unique within a location and match the - regular expression ``[a-zA-Z0-9_-]{1,63}``. This field is - required when using a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the Enterprise [CertificateAuthority.Tier][], but is - optional and its value is ignored otherwise. - certificate (google.cloud.security.privateca_v1.types.Certificate): - Required. A - [Certificate][google.cloud.security.privateca.v1.Certificate] - with initial field values. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - validate_only (bool): - Optional. If this is true, no - [Certificate][google.cloud.security.privateca.v1.Certificate] - resource will be persisted regardless of the - [CaPool][google.cloud.security.privateca.v1.CaPool]'s - [tier][google.cloud.security.privateca.v1.CaPool.tier], and - the returned - [Certificate][google.cloud.security.privateca.v1.Certificate] - will not contain the - [pem_certificate][google.cloud.security.privateca.v1.Certificate.pem_certificate] - field. - issuing_certificate_authority_id (str): - Optional. The resource ID of the - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - that should issue the certificate. This optional field will - ignore the load-balancing scheme of the Pool and directly - issue the certificate from the CA with the specified ID, - contained in the same - [CaPool][google.cloud.security.privateca.v1.CaPool] - referenced by ``parent``. Per-CA quota rules apply. If left - empty, a - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - will be chosen from the - [CaPool][google.cloud.security.privateca.v1.CaPool] by the - service. For example, to issue a - [Certificate][google.cloud.security.privateca.v1.Certificate] - from a Certificate Authority with resource name - "projects/my-project/locations/us-central1/caPools/my-pool/certificateAuthorities/my-ca", - you can set the - [parent][google.cloud.security.privateca.v1.CreateCertificateRequest.parent] - to - "projects/my-project/locations/us-central1/caPools/my-pool" - and the - [issuing_certificate_authority_id][google.cloud.security.privateca.v1.CreateCertificateRequest.issuing_certificate_authority_id] - to "my-ca". - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - certificate_id = proto.Field( - proto.STRING, - number=2, - ) - certificate = proto.Field( - proto.MESSAGE, - number=3, - message=resources.Certificate, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - validate_only = proto.Field( - proto.BOOL, - number=5, - ) - issuing_certificate_authority_id = proto.Field( - proto.STRING, - number=6, - ) - - -class GetCertificateRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.GetCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificate]. - - Attributes: - name (str): - Required. The - [name][google.cloud.security.privateca.v1.Certificate.name] - of the - [Certificate][google.cloud.security.privateca.v1.Certificate] - to get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListCertificatesRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificates]. - - Attributes: - parent (str): - Required. The resource name of the location associated with - the - [Certificates][google.cloud.security.privateca.v1.Certificate], - in the format ``projects/*/locations/*/caPools/*``. - page_size (int): - Optional. Limit on the number of - [Certificates][google.cloud.security.privateca.v1.Certificate] - to include in the response. Further - [Certificates][google.cloud.security.privateca.v1.Certificate] - can subsequently be obtained by including the - [ListCertificatesResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificatesResponse.next_page_token] - in a subsequent request. If unspecified, the server will - pick an appropriate default. - page_token (str): - Optional. Pagination token, returned earlier via - [ListCertificatesResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificatesResponse.next_page_token]. - filter (str): - Optional. Only include resources that match the filter in - the response. For details on supported filters and syntax, - see `Certificates Filtering - documentation `__. - order_by (str): - Optional. Specify how the results should be sorted. For - details on supported fields and syntax, see `Certificates - Sorting - documentation `__. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCertificatesResponse(proto.Message): - r"""Response message for - [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificates]. - - Attributes: - certificates (Sequence[google.cloud.security.privateca_v1.types.Certificate]): - The list of - [Certificates][google.cloud.security.privateca.v1.Certificate]. - next_page_token (str): - A token to retrieve next page of results. Pass this value in - [ListCertificatesRequest.next_page_token][] to retrieve the - next page of results. - unreachable (Sequence[str]): - A list of locations (e.g. "us-west1") that - could not be reached. - """ - - @property - def raw_page(self): - return self - - certificates = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.Certificate, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class RevokeCertificateRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.RevokeCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.RevokeCertificate]. - - Attributes: - name (str): - Required. The resource name for this - [Certificate][google.cloud.security.privateca.v1.Certificate] - in the format - ``projects/*/locations/*/caPools/*/certificates/*``. - reason (google.cloud.security.privateca_v1.types.RevocationReason): - Required. The - [RevocationReason][google.cloud.security.privateca.v1.RevocationReason] - for revoking this certificate. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - reason = proto.Field( - proto.ENUM, - number=2, - enum=resources.RevocationReason, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - - -class UpdateCertificateRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.UpdateCertificate][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificate]. - - Attributes: - certificate (google.cloud.security.privateca_v1.types.Certificate): - Required. - [Certificate][google.cloud.security.privateca.v1.Certificate] - with updated values. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be updated in - this request. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - certificate = proto.Field( - proto.MESSAGE, - number=1, - message=resources.Certificate, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - - -class ActivateCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - pem_ca_certificate (str): - Required. The signed CA certificate issued from - [FetchCertificateAuthorityCsrResponse.pem_csr][google.cloud.security.privateca.v1.FetchCertificateAuthorityCsrResponse.pem_csr]. - subordinate_config (google.cloud.security.privateca_v1.types.SubordinateConfig): - Required. Must include information about the issuer of - 'pem_ca_certificate', and any further issuers until the - self-signed CA. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - pem_ca_certificate = proto.Field( - proto.STRING, - number=2, - ) - subordinate_config = proto.Field( - proto.MESSAGE, - number=3, - message=resources.SubordinateConfig, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - - -class CreateCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.CreateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificateAuthority]. - - Attributes: - parent (str): - Required. The resource name of the - [CaPool][google.cloud.security.privateca.v1.CaPool] - associated with the - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority], - in the format ``projects/*/locations/*/caPools/*``. - certificate_authority_id (str): - Required. It must be unique within a location and match the - regular expression ``[a-zA-Z0-9_-]{1,63}`` - certificate_authority (google.cloud.security.privateca_v1.types.CertificateAuthority): - Required. A - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - with initial field values. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - certificate_authority_id = proto.Field( - proto.STRING, - number=2, - ) - certificate_authority = proto.Field( - proto.MESSAGE, - number=3, - message=resources.CertificateAuthority, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - - -class DisableCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.DisableCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.DisableCertificateAuthority]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class EnableCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.EnableCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.EnableCertificateAuthority]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class FetchCertificateAuthorityCsrRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class FetchCertificateAuthorityCsrResponse(proto.Message): - r"""Response message for - [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. - - Attributes: - pem_csr (str): - Output only. The PEM-encoded signed - certificate signing request (CSR). - """ - - pem_csr = proto.Field( - proto.STRING, - number=1, - ) - - -class GetCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.GetCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateAuthority]. - - Attributes: - name (str): - Required. The - [name][google.cloud.security.privateca.v1.CertificateAuthority.name] - of the - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - to get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListCertificateAuthoritiesRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateAuthorities]. - - Attributes: - parent (str): - Required. The resource name of the - [CaPool][google.cloud.security.privateca.v1.CaPool] - associated with the - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority], - in the format ``projects/*/locations/*/caPools/*``. - page_size (int): - Optional. Limit on the number of - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] - to include in the response. Further - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority] - can subsequently be obtained by including the - [ListCertificateAuthoritiesResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificateAuthoritiesResponse.next_page_token] - in a subsequent request. If unspecified, the server will - pick an appropriate default. - page_token (str): - Optional. Pagination token, returned earlier via - [ListCertificateAuthoritiesResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificateAuthoritiesResponse.next_page_token]. - filter (str): - Optional. Only include resources that match - the filter in the response. - order_by (str): - Optional. Specify how the results should be - sorted. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCertificateAuthoritiesResponse(proto.Message): - r"""Response message for - [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateAuthorities]. - - Attributes: - certificate_authorities (Sequence[google.cloud.security.privateca_v1.types.CertificateAuthority]): - The list of - [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. - next_page_token (str): - A token to retrieve next page of results. Pass this value in - [ListCertificateAuthoritiesRequest.next_page_token][] to - retrieve the next page of results. - unreachable (Sequence[str]): - A list of locations (e.g. "us-west1") that - could not be reached. - """ - - @property - def raw_page(self): - return self - - certificate_authorities = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.CertificateAuthority, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class UndeleteCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.UndeleteCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.UndeleteCertificateAuthority]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class DeleteCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.DeleteCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCertificateAuthority]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - ignore_active_certificates (bool): - Optional. This field allows the CA to be - deleted even if the CA has active certs. Active - certs include both unrevoked and unexpired - certs. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - ignore_active_certificates = proto.Field( - proto.BOOL, - number=4, - ) - - -class UpdateCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.UpdateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateAuthority]. - - Attributes: - certificate_authority (google.cloud.security.privateca_v1.types.CertificateAuthority): - Required. - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - with updated values. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be updated in - this request. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - certificate_authority = proto.Field( - proto.MESSAGE, - number=1, - message=resources.CertificateAuthority, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - - -class CreateCaPoolRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.CreateCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCaPool]. - - Attributes: - parent (str): - Required. The resource name of the location associated with - the [CaPool][google.cloud.security.privateca.v1.CaPool], in - the format ``projects/*/locations/*``. - ca_pool_id (str): - Required. It must be unique within a location and match the - regular expression ``[a-zA-Z0-9_-]{1,63}`` - ca_pool (google.cloud.security.privateca_v1.types.CaPool): - Required. A - [CaPool][google.cloud.security.privateca.v1.CaPool] with - initial field values. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - ca_pool_id = proto.Field( - proto.STRING, - number=2, - ) - ca_pool = proto.Field( - proto.MESSAGE, - number=3, - message=resources.CaPool, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - - -class UpdateCaPoolRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.UpdateCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCaPool]. - - Attributes: - ca_pool (google.cloud.security.privateca_v1.types.CaPool): - Required. - [CaPool][google.cloud.security.privateca.v1.CaPool] with - updated values. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be updated in - this request. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - ca_pool = proto.Field( - proto.MESSAGE, - number=1, - message=resources.CaPool, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - - -class DeleteCaPoolRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.DeleteCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCaPool]. - - Attributes: - name (str): - Required. The resource name for this - [CaPool][google.cloud.security.privateca.v1.CaPool] in the - format ``projects/*/locations/*/caPools/*``. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class FetchCaCertsRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.FetchCaCerts][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCaCerts]. - - Attributes: - ca_pool (str): - Required. The resource name for the - [CaPool][google.cloud.security.privateca.v1.CaPool] in the - format ``projects/*/locations/*/caPools/*``. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - ca_pool = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class FetchCaCertsResponse(proto.Message): - r"""Response message for - [CertificateAuthorityService.FetchCaCerts][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCaCerts]. - - Attributes: - ca_certs (Sequence[google.cloud.security.privateca_v1.types.FetchCaCertsResponse.CertChain]): - The PEM encoded CA certificate chains of all - [ACTIVE][CertificateAuthority.State.ACTIVE] - [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - resources in this - [CaPool][google.cloud.security.privateca.v1.CaPool]. - """ - - class CertChain(proto.Message): - r""" - Attributes: - certificates (Sequence[str]): - The certificates that form the CA chain, from - leaf to root order. - """ - - certificates = proto.RepeatedField( - proto.STRING, - number=1, - ) - - ca_certs = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=CertChain, - ) - - -class GetCaPoolRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.GetCaPool][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCaPool]. - - Attributes: - name (str): - Required. The - [name][google.cloud.security.privateca.v1.CaPool.name] of - the [CaPool][google.cloud.security.privateca.v1.CaPool] to - get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListCaPoolsRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.ListCaPools][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCaPools]. - - Attributes: - parent (str): - Required. The resource name of the location associated with - the [CaPools][google.cloud.security.privateca.v1.CaPool], in - the format ``projects/*/locations/*``. - page_size (int): - Optional. Limit on the number of - [CaPools][google.cloud.security.privateca.v1.CaPool] to - include in the response. Further - [CaPools][google.cloud.security.privateca.v1.CaPool] can - subsequently be obtained by including the - [ListCaPoolsResponse.next_page_token][google.cloud.security.privateca.v1.ListCaPoolsResponse.next_page_token] - in a subsequent request. If unspecified, the server will - pick an appropriate default. - page_token (str): - Optional. Pagination token, returned earlier via - [ListCaPoolsResponse.next_page_token][google.cloud.security.privateca.v1.ListCaPoolsResponse.next_page_token]. - filter (str): - Optional. Only include resources that match - the filter in the response. - order_by (str): - Optional. Specify how the results should be - sorted. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCaPoolsResponse(proto.Message): - r"""Response message for - [CertificateAuthorityService.ListCaPools][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCaPools]. - - Attributes: - ca_pools (Sequence[google.cloud.security.privateca_v1.types.CaPool]): - The list of - [CaPools][google.cloud.security.privateca.v1.CaPool]. - next_page_token (str): - A token to retrieve next page of results. Pass this value in - [ListCertificateAuthoritiesRequest.next_page_token][] to - retrieve the next page of results. - unreachable (Sequence[str]): - A list of locations (e.g. "us-west1") that - could not be reached. - """ - - @property - def raw_page(self): - return self - - ca_pools = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.CaPool, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetCertificateRevocationListRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.GetCertificateRevocationList][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateRevocationList]. - - Attributes: - name (str): - Required. The - [name][google.cloud.security.privateca.v1.CertificateRevocationList.name] - of the - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] - to get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListCertificateRevocationListsRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateRevocationLists]. - - Attributes: - parent (str): - Required. The resource name of the location associated with - the - [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList], - in the format - ``projects/*/locations/*/caPools/*/certificateAuthorities/*``. - page_size (int): - Optional. Limit on the number of - [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList] - to include in the response. Further - [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList] - can subsequently be obtained by including the - [ListCertificateRevocationListsResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificateRevocationListsResponse.next_page_token] - in a subsequent request. If unspecified, the server will - pick an appropriate default. - page_token (str): - Optional. Pagination token, returned earlier via - [ListCertificateRevocationListsResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificateRevocationListsResponse.next_page_token]. - filter (str): - Optional. Only include resources that match - the filter in the response. - order_by (str): - Optional. Specify how the results should be - sorted. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCertificateRevocationListsResponse(proto.Message): - r"""Response message for - [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateRevocationLists]. - - Attributes: - certificate_revocation_lists (Sequence[google.cloud.security.privateca_v1.types.CertificateRevocationList]): - The list of - [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. - next_page_token (str): - A token to retrieve next page of results. Pass this value in - [ListCertificateRevocationListsRequest.next_page_token][] to - retrieve the next page of results. - unreachable (Sequence[str]): - A list of locations (e.g. "us-west1") that - could not be reached. - """ - - @property - def raw_page(self): - return self - - certificate_revocation_lists = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.CertificateRevocationList, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class UpdateCertificateRevocationListRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.UpdateCertificateRevocationList][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateRevocationList]. - - Attributes: - certificate_revocation_list (google.cloud.security.privateca_v1.types.CertificateRevocationList): - Required. - [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList] - with updated values. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be updated in - this request. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - certificate_revocation_list = proto.Field( - proto.MESSAGE, - number=1, - message=resources.CertificateRevocationList, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - - -class CreateCertificateTemplateRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.CreateCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.CreateCertificateTemplate]. - - Attributes: - parent (str): - Required. The resource name of the location associated with - the - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate], - in the format ``projects/*/locations/*``. - certificate_template_id (str): - Required. It must be unique within a location and match the - regular expression ``[a-zA-Z0-9_-]{1,63}`` - certificate_template (google.cloud.security.privateca_v1.types.CertificateTemplate): - Required. A - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - with initial field values. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - certificate_template_id = proto.Field( - proto.STRING, - number=2, - ) - certificate_template = proto.Field( - proto.MESSAGE, - number=3, - message=resources.CertificateTemplate, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - - -class DeleteCertificateTemplateRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.DeleteCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.DeleteCertificateTemplate]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - in the format - ``projects/*/locations/*/certificateTemplates/*``. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class GetCertificateTemplateRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.GetCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.GetCertificateTemplate]. - - Attributes: - name (str): - Required. The - [name][google.cloud.security.privateca.v1.CertificateTemplate.name] - of the - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - to get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListCertificateTemplatesRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.ListCertificateTemplates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateTemplates]. - - Attributes: - parent (str): - Required. The resource name of the location associated with - the - [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate], - in the format ``projects/*/locations/*``. - page_size (int): - Optional. Limit on the number of - [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate] - to include in the response. Further - [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate] - can subsequently be obtained by including the - [ListCertificateTemplatesResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificateTemplatesResponse.next_page_token] - in a subsequent request. If unspecified, the server will - pick an appropriate default. - page_token (str): - Optional. Pagination token, returned earlier via - [ListCertificateTemplatesResponse.next_page_token][google.cloud.security.privateca.v1.ListCertificateTemplatesResponse.next_page_token]. - filter (str): - Optional. Only include resources that match - the filter in the response. - order_by (str): - Optional. Specify how the results should be - sorted. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCertificateTemplatesResponse(proto.Message): - r"""Response message for - [CertificateAuthorityService.ListCertificateTemplates][google.cloud.security.privateca.v1.CertificateAuthorityService.ListCertificateTemplates]. - - Attributes: - certificate_templates (Sequence[google.cloud.security.privateca_v1.types.CertificateTemplate]): - The list of - [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. - next_page_token (str): - A token to retrieve next page of results. Pass this value in - [ListCertificateTemplatesRequest.next_page_token][] to - retrieve the next page of results. - unreachable (Sequence[str]): - A list of locations (e.g. "us-west1") that - could not be reached. - """ - - @property - def raw_page(self): - return self - - certificate_templates = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.CertificateTemplate, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class UpdateCertificateTemplateRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.UpdateCertificateTemplate][google.cloud.security.privateca.v1.CertificateAuthorityService.UpdateCertificateTemplate]. - - Attributes: - certificate_template (google.cloud.security.privateca_v1.types.CertificateTemplate): - Required. - [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - with updated values. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be updated in - this request. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - certificate_template = proto.Field( - proto.MESSAGE, - number=1, - message=resources.CertificateTemplate, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - - -class OperationMetadata(proto.Message): - r"""Represents the metadata of the long-running operation. - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - target (str): - Output only. Server-defined resource path for - the target of the operation. - verb (str): - Output only. Name of the verb executed by the - operation. - status_message (str): - Output only. Human-readable status of the - operation, if any. - requested_cancellation (bool): - Output only. Identifies whether the user has requested - cancellation of the operation. Operations that have - successfully been cancelled have [Operation.error][] value - with a [google.rpc.Status.code][google.rpc.Status.code] of - 1, corresponding to ``Code.CANCELLED``. - api_version (str): - Output only. API version used to start the - operation. - """ - - create_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - target = proto.Field( - proto.STRING, - number=3, - ) - verb = proto.Field( - proto.STRING, - number=4, - ) - status_message = proto.Field( - proto.STRING, - number=5, - ) - requested_cancellation = proto.Field( - proto.BOOL, - number=6, - ) - api_version = proto.Field( - proto.STRING, - number=7, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/mypy.ini b/owl-bot-staging/v1/mypy.ini deleted file mode 100644 index 4505b48..0000000 --- a/owl-bot-staging/v1/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.6 -namespace_packages = True diff --git a/owl-bot-staging/v1/noxfile.py b/owl-bot-staging/v1/noxfile.py deleted file mode 100644 index 6d766f1..0000000 --- a/owl-bot-staging/v1/noxfile.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") - - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", -] - -@nox.session(python=['3.6', '3.7', '3.8', '3.9']) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/security/privateca_v1/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python='3.7') -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=['3.6', '3.7']) -def mypy(session): - """Run the type checker.""" - session.install('mypy') - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python='3.6') -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx<3.0.0", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) diff --git a/owl-bot-staging/v1/scripts/fixup_privateca_v1_keywords.py b/owl-bot-staging/v1/scripts/fixup_privateca_v1_keywords.py deleted file mode 100644 index 65447c5..0000000 --- a/owl-bot-staging/v1/scripts/fixup_privateca_v1_keywords.py +++ /dev/null @@ -1,204 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class privatecaCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'activate_certificate_authority': ('name', 'pem_ca_certificate', 'subordinate_config', 'request_id', ), - 'create_ca_pool': ('parent', 'ca_pool_id', 'ca_pool', 'request_id', ), - 'create_certificate': ('parent', 'certificate', 'certificate_id', 'request_id', 'validate_only', 'issuing_certificate_authority_id', ), - 'create_certificate_authority': ('parent', 'certificate_authority_id', 'certificate_authority', 'request_id', ), - 'create_certificate_template': ('parent', 'certificate_template_id', 'certificate_template', 'request_id', ), - 'delete_ca_pool': ('name', 'request_id', ), - 'delete_certificate_authority': ('name', 'request_id', 'ignore_active_certificates', ), - 'delete_certificate_template': ('name', 'request_id', ), - 'disable_certificate_authority': ('name', 'request_id', ), - 'enable_certificate_authority': ('name', 'request_id', ), - 'fetch_ca_certs': ('ca_pool', 'request_id', ), - 'fetch_certificate_authority_csr': ('name', ), - 'get_ca_pool': ('name', ), - 'get_certificate': ('name', ), - 'get_certificate_authority': ('name', ), - 'get_certificate_revocation_list': ('name', ), - 'get_certificate_template': ('name', ), - 'list_ca_pools': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificate_authorities': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificate_revocation_lists': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificate_templates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'revoke_certificate': ('name', 'reason', 'request_id', ), - 'undelete_certificate_authority': ('name', 'request_id', ), - 'update_ca_pool': ('ca_pool', 'update_mask', 'request_id', ), - 'update_certificate': ('certificate', 'update_mask', 'request_id', ), - 'update_certificate_authority': ('certificate_authority', 'update_mask', 'request_id', ), - 'update_certificate_revocation_list': ('certificate_revocation_list', 'update_mask', 'request_id', ), - 'update_certificate_template': ('certificate_template', 'update_mask', 'request_id', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=privatecaCallTransformer(), -): - """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 privateca 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 9796ba8..0000000 --- a/owl-bot-staging/v1/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import io -import os -import setuptools # type: ignore - -version = '0.1.0' - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, 'README.rst') -with io.open(readme_filename, encoding='utf-8') as readme_file: - readme = readme_file.read() - -setuptools.setup( - name='google-cloud-security-privateca', - version=version, - long_description=readme, - packages=setuptools.PEP420PackageFinder.find(), - namespace_packages=('google', 'google.cloud', 'google.cloud.security'), - platforms='Posix; MacOS X; Windows', - include_package_data=True, - install_requires=( - 'google-api-core[grpc] >= 1.22.2, < 2.0.0dev', - 'libcst >= 0.2.5', - 'proto-plus >= 1.15.0', - 'packaging >= 14.3', ), - python_requires='>=3.6', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Topic :: Internet', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - zip_safe=False, -) diff --git a/owl-bot-staging/v1/tests/unit/__init__.py b/owl-bot-staging/v1/tests/unit/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1/tests/unit/gapic/privateca_v1/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/privateca_v1/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1/tests/unit/gapic/privateca_v1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py b/owl-bot-staging/v1/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py deleted file mode 100644 index 9509255..0000000 --- a/owl-bot-staging/v1/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py +++ /dev/null @@ -1,8989 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -import mock -import packaging.version - -import grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.security.privateca_v1.services.certificate_authority_service import CertificateAuthorityServiceAsyncClient -from google.cloud.security.privateca_v1.services.certificate_authority_service import CertificateAuthorityServiceClient -from google.cloud.security.privateca_v1.services.certificate_authority_service import pagers -from google.cloud.security.privateca_v1.services.certificate_authority_service import transports -from google.cloud.security.privateca_v1.services.certificate_authority_service.transports.base import _API_CORE_VERSION -from google.cloud.security.privateca_v1.services.certificate_authority_service.transports.base import _GOOGLE_AUTH_VERSION -from google.cloud.security.privateca_v1.types import resources -from google.cloud.security.privateca_v1.types import service -from google.longrunning import operations_pb2 -from google.oauth2 import service_account -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.type import expr_pb2 # type: ignore -import google.auth - - -# TODO(busunkim): Once google-api-core >= 1.26.0 is required: -# - Delete all the api-core and auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - -requires_api_core_lt_1_26_0 = pytest.mark.skipif( - packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), - reason="This test requires google-api-core < 1.26.0", -) - -requires_api_core_gte_1_26_0 = pytest.mark.skipif( - packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), - reason="This test requires google-api-core >= 1.26.0", -) - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(None) is None - assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class", [ - CertificateAuthorityServiceClient, - CertificateAuthorityServiceAsyncClient, -]) -def test_certificate_authority_service_client_from_service_account_info(client_class): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == 'privateca.googleapis.com:443' - - -@pytest.mark.parametrize("client_class", [ - CertificateAuthorityServiceClient, - CertificateAuthorityServiceAsyncClient, -]) -def test_certificate_authority_service_client_from_service_account_file(client_class): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: - factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == 'privateca.googleapis.com:443' - - -def test_certificate_authority_service_client_get_transport_class(): - transport = CertificateAuthorityServiceClient.get_transport_class() - available_transports = [ - transports.CertificateAuthorityServiceGrpcTransport, - ] - assert transport in available_transports - - transport = CertificateAuthorityServiceClient.get_transport_class("grpc") - assert transport == transports.CertificateAuthorityServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc"), - (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(CertificateAuthorityServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceClient)) -@mock.patch.object(CertificateAuthorityServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceAsyncClient)) -def test_certificate_authority_service_client_client_options(client_class, transport_class, transport_name): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(CertificateAuthorityServiceClient, '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(CertificateAuthorityServiceClient, 'get_transport_class') as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - client = client_class() - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError): - client = client_class() - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc", "true"), - (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc", "false"), - (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(CertificateAuthorityServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceClient)) -@mock.patch.object(CertificateAuthorityServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_certificate_authority_service_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc"), - (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_certificate_authority_service_client_client_options_scopes(client_class, transport_class, transport_name): - # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc"), - (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_certificate_authority_service_client_client_options_credentials_file(client_class, transport_class, transport_name): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_certificate_authority_service_client_client_options_from_dict(): - with mock.patch('google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = CertificateAuthorityServiceClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_create_certificate(transport: str = 'grpc', request_type=service.CreateCertificateRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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 = resources.Certificate( - name='name_value', - issuer_certificate_authority='issuer_certificate_authority_value', - certificate_template='certificate_template_value', - subject_mode=resources.SubjectRequestMode.DEFAULT, - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - pem_csr='pem_csr_value', - ) - 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] == service.CreateCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' - assert response.certificate_template == 'certificate_template_value' - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -def test_create_certificate_from_dict(): - test_create_certificate(request_type=dict) - - -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 = CertificateAuthorityServiceClient( - 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] == service.CreateCertificateRequest() - - -@pytest.mark.asyncio -async def test_create_certificate_async(transport: str = 'grpc_asyncio', request_type=service.CreateCertificateRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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(resources.Certificate( - name='name_value', - issuer_certificate_authority='issuer_certificate_authority_value', - certificate_template='certificate_template_value', - subject_mode=resources.SubjectRequestMode.DEFAULT, - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - )) - 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] == service.CreateCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' - assert response.certificate_template == 'certificate_template_value' - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -@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 = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.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 = resources.Certificate() - 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 = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.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(resources.Certificate()) - 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 = CertificateAuthorityServiceClient( - 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 = resources.Certificate() - # 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=resources.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] - assert args[0].parent == 'parent_value' - assert args[0].certificate == resources.Certificate(name='name_value') - assert args[0].certificate_id == 'certificate_id_value' - - -def test_create_certificate_flattened_error(): - client = CertificateAuthorityServiceClient( - 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( - service.CreateCertificateRequest(), - parent='parent_value', - certificate=resources.Certificate(name='name_value'), - certificate_id='certificate_id_value', - ) - - -@pytest.mark.asyncio -async def test_create_certificate_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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 = resources.Certificate() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) - # 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=resources.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] - assert args[0].parent == 'parent_value' - assert args[0].certificate == resources.Certificate(name='name_value') - assert args[0].certificate_id == 'certificate_id_value' - - -@pytest.mark.asyncio -async def test_create_certificate_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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( - service.CreateCertificateRequest(), - parent='parent_value', - certificate=resources.Certificate(name='name_value'), - certificate_id='certificate_id_value', - ) - - -def test_get_certificate(transport: str = 'grpc', request_type=service.GetCertificateRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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 = resources.Certificate( - name='name_value', - issuer_certificate_authority='issuer_certificate_authority_value', - certificate_template='certificate_template_value', - subject_mode=resources.SubjectRequestMode.DEFAULT, - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - pem_csr='pem_csr_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] == service.GetCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' - assert response.certificate_template == 'certificate_template_value' - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -def test_get_certificate_from_dict(): - test_get_certificate(request_type=dict) - - -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 = CertificateAuthorityServiceClient( - 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] == service.GetCertificateRequest() - - -@pytest.mark.asyncio -async def test_get_certificate_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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(resources.Certificate( - name='name_value', - issuer_certificate_authority='issuer_certificate_authority_value', - certificate_template='certificate_template_value', - subject_mode=resources.SubjectRequestMode.DEFAULT, - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - )) - 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] == service.GetCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' - assert response.certificate_template == 'certificate_template_value' - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -@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 = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.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 = resources.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 = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.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(resources.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 = CertificateAuthorityServiceClient( - 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 = resources.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] - assert args[0].name == 'name_value' - - -def test_get_certificate_flattened_error(): - client = CertificateAuthorityServiceClient( - 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( - service.GetCertificateRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_certificate_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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 = resources.Certificate() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.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] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_certificate_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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( - service.GetCertificateRequest(), - name='name_value', - ) - - -def test_list_certificates(transport: str = 'grpc', request_type=service.ListCertificatesRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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 = service.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] == service.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_from_dict(): - test_list_certificates(request_type=dict) - - -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 = CertificateAuthorityServiceClient( - 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] == service.ListCertificatesRequest() - - -@pytest.mark.asyncio -async def test_list_certificates_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificatesRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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(service.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] == service.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 = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.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 = service.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 = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.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(service.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 = CertificateAuthorityServiceClient( - 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 = service.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] - assert args[0].parent == 'parent_value' - - -def test_list_certificates_flattened_error(): - client = CertificateAuthorityServiceClient( - 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( - service.ListCertificatesRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_certificates_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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 = service.ListCertificatesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.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] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_certificates_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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( - service.ListCertificatesRequest(), - parent='parent_value', - ) - - -def test_list_certificates_pager(): - client = CertificateAuthorityServiceClient( - 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: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - resources.Certificate(), - ], - next_page_token='abc', - ), - service.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - ], - next_page_token='ghi', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_certificates(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.Certificate) - for i in results) - -def test_list_certificates_pages(): - client = CertificateAuthorityServiceClient( - 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: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - resources.Certificate(), - ], - next_page_token='abc', - ), - service.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - ], - next_page_token='ghi', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.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 = CertificateAuthorityServiceAsyncClient( - 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 = ( - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - resources.Certificate(), - ], - next_page_token='abc', - ), - service.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - ], - next_page_token='ghi', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_certificates(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.Certificate) - for i in responses) - -@pytest.mark.asyncio -async def test_list_certificates_async_pages(): - client = CertificateAuthorityServiceAsyncClient( - 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 = ( - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - resources.Certificate(), - ], - next_page_token='abc', - ), - service.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - ], - next_page_token='ghi', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_certificates(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_revoke_certificate(transport: str = 'grpc', request_type=service.RevokeCertificateRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.revoke_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Certificate( - name='name_value', - issuer_certificate_authority='issuer_certificate_authority_value', - certificate_template='certificate_template_value', - subject_mode=resources.SubjectRequestMode.DEFAULT, - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - pem_csr='pem_csr_value', - ) - response = client.revoke_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] == service.RevokeCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' - assert response.certificate_template == 'certificate_template_value' - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -def test_revoke_certificate_from_dict(): - test_revoke_certificate(request_type=dict) - - -def test_revoke_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 = CertificateAuthorityServiceClient( - 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.revoke_certificate), - '__call__') as call: - client.revoke_certificate() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.RevokeCertificateRequest() - - -@pytest.mark.asyncio -async def test_revoke_certificate_async(transport: str = 'grpc_asyncio', request_type=service.RevokeCertificateRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.revoke_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate( - name='name_value', - issuer_certificate_authority='issuer_certificate_authority_value', - certificate_template='certificate_template_value', - subject_mode=resources.SubjectRequestMode.DEFAULT, - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - )) - response = await client.revoke_certificate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.RevokeCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' - assert response.certificate_template == 'certificate_template_value' - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -@pytest.mark.asyncio -async def test_revoke_certificate_async_from_dict(): - await test_revoke_certificate_async(request_type=dict) - - -def test_revoke_certificate_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.RevokeCertificateRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.revoke_certificate), - '__call__') as call: - call.return_value = resources.Certificate() - client.revoke_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_revoke_certificate_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.RevokeCertificateRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.revoke_certificate), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) - await client.revoke_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_revoke_certificate_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.revoke_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Certificate() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.revoke_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] - assert args[0].name == 'name_value' - - -def test_revoke_certificate_flattened_error(): - client = CertificateAuthorityServiceClient( - 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.revoke_certificate( - service.RevokeCertificateRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_revoke_certificate_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.revoke_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Certificate() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.revoke_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] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_revoke_certificate_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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.revoke_certificate( - service.RevokeCertificateRequest(), - name='name_value', - ) - - -def test_update_certificate(transport: str = 'grpc', request_type=service.UpdateCertificateRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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 = resources.Certificate( - name='name_value', - issuer_certificate_authority='issuer_certificate_authority_value', - certificate_template='certificate_template_value', - subject_mode=resources.SubjectRequestMode.DEFAULT, - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - pem_csr='pem_csr_value', - ) - 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] == service.UpdateCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' - assert response.certificate_template == 'certificate_template_value' - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -def test_update_certificate_from_dict(): - test_update_certificate(request_type=dict) - - -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 = CertificateAuthorityServiceClient( - 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] == service.UpdateCertificateRequest() - - -@pytest.mark.asyncio -async def test_update_certificate_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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(resources.Certificate( - name='name_value', - issuer_certificate_authority='issuer_certificate_authority_value', - certificate_template='certificate_template_value', - subject_mode=resources.SubjectRequestMode.DEFAULT, - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - )) - 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] == service.UpdateCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.issuer_certificate_authority == 'issuer_certificate_authority_value' - assert response.certificate_template == 'certificate_template_value' - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -@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 = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateRequest() - - request.certificate.name = 'certificate.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 = resources.Certificate() - 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=certificate.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_certificate_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateRequest() - - request.certificate.name = 'certificate.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(resources.Certificate()) - 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=certificate.name/value', - ) in kw['metadata'] - - -def test_update_certificate_flattened(): - client = CertificateAuthorityServiceClient( - 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 = resources.Certificate() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_certificate( - certificate=resources.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] - assert args[0].certificate == resources.Certificate(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_certificate_flattened_error(): - client = CertificateAuthorityServiceClient( - 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( - service.UpdateCertificateRequest(), - certificate=resources.Certificate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_certificate_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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 = resources.Certificate() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_certificate( - certificate=resources.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] - assert args[0].certificate == resources.Certificate(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_certificate_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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( - service.UpdateCertificateRequest(), - certificate=resources.Certificate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_activate_certificate_authority(transport: str = 'grpc', request_type=service.ActivateCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.activate_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_activate_certificate_authority_from_dict(): - test_activate_certificate_authority(request_type=dict) - - -def test_activate_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - client.activate_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_activate_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.ActivateCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.activate_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_activate_certificate_authority_async_from_dict(): - await test_activate_certificate_authority_async(request_type=dict) - - -def test_activate_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ActivateCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.activate_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_activate_certificate_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ActivateCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.activate_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -def test_activate_certificate_authority_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.activate_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_activate_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.activate_certificate_authority( - service.ActivateCertificateAuthorityRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_activate_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.activate_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_activate_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.activate_certificate_authority( - service.ActivateCertificateAuthorityRequest(), - name='name_value', - ) - - -def test_create_certificate_authority(transport: str = 'grpc', request_type=service.CreateCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_certificate_authority_from_dict(): - test_create_certificate_authority(request_type=dict) - - -def test_create_certificate_authority_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 = CertificateAuthorityServiceClient( - 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_authority), - '__call__') as call: - client.create_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_create_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.CreateCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__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_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_certificate_authority_async_from_dict(): - await test_create_certificate_authority_async(request_type=dict) - - -def test_create_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateCertificateAuthorityRequest() - - 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_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_certificate_authority(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_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateCertificateAuthorityRequest() - - 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_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_certificate_authority(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_authority_flattened(): - client = CertificateAuthorityServiceClient( - 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_authority), - '__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_authority( - parent='parent_value', - certificate_authority=resources.CertificateAuthority(name='name_value'), - certificate_authority_id='certificate_authority_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') - assert args[0].certificate_authority_id == 'certificate_authority_id_value' - - -def test_create_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_authority( - service.CreateCertificateAuthorityRequest(), - parent='parent_value', - certificate_authority=resources.CertificateAuthority(name='name_value'), - certificate_authority_id='certificate_authority_id_value', - ) - - -@pytest.mark.asyncio -async def test_create_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority), - '__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_authority( - parent='parent_value', - certificate_authority=resources.CertificateAuthority(name='name_value'), - certificate_authority_id='certificate_authority_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') - assert args[0].certificate_authority_id == 'certificate_authority_id_value' - - -@pytest.mark.asyncio -async def test_create_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority( - service.CreateCertificateAuthorityRequest(), - parent='parent_value', - certificate_authority=resources.CertificateAuthority(name='name_value'), - certificate_authority_id='certificate_authority_id_value', - ) - - -def test_disable_certificate_authority(transport: str = 'grpc', request_type=service.DisableCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.disable_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.disable_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_disable_certificate_authority_from_dict(): - test_disable_certificate_authority(request_type=dict) - - -def test_disable_certificate_authority_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 = CertificateAuthorityServiceClient( - 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.disable_certificate_authority), - '__call__') as call: - client.disable_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_disable_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.DisableCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.disable_certificate_authority), - '__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.disable_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_disable_certificate_authority_async_from_dict(): - await test_disable_certificate_authority_async(request_type=dict) - - -def test_disable_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.DisableCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.disable_certificate_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.disable_certificate_authority(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_disable_certificate_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.DisableCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.disable_certificate_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.disable_certificate_authority(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_disable_certificate_authority_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.disable_certificate_authority), - '__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.disable_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_disable_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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.disable_certificate_authority( - service.DisableCertificateAuthorityRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_disable_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.disable_certificate_authority), - '__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.disable_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_disable_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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.disable_certificate_authority( - service.DisableCertificateAuthorityRequest(), - name='name_value', - ) - - -def test_enable_certificate_authority(transport: str = 'grpc', request_type=service.EnableCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.enable_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.enable_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_enable_certificate_authority_from_dict(): - test_enable_certificate_authority(request_type=dict) - - -def test_enable_certificate_authority_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 = CertificateAuthorityServiceClient( - 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.enable_certificate_authority), - '__call__') as call: - client.enable_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_enable_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.EnableCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.enable_certificate_authority), - '__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.enable_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_enable_certificate_authority_async_from_dict(): - await test_enable_certificate_authority_async(request_type=dict) - - -def test_enable_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.EnableCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.enable_certificate_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.enable_certificate_authority(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_enable_certificate_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.EnableCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.enable_certificate_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.enable_certificate_authority(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_enable_certificate_authority_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.enable_certificate_authority), - '__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.enable_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_enable_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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.enable_certificate_authority( - service.EnableCertificateAuthorityRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_enable_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.enable_certificate_authority), - '__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.enable_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_enable_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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.enable_certificate_authority( - service.EnableCertificateAuthorityRequest(), - name='name_value', - ) - - -def test_fetch_certificate_authority_csr(transport: str = 'grpc', request_type=service.FetchCertificateAuthorityCsrRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.fetch_certificate_authority_csr), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.FetchCertificateAuthorityCsrResponse( - pem_csr='pem_csr_value', - ) - response = client.fetch_certificate_authority_csr(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCertificateAuthorityCsrRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, service.FetchCertificateAuthorityCsrResponse) - assert response.pem_csr == 'pem_csr_value' - - -def test_fetch_certificate_authority_csr_from_dict(): - test_fetch_certificate_authority_csr(request_type=dict) - - -def test_fetch_certificate_authority_csr_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 = CertificateAuthorityServiceClient( - 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.fetch_certificate_authority_csr), - '__call__') as call: - client.fetch_certificate_authority_csr() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCertificateAuthorityCsrRequest() - - -@pytest.mark.asyncio -async def test_fetch_certificate_authority_csr_async(transport: str = 'grpc_asyncio', request_type=service.FetchCertificateAuthorityCsrRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.fetch_certificate_authority_csr), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCertificateAuthorityCsrResponse( - pem_csr='pem_csr_value', - )) - response = await client.fetch_certificate_authority_csr(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCertificateAuthorityCsrRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, service.FetchCertificateAuthorityCsrResponse) - assert response.pem_csr == 'pem_csr_value' - - -@pytest.mark.asyncio -async def test_fetch_certificate_authority_csr_async_from_dict(): - await test_fetch_certificate_authority_csr_async(request_type=dict) - - -def test_fetch_certificate_authority_csr_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.FetchCertificateAuthorityCsrRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_certificate_authority_csr), - '__call__') as call: - call.return_value = service.FetchCertificateAuthorityCsrResponse() - client.fetch_certificate_authority_csr(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_fetch_certificate_authority_csr_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.FetchCertificateAuthorityCsrRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_certificate_authority_csr), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCertificateAuthorityCsrResponse()) - await client.fetch_certificate_authority_csr(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_fetch_certificate_authority_csr_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_certificate_authority_csr), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.FetchCertificateAuthorityCsrResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.fetch_certificate_authority_csr( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_fetch_certificate_authority_csr_flattened_error(): - client = CertificateAuthorityServiceClient( - 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.fetch_certificate_authority_csr( - service.FetchCertificateAuthorityCsrRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_fetch_certificate_authority_csr_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_certificate_authority_csr), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.FetchCertificateAuthorityCsrResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCertificateAuthorityCsrResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.fetch_certificate_authority_csr( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_fetch_certificate_authority_csr_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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.fetch_certificate_authority_csr( - service.FetchCertificateAuthorityCsrRequest(), - name='name_value', - ) - - -def test_get_certificate_authority(transport: str = 'grpc', request_type=service.GetCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateAuthority( - name='name_value', - type_=resources.CertificateAuthority.Type.SELF_SIGNED, - tier=resources.CaPool.Tier.ENTERPRISE, - state=resources.CertificateAuthority.State.ENABLED, - pem_ca_certificates=['pem_ca_certificates_value'], - gcs_bucket='gcs_bucket_value', - ) - response = client.get_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateAuthority) - assert response.name == 'name_value' - assert response.type_ == resources.CertificateAuthority.Type.SELF_SIGNED - assert response.tier == resources.CaPool.Tier.ENTERPRISE - assert response.state == resources.CertificateAuthority.State.ENABLED - assert response.pem_ca_certificates == ['pem_ca_certificates_value'] - assert response.gcs_bucket == 'gcs_bucket_value' - - -def test_get_certificate_authority_from_dict(): - test_get_certificate_authority(request_type=dict) - - -def test_get_certificate_authority_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 = CertificateAuthorityServiceClient( - 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_authority), - '__call__') as call: - client.get_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_get_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateAuthority( - name='name_value', - type_=resources.CertificateAuthority.Type.SELF_SIGNED, - tier=resources.CaPool.Tier.ENTERPRISE, - state=resources.CertificateAuthority.State.ENABLED, - pem_ca_certificates=['pem_ca_certificates_value'], - gcs_bucket='gcs_bucket_value', - )) - response = await client.get_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateAuthority) - assert response.name == 'name_value' - assert response.type_ == resources.CertificateAuthority.Type.SELF_SIGNED - assert response.tier == resources.CaPool.Tier.ENTERPRISE - assert response.state == resources.CertificateAuthority.State.ENABLED - assert response.pem_ca_certificates == ['pem_ca_certificates_value'] - assert response.gcs_bucket == 'gcs_bucket_value' - - -@pytest.mark.asyncio -async def test_get_certificate_authority_async_from_dict(): - await test_get_certificate_authority_async(request_type=dict) - - -def test_get_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCertificateAuthorityRequest() - - 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_authority), - '__call__') as call: - call.return_value = resources.CertificateAuthority() - client.get_certificate_authority(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_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCertificateAuthorityRequest() - - 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_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateAuthority()) - await client.get_certificate_authority(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_authority_flattened(): - client = CertificateAuthorityServiceClient( - 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateAuthority() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_get_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_authority( - service.GetCertificateAuthorityRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateAuthority() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateAuthority()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority( - service.GetCertificateAuthorityRequest(), - name='name_value', - ) - - -def test_list_certificate_authorities(transport: str = 'grpc', request_type=service.ListCertificateAuthoritiesRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authorities), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateAuthoritiesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_certificate_authorities(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateAuthoritiesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateAuthoritiesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificate_authorities_from_dict(): - test_list_certificate_authorities(request_type=dict) - - -def test_list_certificate_authorities_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 = CertificateAuthorityServiceClient( - 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_authorities), - '__call__') as call: - client.list_certificate_authorities() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateAuthoritiesRequest() - - -@pytest.mark.asyncio -async def test_list_certificate_authorities_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificateAuthoritiesRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authorities), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateAuthoritiesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_certificate_authorities(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateAuthoritiesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateAuthoritiesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_certificate_authorities_async_from_dict(): - await test_list_certificate_authorities_async(request_type=dict) - - -def test_list_certificate_authorities_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCertificateAuthoritiesRequest() - - 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_authorities), - '__call__') as call: - call.return_value = service.ListCertificateAuthoritiesResponse() - client.list_certificate_authorities(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_authorities_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCertificateAuthoritiesRequest() - - 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_authorities), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateAuthoritiesResponse()) - await client.list_certificate_authorities(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_authorities_flattened(): - client = CertificateAuthorityServiceClient( - 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_authorities), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateAuthoritiesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_certificate_authorities( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -def test_list_certificate_authorities_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_authorities( - service.ListCertificateAuthoritiesRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_certificate_authorities_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authorities), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateAuthoritiesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateAuthoritiesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_certificate_authorities( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_certificate_authorities_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authorities( - service.ListCertificateAuthoritiesRequest(), - parent='parent_value', - ) - - -def test_list_certificate_authorities_pager(): - client = CertificateAuthorityServiceClient( - 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_authorities), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - next_page_token='abc', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[], - next_page_token='def', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - ], - next_page_token='ghi', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_certificate_authorities(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.CertificateAuthority) - for i in results) - -def test_list_certificate_authorities_pages(): - client = CertificateAuthorityServiceClient( - 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_authorities), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - next_page_token='abc', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[], - next_page_token='def', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - ], - next_page_token='ghi', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - ), - RuntimeError, - ) - pages = list(client.list_certificate_authorities(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_authorities_async_pager(): - client = CertificateAuthorityServiceAsyncClient( - 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_authorities), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - next_page_token='abc', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[], - next_page_token='def', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - ], - next_page_token='ghi', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_certificate_authorities(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.CertificateAuthority) - for i in responses) - -@pytest.mark.asyncio -async def test_list_certificate_authorities_async_pages(): - client = CertificateAuthorityServiceAsyncClient( - 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_authorities), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - next_page_token='abc', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[], - next_page_token='def', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - ], - next_page_token='ghi', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_certificate_authorities(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_undelete_certificate_authority(transport: str = 'grpc', request_type=service.UndeleteCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.undelete_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.undelete_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.UndeleteCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_undelete_certificate_authority_from_dict(): - test_undelete_certificate_authority(request_type=dict) - - -def test_undelete_certificate_authority_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 = CertificateAuthorityServiceClient( - 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.undelete_certificate_authority), - '__call__') as call: - client.undelete_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.UndeleteCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_undelete_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.UndeleteCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.undelete_certificate_authority), - '__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.undelete_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.UndeleteCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_undelete_certificate_authority_async_from_dict(): - await test_undelete_certificate_authority_async(request_type=dict) - - -def test_undelete_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UndeleteCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.undelete_certificate_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.undelete_certificate_authority(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_undelete_certificate_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UndeleteCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.undelete_certificate_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.undelete_certificate_authority(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_undelete_certificate_authority_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.undelete_certificate_authority), - '__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.undelete_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_undelete_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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.undelete_certificate_authority( - service.UndeleteCertificateAuthorityRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_undelete_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.undelete_certificate_authority), - '__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.undelete_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_undelete_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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.undelete_certificate_authority( - service.UndeleteCertificateAuthorityRequest(), - name='name_value', - ) - - -def test_delete_certificate_authority(transport: str = 'grpc', request_type=service.DeleteCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_certificate_authority_from_dict(): - test_delete_certificate_authority(request_type=dict) - - -def test_delete_certificate_authority_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 = CertificateAuthorityServiceClient( - 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_authority), - '__call__') as call: - client.delete_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_delete_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.DeleteCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__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_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_certificate_authority_async_from_dict(): - await test_delete_certificate_authority_async(request_type=dict) - - -def test_delete_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.DeleteCertificateAuthorityRequest() - - 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_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_certificate_authority(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_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.DeleteCertificateAuthorityRequest() - - 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_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_certificate_authority(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_authority_flattened(): - client = CertificateAuthorityServiceClient( - 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_authority), - '__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_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_delete_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_authority( - service.DeleteCertificateAuthorityRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority), - '__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_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_delete_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority( - service.DeleteCertificateAuthorityRequest(), - name='name_value', - ) - - -def test_update_certificate_authority(transport: str = 'grpc', request_type=service.UpdateCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_certificate_authority_from_dict(): - test_update_certificate_authority(request_type=dict) - - -def test_update_certificate_authority_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 = CertificateAuthorityServiceClient( - 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_authority), - '__call__') as call: - client.update_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_update_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__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_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_certificate_authority_async_from_dict(): - await test_update_certificate_authority_async(request_type=dict) - - -def test_update_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateAuthorityRequest() - - request.certificate_authority.name = 'certificate_authority.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_certificate_authority(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_authority.name=certificate_authority.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_certificate_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateAuthorityRequest() - - request.certificate_authority.name = 'certificate_authority.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_certificate_authority(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_authority.name=certificate_authority.name/value', - ) in kw['metadata'] - - -def test_update_certificate_authority_flattened(): - client = CertificateAuthorityServiceClient( - 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_authority), - '__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_authority( - certificate_authority=resources.CertificateAuthority(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_authority( - service.UpdateCertificateAuthorityRequest(), - certificate_authority=resources.CertificateAuthority(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority), - '__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_authority( - certificate_authority=resources.CertificateAuthority(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority( - service.UpdateCertificateAuthorityRequest(), - certificate_authority=resources.CertificateAuthority(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_create_ca_pool(transport: str = 'grpc', request_type=service.CreateCaPoolRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_ca_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_ca_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCaPoolRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_ca_pool_from_dict(): - test_create_ca_pool(request_type=dict) - - -def test_create_ca_pool_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 = CertificateAuthorityServiceClient( - 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_ca_pool), - '__call__') as call: - client.create_ca_pool() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCaPoolRequest() - - -@pytest.mark.asyncio -async def test_create_ca_pool_async(transport: str = 'grpc_asyncio', request_type=service.CreateCaPoolRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_ca_pool), - '__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_ca_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCaPoolRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_ca_pool_async_from_dict(): - await test_create_ca_pool_async(request_type=dict) - - -def test_create_ca_pool_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateCaPoolRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_ca_pool), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_ca_pool(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_ca_pool_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateCaPoolRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_ca_pool), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_ca_pool(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_ca_pool_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_ca_pool), - '__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_ca_pool( - parent='parent_value', - ca_pool=resources.CaPool(name='name_value'), - ca_pool_id='ca_pool_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].ca_pool == resources.CaPool(name='name_value') - assert args[0].ca_pool_id == 'ca_pool_id_value' - - -def test_create_ca_pool_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_ca_pool( - service.CreateCaPoolRequest(), - parent='parent_value', - ca_pool=resources.CaPool(name='name_value'), - ca_pool_id='ca_pool_id_value', - ) - - -@pytest.mark.asyncio -async def test_create_ca_pool_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_ca_pool), - '__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_ca_pool( - parent='parent_value', - ca_pool=resources.CaPool(name='name_value'), - ca_pool_id='ca_pool_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].ca_pool == resources.CaPool(name='name_value') - assert args[0].ca_pool_id == 'ca_pool_id_value' - - -@pytest.mark.asyncio -async def test_create_ca_pool_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_ca_pool( - service.CreateCaPoolRequest(), - parent='parent_value', - ca_pool=resources.CaPool(name='name_value'), - ca_pool_id='ca_pool_id_value', - ) - - -def test_update_ca_pool(transport: str = 'grpc', request_type=service.UpdateCaPoolRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_ca_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_ca_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCaPoolRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_ca_pool_from_dict(): - test_update_ca_pool(request_type=dict) - - -def test_update_ca_pool_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 = CertificateAuthorityServiceClient( - 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_ca_pool), - '__call__') as call: - client.update_ca_pool() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCaPoolRequest() - - -@pytest.mark.asyncio -async def test_update_ca_pool_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCaPoolRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_ca_pool), - '__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_ca_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCaPoolRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_ca_pool_async_from_dict(): - await test_update_ca_pool_async(request_type=dict) - - -def test_update_ca_pool_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCaPoolRequest() - - request.ca_pool.name = 'ca_pool.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_ca_pool), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_ca_pool(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', - 'ca_pool.name=ca_pool.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_ca_pool_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCaPoolRequest() - - request.ca_pool.name = 'ca_pool.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_ca_pool), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_ca_pool(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', - 'ca_pool.name=ca_pool.name/value', - ) in kw['metadata'] - - -def test_update_ca_pool_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_ca_pool), - '__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_ca_pool( - ca_pool=resources.CaPool(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].ca_pool == resources.CaPool(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_ca_pool_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_ca_pool( - service.UpdateCaPoolRequest(), - ca_pool=resources.CaPool(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_ca_pool_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_ca_pool), - '__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_ca_pool( - ca_pool=resources.CaPool(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].ca_pool == resources.CaPool(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_ca_pool_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_ca_pool( - service.UpdateCaPoolRequest(), - ca_pool=resources.CaPool(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_get_ca_pool(transport: str = 'grpc', request_type=service.GetCaPoolRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_ca_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CaPool( - name='name_value', - tier=resources.CaPool.Tier.ENTERPRISE, - ) - response = client.get_ca_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCaPoolRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CaPool) - assert response.name == 'name_value' - assert response.tier == resources.CaPool.Tier.ENTERPRISE - - -def test_get_ca_pool_from_dict(): - test_get_ca_pool(request_type=dict) - - -def test_get_ca_pool_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 = CertificateAuthorityServiceClient( - 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_ca_pool), - '__call__') as call: - client.get_ca_pool() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCaPoolRequest() - - -@pytest.mark.asyncio -async def test_get_ca_pool_async(transport: str = 'grpc_asyncio', request_type=service.GetCaPoolRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_ca_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CaPool( - name='name_value', - tier=resources.CaPool.Tier.ENTERPRISE, - )) - response = await client.get_ca_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCaPoolRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CaPool) - assert response.name == 'name_value' - assert response.tier == resources.CaPool.Tier.ENTERPRISE - - -@pytest.mark.asyncio -async def test_get_ca_pool_async_from_dict(): - await test_get_ca_pool_async(request_type=dict) - - -def test_get_ca_pool_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCaPoolRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_ca_pool), - '__call__') as call: - call.return_value = resources.CaPool() - client.get_ca_pool(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_ca_pool_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCaPoolRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_ca_pool), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CaPool()) - await client.get_ca_pool(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_ca_pool_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_ca_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CaPool() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_ca_pool( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_get_ca_pool_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_ca_pool( - service.GetCaPoolRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_ca_pool_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_ca_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CaPool() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CaPool()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_ca_pool( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_ca_pool_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_ca_pool( - service.GetCaPoolRequest(), - name='name_value', - ) - - -def test_list_ca_pools(transport: str = 'grpc', request_type=service.ListCaPoolsRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_ca_pools), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCaPoolsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_ca_pools(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCaPoolsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCaPoolsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_ca_pools_from_dict(): - test_list_ca_pools(request_type=dict) - - -def test_list_ca_pools_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 = CertificateAuthorityServiceClient( - 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_ca_pools), - '__call__') as call: - client.list_ca_pools() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCaPoolsRequest() - - -@pytest.mark.asyncio -async def test_list_ca_pools_async(transport: str = 'grpc_asyncio', request_type=service.ListCaPoolsRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_ca_pools), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCaPoolsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_ca_pools(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCaPoolsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCaPoolsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_ca_pools_async_from_dict(): - await test_list_ca_pools_async(request_type=dict) - - -def test_list_ca_pools_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCaPoolsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ca_pools), - '__call__') as call: - call.return_value = service.ListCaPoolsResponse() - client.list_ca_pools(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_ca_pools_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCaPoolsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ca_pools), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCaPoolsResponse()) - await client.list_ca_pools(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_ca_pools_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ca_pools), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCaPoolsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_ca_pools( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -def test_list_ca_pools_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_ca_pools( - service.ListCaPoolsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_ca_pools_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ca_pools), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCaPoolsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCaPoolsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_ca_pools( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_ca_pools_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_ca_pools( - service.ListCaPoolsRequest(), - parent='parent_value', - ) - - -def test_list_ca_pools_pager(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ca_pools), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCaPoolsResponse( - ca_pools=[ - resources.CaPool(), - resources.CaPool(), - resources.CaPool(), - ], - next_page_token='abc', - ), - service.ListCaPoolsResponse( - ca_pools=[], - next_page_token='def', - ), - service.ListCaPoolsResponse( - ca_pools=[ - resources.CaPool(), - ], - next_page_token='ghi', - ), - service.ListCaPoolsResponse( - ca_pools=[ - resources.CaPool(), - resources.CaPool(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_ca_pools(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.CaPool) - for i in results) - -def test_list_ca_pools_pages(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ca_pools), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCaPoolsResponse( - ca_pools=[ - resources.CaPool(), - resources.CaPool(), - resources.CaPool(), - ], - next_page_token='abc', - ), - service.ListCaPoolsResponse( - ca_pools=[], - next_page_token='def', - ), - service.ListCaPoolsResponse( - ca_pools=[ - resources.CaPool(), - ], - next_page_token='ghi', - ), - service.ListCaPoolsResponse( - ca_pools=[ - resources.CaPool(), - resources.CaPool(), - ], - ), - RuntimeError, - ) - pages = list(client.list_ca_pools(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_ca_pools_async_pager(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ca_pools), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCaPoolsResponse( - ca_pools=[ - resources.CaPool(), - resources.CaPool(), - resources.CaPool(), - ], - next_page_token='abc', - ), - service.ListCaPoolsResponse( - ca_pools=[], - next_page_token='def', - ), - service.ListCaPoolsResponse( - ca_pools=[ - resources.CaPool(), - ], - next_page_token='ghi', - ), - service.ListCaPoolsResponse( - ca_pools=[ - resources.CaPool(), - resources.CaPool(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_ca_pools(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.CaPool) - for i in responses) - -@pytest.mark.asyncio -async def test_list_ca_pools_async_pages(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_ca_pools), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCaPoolsResponse( - ca_pools=[ - resources.CaPool(), - resources.CaPool(), - resources.CaPool(), - ], - next_page_token='abc', - ), - service.ListCaPoolsResponse( - ca_pools=[], - next_page_token='def', - ), - service.ListCaPoolsResponse( - ca_pools=[ - resources.CaPool(), - ], - next_page_token='ghi', - ), - service.ListCaPoolsResponse( - ca_pools=[ - resources.CaPool(), - resources.CaPool(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_ca_pools(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_delete_ca_pool(transport: str = 'grpc', request_type=service.DeleteCaPoolRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_ca_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_ca_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCaPoolRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_ca_pool_from_dict(): - test_delete_ca_pool(request_type=dict) - - -def test_delete_ca_pool_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 = CertificateAuthorityServiceClient( - 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_ca_pool), - '__call__') as call: - client.delete_ca_pool() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCaPoolRequest() - - -@pytest.mark.asyncio -async def test_delete_ca_pool_async(transport: str = 'grpc_asyncio', request_type=service.DeleteCaPoolRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_ca_pool), - '__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_ca_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCaPoolRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_ca_pool_async_from_dict(): - await test_delete_ca_pool_async(request_type=dict) - - -def test_delete_ca_pool_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.DeleteCaPoolRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_ca_pool), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_ca_pool(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_ca_pool_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.DeleteCaPoolRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_ca_pool), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_ca_pool(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_ca_pool_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_ca_pool), - '__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_ca_pool( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_delete_ca_pool_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_ca_pool( - service.DeleteCaPoolRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_ca_pool_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_ca_pool), - '__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_ca_pool( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_delete_ca_pool_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_ca_pool( - service.DeleteCaPoolRequest(), - name='name_value', - ) - - -def test_fetch_ca_certs(transport: str = 'grpc', request_type=service.FetchCaCertsRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.fetch_ca_certs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.FetchCaCertsResponse( - ) - response = client.fetch_ca_certs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCaCertsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, service.FetchCaCertsResponse) - - -def test_fetch_ca_certs_from_dict(): - test_fetch_ca_certs(request_type=dict) - - -def test_fetch_ca_certs_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 = CertificateAuthorityServiceClient( - 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.fetch_ca_certs), - '__call__') as call: - client.fetch_ca_certs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCaCertsRequest() - - -@pytest.mark.asyncio -async def test_fetch_ca_certs_async(transport: str = 'grpc_asyncio', request_type=service.FetchCaCertsRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.fetch_ca_certs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCaCertsResponse( - )) - response = await client.fetch_ca_certs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCaCertsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, service.FetchCaCertsResponse) - - -@pytest.mark.asyncio -async def test_fetch_ca_certs_async_from_dict(): - await test_fetch_ca_certs_async(request_type=dict) - - -def test_fetch_ca_certs_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.FetchCaCertsRequest() - - request.ca_pool = 'ca_pool/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_ca_certs), - '__call__') as call: - call.return_value = service.FetchCaCertsResponse() - client.fetch_ca_certs(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', - 'ca_pool=ca_pool/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_fetch_ca_certs_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.FetchCaCertsRequest() - - request.ca_pool = 'ca_pool/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_ca_certs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCaCertsResponse()) - await client.fetch_ca_certs(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', - 'ca_pool=ca_pool/value', - ) in kw['metadata'] - - -def test_fetch_ca_certs_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_ca_certs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.FetchCaCertsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.fetch_ca_certs( - ca_pool='ca_pool_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].ca_pool == 'ca_pool_value' - - -def test_fetch_ca_certs_flattened_error(): - client = CertificateAuthorityServiceClient( - 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.fetch_ca_certs( - service.FetchCaCertsRequest(), - ca_pool='ca_pool_value', - ) - - -@pytest.mark.asyncio -async def test_fetch_ca_certs_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_ca_certs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.FetchCaCertsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCaCertsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.fetch_ca_certs( - ca_pool='ca_pool_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].ca_pool == 'ca_pool_value' - - -@pytest.mark.asyncio -async def test_fetch_ca_certs_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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.fetch_ca_certs( - service.FetchCaCertsRequest(), - ca_pool='ca_pool_value', - ) - - -def test_get_certificate_revocation_list(transport: str = 'grpc', request_type=service.GetCertificateRevocationListRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_revocation_list), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateRevocationList( - name='name_value', - sequence_number=1601, - pem_crl='pem_crl_value', - access_url='access_url_value', - state=resources.CertificateRevocationList.State.ACTIVE, - revision_id='revision_id_value', - ) - response = client.get_certificate_revocation_list(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRevocationListRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateRevocationList) - assert response.name == 'name_value' - assert response.sequence_number == 1601 - assert response.pem_crl == 'pem_crl_value' - assert response.access_url == 'access_url_value' - assert response.state == resources.CertificateRevocationList.State.ACTIVE - assert response.revision_id == 'revision_id_value' - - -def test_get_certificate_revocation_list_from_dict(): - test_get_certificate_revocation_list(request_type=dict) - - -def test_get_certificate_revocation_list_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 = CertificateAuthorityServiceClient( - 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_revocation_list), - '__call__') as call: - client.get_certificate_revocation_list() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRevocationListRequest() - - -@pytest.mark.asyncio -async def test_get_certificate_revocation_list_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateRevocationListRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_revocation_list), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateRevocationList( - name='name_value', - sequence_number=1601, - pem_crl='pem_crl_value', - access_url='access_url_value', - state=resources.CertificateRevocationList.State.ACTIVE, - revision_id='revision_id_value', - )) - response = await client.get_certificate_revocation_list(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRevocationListRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateRevocationList) - assert response.name == 'name_value' - assert response.sequence_number == 1601 - assert response.pem_crl == 'pem_crl_value' - assert response.access_url == 'access_url_value' - assert response.state == resources.CertificateRevocationList.State.ACTIVE - assert response.revision_id == 'revision_id_value' - - -@pytest.mark.asyncio -async def test_get_certificate_revocation_list_async_from_dict(): - await test_get_certificate_revocation_list_async(request_type=dict) - - -def test_get_certificate_revocation_list_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCertificateRevocationListRequest() - - 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_revocation_list), - '__call__') as call: - call.return_value = resources.CertificateRevocationList() - client.get_certificate_revocation_list(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_revocation_list_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCertificateRevocationListRequest() - - 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_revocation_list), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateRevocationList()) - await client.get_certificate_revocation_list(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_revocation_list_flattened(): - client = CertificateAuthorityServiceClient( - 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_revocation_list), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateRevocationList() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_certificate_revocation_list( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_get_certificate_revocation_list_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_revocation_list( - service.GetCertificateRevocationListRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_certificate_revocation_list_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_list), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateRevocationList() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateRevocationList()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_certificate_revocation_list( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_certificate_revocation_list_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_list( - service.GetCertificateRevocationListRequest(), - name='name_value', - ) - - -def test_list_certificate_revocation_lists(transport: str = 'grpc', request_type=service.ListCertificateRevocationListsRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_revocation_lists), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateRevocationListsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_certificate_revocation_lists(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateRevocationListsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateRevocationListsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificate_revocation_lists_from_dict(): - test_list_certificate_revocation_lists(request_type=dict) - - -def test_list_certificate_revocation_lists_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 = CertificateAuthorityServiceClient( - 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_revocation_lists), - '__call__') as call: - client.list_certificate_revocation_lists() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateRevocationListsRequest() - - -@pytest.mark.asyncio -async def test_list_certificate_revocation_lists_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificateRevocationListsRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_revocation_lists), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateRevocationListsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_certificate_revocation_lists(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateRevocationListsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateRevocationListsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_certificate_revocation_lists_async_from_dict(): - await test_list_certificate_revocation_lists_async(request_type=dict) - - -def test_list_certificate_revocation_lists_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCertificateRevocationListsRequest() - - 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_revocation_lists), - '__call__') as call: - call.return_value = service.ListCertificateRevocationListsResponse() - client.list_certificate_revocation_lists(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_revocation_lists_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCertificateRevocationListsRequest() - - 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_revocation_lists), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateRevocationListsResponse()) - await client.list_certificate_revocation_lists(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_revocation_lists_flattened(): - client = CertificateAuthorityServiceClient( - 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_revocation_lists), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateRevocationListsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_certificate_revocation_lists( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -def test_list_certificate_revocation_lists_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_revocation_lists( - service.ListCertificateRevocationListsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_certificate_revocation_lists_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_lists), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateRevocationListsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateRevocationListsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_certificate_revocation_lists( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_certificate_revocation_lists_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_lists( - service.ListCertificateRevocationListsRequest(), - parent='parent_value', - ) - - -def test_list_certificate_revocation_lists_pager(): - client = CertificateAuthorityServiceClient( - 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_revocation_lists), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - next_page_token='abc', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[], - next_page_token='def', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - ], - next_page_token='ghi', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_certificate_revocation_lists(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.CertificateRevocationList) - for i in results) - -def test_list_certificate_revocation_lists_pages(): - client = CertificateAuthorityServiceClient( - 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_revocation_lists), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - next_page_token='abc', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[], - next_page_token='def', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - ], - next_page_token='ghi', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - ), - RuntimeError, - ) - pages = list(client.list_certificate_revocation_lists(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_revocation_lists_async_pager(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_lists), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - next_page_token='abc', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[], - next_page_token='def', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - ], - next_page_token='ghi', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_certificate_revocation_lists(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.CertificateRevocationList) - for i in responses) - -@pytest.mark.asyncio -async def test_list_certificate_revocation_lists_async_pages(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_lists), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - next_page_token='abc', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[], - next_page_token='def', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - ], - next_page_token='ghi', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_certificate_revocation_lists(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_update_certificate_revocation_list(transport: str = 'grpc', request_type=service.UpdateCertificateRevocationListRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_revocation_list), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_certificate_revocation_list(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRevocationListRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_certificate_revocation_list_from_dict(): - test_update_certificate_revocation_list(request_type=dict) - - -def test_update_certificate_revocation_list_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 = CertificateAuthorityServiceClient( - 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_revocation_list), - '__call__') as call: - client.update_certificate_revocation_list() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRevocationListRequest() - - -@pytest.mark.asyncio -async def test_update_certificate_revocation_list_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateRevocationListRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_revocation_list), - '__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_revocation_list(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRevocationListRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_certificate_revocation_list_async_from_dict(): - await test_update_certificate_revocation_list_async(request_type=dict) - - -def test_update_certificate_revocation_list_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateRevocationListRequest() - - request.certificate_revocation_list.name = 'certificate_revocation_list.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_revocation_list), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_certificate_revocation_list(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_revocation_list.name=certificate_revocation_list.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_certificate_revocation_list_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateRevocationListRequest() - - request.certificate_revocation_list.name = 'certificate_revocation_list.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_revocation_list), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_certificate_revocation_list(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_revocation_list.name=certificate_revocation_list.name/value', - ) in kw['metadata'] - - -def test_update_certificate_revocation_list_flattened(): - client = CertificateAuthorityServiceClient( - 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_revocation_list), - '__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_revocation_list( - certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].certificate_revocation_list == resources.CertificateRevocationList(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_certificate_revocation_list_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_revocation_list( - service.UpdateCertificateRevocationListRequest(), - certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_certificate_revocation_list_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_list), - '__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_revocation_list( - certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].certificate_revocation_list == resources.CertificateRevocationList(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_certificate_revocation_list_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_list( - service.UpdateCertificateRevocationListRequest(), - certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_create_certificate_template(transport: str = 'grpc', request_type=service.CreateCertificateTemplateRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_template), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_certificate_template(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateTemplateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_certificate_template_from_dict(): - test_create_certificate_template(request_type=dict) - - -def test_create_certificate_template_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 = CertificateAuthorityServiceClient( - 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_template), - '__call__') as call: - client.create_certificate_template() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateTemplateRequest() - - -@pytest.mark.asyncio -async def test_create_certificate_template_async(transport: str = 'grpc_asyncio', request_type=service.CreateCertificateTemplateRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_template), - '__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_template(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateTemplateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_certificate_template_async_from_dict(): - await test_create_certificate_template_async(request_type=dict) - - -def test_create_certificate_template_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateCertificateTemplateRequest() - - 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_template), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_certificate_template(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_template_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateCertificateTemplateRequest() - - 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_template), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_certificate_template(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_template_flattened(): - client = CertificateAuthorityServiceClient( - 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_template), - '__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_template( - parent='parent_value', - certificate_template=resources.CertificateTemplate(name='name_value'), - certificate_template_id='certificate_template_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].certificate_template == resources.CertificateTemplate(name='name_value') - assert args[0].certificate_template_id == 'certificate_template_id_value' - - -def test_create_certificate_template_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_template( - service.CreateCertificateTemplateRequest(), - parent='parent_value', - certificate_template=resources.CertificateTemplate(name='name_value'), - certificate_template_id='certificate_template_id_value', - ) - - -@pytest.mark.asyncio -async def test_create_certificate_template_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_template), - '__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_template( - parent='parent_value', - certificate_template=resources.CertificateTemplate(name='name_value'), - certificate_template_id='certificate_template_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].certificate_template == resources.CertificateTemplate(name='name_value') - assert args[0].certificate_template_id == 'certificate_template_id_value' - - -@pytest.mark.asyncio -async def test_create_certificate_template_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_template( - service.CreateCertificateTemplateRequest(), - parent='parent_value', - certificate_template=resources.CertificateTemplate(name='name_value'), - certificate_template_id='certificate_template_id_value', - ) - - -def test_delete_certificate_template(transport: str = 'grpc', request_type=service.DeleteCertificateTemplateRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_template), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_certificate_template(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCertificateTemplateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_certificate_template_from_dict(): - test_delete_certificate_template(request_type=dict) - - -def test_delete_certificate_template_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 = CertificateAuthorityServiceClient( - 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_template), - '__call__') as call: - client.delete_certificate_template() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCertificateTemplateRequest() - - -@pytest.mark.asyncio -async def test_delete_certificate_template_async(transport: str = 'grpc_asyncio', request_type=service.DeleteCertificateTemplateRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_template), - '__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_template(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCertificateTemplateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_certificate_template_async_from_dict(): - await test_delete_certificate_template_async(request_type=dict) - - -def test_delete_certificate_template_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.DeleteCertificateTemplateRequest() - - 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_template), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_certificate_template(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_template_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.DeleteCertificateTemplateRequest() - - 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_template), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_certificate_template(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_template_flattened(): - client = CertificateAuthorityServiceClient( - 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_template), - '__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_template( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_delete_certificate_template_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_template( - service.DeleteCertificateTemplateRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_certificate_template_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_template), - '__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_template( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_delete_certificate_template_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_template( - service.DeleteCertificateTemplateRequest(), - name='name_value', - ) - - -def test_get_certificate_template(transport: str = 'grpc', request_type=service.GetCertificateTemplateRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_template), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateTemplate( - name='name_value', - description='description_value', - ) - response = client.get_certificate_template(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateTemplateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateTemplate) - assert response.name == 'name_value' - assert response.description == 'description_value' - - -def test_get_certificate_template_from_dict(): - test_get_certificate_template(request_type=dict) - - -def test_get_certificate_template_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 = CertificateAuthorityServiceClient( - 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_template), - '__call__') as call: - client.get_certificate_template() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateTemplateRequest() - - -@pytest.mark.asyncio -async def test_get_certificate_template_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateTemplateRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_template), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateTemplate( - name='name_value', - description='description_value', - )) - response = await client.get_certificate_template(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateTemplateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateTemplate) - assert response.name == 'name_value' - assert response.description == 'description_value' - - -@pytest.mark.asyncio -async def test_get_certificate_template_async_from_dict(): - await test_get_certificate_template_async(request_type=dict) - - -def test_get_certificate_template_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCertificateTemplateRequest() - - 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_template), - '__call__') as call: - call.return_value = resources.CertificateTemplate() - client.get_certificate_template(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_template_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCertificateTemplateRequest() - - 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_template), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateTemplate()) - await client.get_certificate_template(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_template_flattened(): - client = CertificateAuthorityServiceClient( - 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_template), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateTemplate() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_certificate_template( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_get_certificate_template_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_template( - service.GetCertificateTemplateRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_certificate_template_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_template), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateTemplate() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateTemplate()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_certificate_template( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_certificate_template_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_template( - service.GetCertificateTemplateRequest(), - name='name_value', - ) - - -def test_list_certificate_templates(transport: str = 'grpc', request_type=service.ListCertificateTemplatesRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_templates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateTemplatesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_certificate_templates(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateTemplatesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateTemplatesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificate_templates_from_dict(): - test_list_certificate_templates(request_type=dict) - - -def test_list_certificate_templates_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 = CertificateAuthorityServiceClient( - 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_templates), - '__call__') as call: - client.list_certificate_templates() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateTemplatesRequest() - - -@pytest.mark.asyncio -async def test_list_certificate_templates_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificateTemplatesRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_templates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateTemplatesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_certificate_templates(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateTemplatesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateTemplatesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_certificate_templates_async_from_dict(): - await test_list_certificate_templates_async(request_type=dict) - - -def test_list_certificate_templates_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCertificateTemplatesRequest() - - 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_templates), - '__call__') as call: - call.return_value = service.ListCertificateTemplatesResponse() - client.list_certificate_templates(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_templates_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCertificateTemplatesRequest() - - 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_templates), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateTemplatesResponse()) - await client.list_certificate_templates(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_templates_flattened(): - client = CertificateAuthorityServiceClient( - 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_templates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateTemplatesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_certificate_templates( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -def test_list_certificate_templates_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_templates( - service.ListCertificateTemplatesRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_certificate_templates_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_templates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateTemplatesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateTemplatesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_certificate_templates( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_certificate_templates_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_templates( - service.ListCertificateTemplatesRequest(), - parent='parent_value', - ) - - -def test_list_certificate_templates_pager(): - client = CertificateAuthorityServiceClient( - 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_templates), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateTemplatesResponse( - certificate_templates=[ - resources.CertificateTemplate(), - resources.CertificateTemplate(), - resources.CertificateTemplate(), - ], - next_page_token='abc', - ), - service.ListCertificateTemplatesResponse( - certificate_templates=[], - next_page_token='def', - ), - service.ListCertificateTemplatesResponse( - certificate_templates=[ - resources.CertificateTemplate(), - ], - next_page_token='ghi', - ), - service.ListCertificateTemplatesResponse( - certificate_templates=[ - resources.CertificateTemplate(), - resources.CertificateTemplate(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_certificate_templates(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.CertificateTemplate) - for i in results) - -def test_list_certificate_templates_pages(): - client = CertificateAuthorityServiceClient( - 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_templates), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateTemplatesResponse( - certificate_templates=[ - resources.CertificateTemplate(), - resources.CertificateTemplate(), - resources.CertificateTemplate(), - ], - next_page_token='abc', - ), - service.ListCertificateTemplatesResponse( - certificate_templates=[], - next_page_token='def', - ), - service.ListCertificateTemplatesResponse( - certificate_templates=[ - resources.CertificateTemplate(), - ], - next_page_token='ghi', - ), - service.ListCertificateTemplatesResponse( - certificate_templates=[ - resources.CertificateTemplate(), - resources.CertificateTemplate(), - ], - ), - RuntimeError, - ) - pages = list(client.list_certificate_templates(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_templates_async_pager(): - client = CertificateAuthorityServiceAsyncClient( - 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_templates), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateTemplatesResponse( - certificate_templates=[ - resources.CertificateTemplate(), - resources.CertificateTemplate(), - resources.CertificateTemplate(), - ], - next_page_token='abc', - ), - service.ListCertificateTemplatesResponse( - certificate_templates=[], - next_page_token='def', - ), - service.ListCertificateTemplatesResponse( - certificate_templates=[ - resources.CertificateTemplate(), - ], - next_page_token='ghi', - ), - service.ListCertificateTemplatesResponse( - certificate_templates=[ - resources.CertificateTemplate(), - resources.CertificateTemplate(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_certificate_templates(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.CertificateTemplate) - for i in responses) - -@pytest.mark.asyncio -async def test_list_certificate_templates_async_pages(): - client = CertificateAuthorityServiceAsyncClient( - 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_templates), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateTemplatesResponse( - certificate_templates=[ - resources.CertificateTemplate(), - resources.CertificateTemplate(), - resources.CertificateTemplate(), - ], - next_page_token='abc', - ), - service.ListCertificateTemplatesResponse( - certificate_templates=[], - next_page_token='def', - ), - service.ListCertificateTemplatesResponse( - certificate_templates=[ - resources.CertificateTemplate(), - ], - next_page_token='ghi', - ), - service.ListCertificateTemplatesResponse( - certificate_templates=[ - resources.CertificateTemplate(), - resources.CertificateTemplate(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_certificate_templates(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_update_certificate_template(transport: str = 'grpc', request_type=service.UpdateCertificateTemplateRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_template), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_certificate_template(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateTemplateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_certificate_template_from_dict(): - test_update_certificate_template(request_type=dict) - - -def test_update_certificate_template_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 = CertificateAuthorityServiceClient( - 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_template), - '__call__') as call: - client.update_certificate_template() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateTemplateRequest() - - -@pytest.mark.asyncio -async def test_update_certificate_template_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateTemplateRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_template), - '__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_template(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateTemplateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_certificate_template_async_from_dict(): - await test_update_certificate_template_async(request_type=dict) - - -def test_update_certificate_template_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateTemplateRequest() - - request.certificate_template.name = 'certificate_template.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_template), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_certificate_template(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_template.name=certificate_template.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_certificate_template_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateTemplateRequest() - - request.certificate_template.name = 'certificate_template.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_template), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_certificate_template(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_template.name=certificate_template.name/value', - ) in kw['metadata'] - - -def test_update_certificate_template_flattened(): - client = CertificateAuthorityServiceClient( - 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_template), - '__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_template( - certificate_template=resources.CertificateTemplate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].certificate_template == resources.CertificateTemplate(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_certificate_template_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_template( - service.UpdateCertificateTemplateRequest(), - certificate_template=resources.CertificateTemplate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_certificate_template_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_template), - '__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_template( - certificate_template=resources.CertificateTemplate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].certificate_template == resources.CertificateTemplate(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_certificate_template_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_template( - service.UpdateCertificateTemplateRequest(), - certificate_template=resources.CertificateTemplate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CertificateAuthorityServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CertificateAuthorityServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = CertificateAuthorityServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.CertificateAuthorityServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.CertificateAuthorityServiceGrpcTransport, - transports.CertificateAuthorityServiceGrpcAsyncIOTransport, -]) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.CertificateAuthorityServiceGrpcTransport, - ) - -def test_certificate_authority_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.CertificateAuthorityServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_certificate_authority_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.CertificateAuthorityServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'create_certificate', - 'get_certificate', - 'list_certificates', - 'revoke_certificate', - 'update_certificate', - 'activate_certificate_authority', - 'create_certificate_authority', - 'disable_certificate_authority', - 'enable_certificate_authority', - 'fetch_certificate_authority_csr', - 'get_certificate_authority', - 'list_certificate_authorities', - 'undelete_certificate_authority', - 'delete_certificate_authority', - 'update_certificate_authority', - 'create_ca_pool', - 'update_ca_pool', - 'get_ca_pool', - 'list_ca_pools', - 'delete_ca_pool', - 'fetch_ca_certs', - 'get_certificate_revocation_list', - 'list_certificate_revocation_lists', - 'update_certificate_revocation_list', - 'create_certificate_template', - 'delete_certificate_template', - 'get_certificate_template', - 'list_certificate_templates', - 'update_certificate_template', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - -@requires_google_auth_gte_1_25_0 -def test_certificate_authority_service_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file - with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CertificateAuthorityServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id="octopus", - ) - - -@requires_google_auth_lt_1_25_0 -def test_certificate_authority_service_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CertificateAuthorityServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), - quota_project_id="octopus", - ) - - -def test_certificate_authority_service_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CertificateAuthorityServiceTransport() - adc.assert_called_once() - - -@requires_google_auth_gte_1_25_0 -def test_certificate_authority_service_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - CertificateAuthorityServiceClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id=None, - ) - - -@requires_google_auth_lt_1_25_0 -def test_certificate_authority_service_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - CertificateAuthorityServiceClient() - adc.assert_called_once_with( - scopes=( 'https://www.googleapis.com/auth/cloud-platform',), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.CertificateAuthorityServiceGrpcTransport, - transports.CertificateAuthorityServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_gte_1_25_0 -def test_certificate_authority_service_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.CertificateAuthorityServiceGrpcTransport, - transports.CertificateAuthorityServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_certificate_authority_service_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with(scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), - (transports.CertificateAuthorityServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -@requires_api_core_gte_1_26_0 -def test_certificate_authority_service_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) - - create_channel.assert_called_with( - "privateca.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="privateca.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), - (transports.CertificateAuthorityServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -@requires_api_core_lt_1_26_0 -def test_certificate_authority_service_transport_create_channel_old_api_core(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") - - create_channel.assert_called_with( - "privateca.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), - (transports.CertificateAuthorityServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -@requires_api_core_lt_1_26_0 -def test_certificate_authority_service_transport_create_channel_user_scopes(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( - "privateca.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - scopes=["1", "2"], - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.CertificateAuthorityServiceGrpcTransport, transports.CertificateAuthorityServiceGrpcAsyncIOTransport]) -def test_certificate_authority_service_grpc_transport_client_cert_source_for_mtls( - transport_class -): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), - 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_authority_service_host_no_port(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='privateca.googleapis.com'), - ) - assert client.transport._host == 'privateca.googleapis.com:443' - - -def test_certificate_authority_service_host_with_port(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='privateca.googleapis.com:8000'), - ) - assert client.transport._host == 'privateca.googleapis.com:8000' - -def test_certificate_authority_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CertificateAuthorityServiceGrpcTransport( - 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_authority_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CertificateAuthorityServiceGrpcAsyncIOTransport( - 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.CertificateAuthorityServiceGrpcTransport, transports.CertificateAuthorityServiceGrpcAsyncIOTransport]) -def test_certificate_authority_service_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), - 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.CertificateAuthorityServiceGrpcTransport, transports.CertificateAuthorityServiceGrpcAsyncIOTransport]) -def test_certificate_authority_service_transport_channel_mtls_with_adc( - transport_class -): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), - 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_authority_service_grpc_lro_client(): - client = CertificateAuthorityServiceClient( - 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_authority_service_grpc_lro_async_client(): - client = CertificateAuthorityServiceAsyncClient( - 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 = CertificateAuthorityServiceClient.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 = CertificateAuthorityServiceClient.ca_pool_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_ca_pool_path(path) - assert expected == actual - -def test_certificate_path(): - project = "cuttlefish" - location = "mussel" - ca_pool = "winkle" - certificate = "nautilus" - expected = "projects/{project}/locations/{location}/caPools/{ca_pool}/certificates/{certificate}".format(project=project, location=location, ca_pool=ca_pool, certificate=certificate, ) - actual = CertificateAuthorityServiceClient.certificate_path(project, location, ca_pool, certificate) - assert expected == actual - - -def test_parse_certificate_path(): - expected = { - "project": "scallop", - "location": "abalone", - "ca_pool": "squid", - "certificate": "clam", - } - path = CertificateAuthorityServiceClient.certificate_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_certificate_path(path) - assert expected == actual - -def test_certificate_authority_path(): - project = "whelk" - location = "octopus" - ca_pool = "oyster" - certificate_authority = "nudibranch" - expected = "projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}".format(project=project, location=location, ca_pool=ca_pool, certificate_authority=certificate_authority, ) - actual = CertificateAuthorityServiceClient.certificate_authority_path(project, location, ca_pool, certificate_authority) - assert expected == actual - - -def test_parse_certificate_authority_path(): - expected = { - "project": "cuttlefish", - "location": "mussel", - "ca_pool": "winkle", - "certificate_authority": "nautilus", - } - path = CertificateAuthorityServiceClient.certificate_authority_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_certificate_authority_path(path) - assert expected == actual - -def test_certificate_revocation_list_path(): - project = "scallop" - location = "abalone" - ca_pool = "squid" - certificate_authority = "clam" - certificate_revocation_list = "whelk" - expected = "projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list}".format(project=project, location=location, ca_pool=ca_pool, certificate_authority=certificate_authority, certificate_revocation_list=certificate_revocation_list, ) - actual = CertificateAuthorityServiceClient.certificate_revocation_list_path(project, location, ca_pool, certificate_authority, certificate_revocation_list) - assert expected == actual - - -def test_parse_certificate_revocation_list_path(): - expected = { - "project": "octopus", - "location": "oyster", - "ca_pool": "nudibranch", - "certificate_authority": "cuttlefish", - "certificate_revocation_list": "mussel", - } - path = CertificateAuthorityServiceClient.certificate_revocation_list_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_certificate_revocation_list_path(path) - assert expected == actual - -def test_certificate_template_path(): - project = "winkle" - location = "nautilus" - certificate_template = "scallop" - expected = "projects/{project}/locations/{location}/certificateTemplates/{certificate_template}".format(project=project, location=location, certificate_template=certificate_template, ) - actual = CertificateAuthorityServiceClient.certificate_template_path(project, location, certificate_template) - assert expected == actual - - -def test_parse_certificate_template_path(): - expected = { - "project": "abalone", - "location": "squid", - "certificate_template": "clam", - } - path = CertificateAuthorityServiceClient.certificate_template_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_certificate_template_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "whelk" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = CertificateAuthorityServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "octopus", - } - path = CertificateAuthorityServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "oyster" - expected = "folders/{folder}".format(folder=folder, ) - actual = CertificateAuthorityServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nudibranch", - } - path = CertificateAuthorityServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization, ) - actual = CertificateAuthorityServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "mussel", - } - path = CertificateAuthorityServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "winkle" - expected = "projects/{project}".format(project=project, ) - actual = CertificateAuthorityServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "nautilus", - } - path = CertificateAuthorityServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.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 = CertificateAuthorityServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "squid", - "location": "clam", - } - path = CertificateAuthorityServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_withDEFAULT_CLIENT_INFO(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object(transports.CertificateAuthorityServiceTransport, '_prep_wrapped_messages') as prep: - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.CertificateAuthorityServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = CertificateAuthorityServiceClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) diff --git a/owl-bot-staging/v1beta1/MANIFEST.in b/owl-bot-staging/v1beta1/MANIFEST.in deleted file mode 100644 index de196ee..0000000 --- a/owl-bot-staging/v1beta1/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/security/privateca *.py -recursive-include google/cloud/security/privateca_v1beta1 *.py diff --git a/owl-bot-staging/v1beta1/README.rst b/owl-bot-staging/v1beta1/README.rst deleted file mode 100644 index d1e676b..0000000 --- a/owl-bot-staging/v1beta1/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Security Privateca 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 Security Privateca API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1beta1/docs/conf.py b/owl-bot-staging/v1beta1/docs/conf.py deleted file mode 100644 index a29fc06..0000000 --- a/owl-bot-staging/v1beta1/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# google-cloud-security-privateca documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "1.6.3" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = "index" - -# General information about the project. -project = u"google-cloud-security-privateca" -copyright = u"2020, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Security 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-security-privateca-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - master_doc, - "google-cloud-security-privateca.tex", - u"google-cloud-security-privateca Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - master_doc, - "google-cloud-security-privateca", - u"Google Cloud Security Privateca Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - master_doc, - "google-cloud-security-privateca", - u"google-cloud-security-privateca Documentation", - author, - "google-cloud-security-privateca", - "GAPIC library for Google Cloud Security Privateca API", - "APIs", - ) -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "gax": ("https://gax-python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), - "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("http://requests.kennethreitz.org/en/stable/", None), - "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/v1beta1/docs/index.rst b/owl-bot-staging/v1beta1/docs/index.rst deleted file mode 100644 index 43f127e..0000000 --- a/owl-bot-staging/v1beta1/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - privateca_v1beta1/services - privateca_v1beta1/types diff --git a/owl-bot-staging/v1beta1/docs/privateca_v1beta1/certificate_authority_service.rst b/owl-bot-staging/v1beta1/docs/privateca_v1beta1/certificate_authority_service.rst deleted file mode 100644 index 536a4c8..0000000 --- a/owl-bot-staging/v1beta1/docs/privateca_v1beta1/certificate_authority_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -CertificateAuthorityService ---------------------------------------------- - -.. automodule:: google.cloud.security.privateca_v1beta1.services.certificate_authority_service - :members: - :inherited-members: - -.. automodule:: google.cloud.security.privateca_v1beta1.services.certificate_authority_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v1beta1/docs/privateca_v1beta1/services.rst b/owl-bot-staging/v1beta1/docs/privateca_v1beta1/services.rst deleted file mode 100644 index bb5adb3..0000000 --- a/owl-bot-staging/v1beta1/docs/privateca_v1beta1/services.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Security Privateca v1beta1 API -======================================================== -.. toctree:: - :maxdepth: 2 - - certificate_authority_service diff --git a/owl-bot-staging/v1beta1/docs/privateca_v1beta1/types.rst b/owl-bot-staging/v1beta1/docs/privateca_v1beta1/types.rst deleted file mode 100644 index 4e6a2a6..0000000 --- a/owl-bot-staging/v1beta1/docs/privateca_v1beta1/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Security Privateca v1beta1 API -===================================================== - -.. automodule:: google.cloud.security.privateca_v1beta1.types - :members: - :undoc-members: - :show-inheritance: diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca/__init__.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca/__init__.py deleted file mode 100644 index 3591c80..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca/__init__.py +++ /dev/null @@ -1,107 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from google.cloud.security.privateca_v1beta1.services.certificate_authority_service.client import CertificateAuthorityServiceClient -from google.cloud.security.privateca_v1beta1.services.certificate_authority_service.async_client import CertificateAuthorityServiceAsyncClient - -from google.cloud.security.privateca_v1beta1.types.resources import Certificate -from google.cloud.security.privateca_v1beta1.types.resources import CertificateAuthority -from google.cloud.security.privateca_v1beta1.types.resources import CertificateConfig -from google.cloud.security.privateca_v1beta1.types.resources import CertificateDescription -from google.cloud.security.privateca_v1beta1.types.resources import CertificateRevocationList -from google.cloud.security.privateca_v1beta1.types.resources import KeyUsage -from google.cloud.security.privateca_v1beta1.types.resources import ObjectId -from google.cloud.security.privateca_v1beta1.types.resources import PublicKey -from google.cloud.security.privateca_v1beta1.types.resources import ReusableConfig -from google.cloud.security.privateca_v1beta1.types.resources import ReusableConfigValues -from google.cloud.security.privateca_v1beta1.types.resources import ReusableConfigWrapper -from google.cloud.security.privateca_v1beta1.types.resources import Subject -from google.cloud.security.privateca_v1beta1.types.resources import SubjectAltNames -from google.cloud.security.privateca_v1beta1.types.resources import SubordinateConfig -from google.cloud.security.privateca_v1beta1.types.resources import X509Extension -from google.cloud.security.privateca_v1beta1.types.resources import RevocationReason -from google.cloud.security.privateca_v1beta1.types.service import ActivateCertificateAuthorityRequest -from google.cloud.security.privateca_v1beta1.types.service import CreateCertificateAuthorityRequest -from google.cloud.security.privateca_v1beta1.types.service import CreateCertificateRequest -from google.cloud.security.privateca_v1beta1.types.service import DisableCertificateAuthorityRequest -from google.cloud.security.privateca_v1beta1.types.service import EnableCertificateAuthorityRequest -from google.cloud.security.privateca_v1beta1.types.service import FetchCertificateAuthorityCsrRequest -from google.cloud.security.privateca_v1beta1.types.service import FetchCertificateAuthorityCsrResponse -from google.cloud.security.privateca_v1beta1.types.service import GetCertificateAuthorityRequest -from google.cloud.security.privateca_v1beta1.types.service import GetCertificateRequest -from google.cloud.security.privateca_v1beta1.types.service import GetCertificateRevocationListRequest -from google.cloud.security.privateca_v1beta1.types.service import GetReusableConfigRequest -from google.cloud.security.privateca_v1beta1.types.service import ListCertificateAuthoritiesRequest -from google.cloud.security.privateca_v1beta1.types.service import ListCertificateAuthoritiesResponse -from google.cloud.security.privateca_v1beta1.types.service import ListCertificateRevocationListsRequest -from google.cloud.security.privateca_v1beta1.types.service import ListCertificateRevocationListsResponse -from google.cloud.security.privateca_v1beta1.types.service import ListCertificatesRequest -from google.cloud.security.privateca_v1beta1.types.service import ListCertificatesResponse -from google.cloud.security.privateca_v1beta1.types.service import ListReusableConfigsRequest -from google.cloud.security.privateca_v1beta1.types.service import ListReusableConfigsResponse -from google.cloud.security.privateca_v1beta1.types.service import OperationMetadata -from google.cloud.security.privateca_v1beta1.types.service import RestoreCertificateAuthorityRequest -from google.cloud.security.privateca_v1beta1.types.service import RevokeCertificateRequest -from google.cloud.security.privateca_v1beta1.types.service import ScheduleDeleteCertificateAuthorityRequest -from google.cloud.security.privateca_v1beta1.types.service import UpdateCertificateAuthorityRequest -from google.cloud.security.privateca_v1beta1.types.service import UpdateCertificateRequest -from google.cloud.security.privateca_v1beta1.types.service import UpdateCertificateRevocationListRequest - -__all__ = ('CertificateAuthorityServiceClient', - 'CertificateAuthorityServiceAsyncClient', - 'Certificate', - 'CertificateAuthority', - 'CertificateConfig', - 'CertificateDescription', - 'CertificateRevocationList', - 'KeyUsage', - 'ObjectId', - 'PublicKey', - 'ReusableConfig', - 'ReusableConfigValues', - 'ReusableConfigWrapper', - 'Subject', - 'SubjectAltNames', - 'SubordinateConfig', - 'X509Extension', - 'RevocationReason', - 'ActivateCertificateAuthorityRequest', - 'CreateCertificateAuthorityRequest', - 'CreateCertificateRequest', - 'DisableCertificateAuthorityRequest', - 'EnableCertificateAuthorityRequest', - 'FetchCertificateAuthorityCsrRequest', - 'FetchCertificateAuthorityCsrResponse', - 'GetCertificateAuthorityRequest', - 'GetCertificateRequest', - 'GetCertificateRevocationListRequest', - 'GetReusableConfigRequest', - 'ListCertificateAuthoritiesRequest', - 'ListCertificateAuthoritiesResponse', - 'ListCertificateRevocationListsRequest', - 'ListCertificateRevocationListsResponse', - 'ListCertificatesRequest', - 'ListCertificatesResponse', - 'ListReusableConfigsRequest', - 'ListReusableConfigsResponse', - 'OperationMetadata', - 'RestoreCertificateAuthorityRequest', - 'RevokeCertificateRequest', - 'ScheduleDeleteCertificateAuthorityRequest', - 'UpdateCertificateAuthorityRequest', - 'UpdateCertificateRequest', - 'UpdateCertificateRevocationListRequest', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca/py.typed b/owl-bot-staging/v1beta1/google/cloud/security/privateca/py.typed deleted file mode 100644 index 866f40f..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-security-privateca package uses inline types. diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/__init__.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/__init__.py deleted file mode 100644 index 34e03b7..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/__init__.py +++ /dev/null @@ -1,108 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from .services.certificate_authority_service import CertificateAuthorityServiceClient -from .services.certificate_authority_service import CertificateAuthorityServiceAsyncClient - -from .types.resources import Certificate -from .types.resources import CertificateAuthority -from .types.resources import CertificateConfig -from .types.resources import CertificateDescription -from .types.resources import CertificateRevocationList -from .types.resources import KeyUsage -from .types.resources import ObjectId -from .types.resources import PublicKey -from .types.resources import ReusableConfig -from .types.resources import ReusableConfigValues -from .types.resources import ReusableConfigWrapper -from .types.resources import Subject -from .types.resources import SubjectAltNames -from .types.resources import SubordinateConfig -from .types.resources import X509Extension -from .types.resources import RevocationReason -from .types.service import ActivateCertificateAuthorityRequest -from .types.service import CreateCertificateAuthorityRequest -from .types.service import CreateCertificateRequest -from .types.service import DisableCertificateAuthorityRequest -from .types.service import EnableCertificateAuthorityRequest -from .types.service import FetchCertificateAuthorityCsrRequest -from .types.service import FetchCertificateAuthorityCsrResponse -from .types.service import GetCertificateAuthorityRequest -from .types.service import GetCertificateRequest -from .types.service import GetCertificateRevocationListRequest -from .types.service import GetReusableConfigRequest -from .types.service import ListCertificateAuthoritiesRequest -from .types.service import ListCertificateAuthoritiesResponse -from .types.service import ListCertificateRevocationListsRequest -from .types.service import ListCertificateRevocationListsResponse -from .types.service import ListCertificatesRequest -from .types.service import ListCertificatesResponse -from .types.service import ListReusableConfigsRequest -from .types.service import ListReusableConfigsResponse -from .types.service import OperationMetadata -from .types.service import RestoreCertificateAuthorityRequest -from .types.service import RevokeCertificateRequest -from .types.service import ScheduleDeleteCertificateAuthorityRequest -from .types.service import UpdateCertificateAuthorityRequest -from .types.service import UpdateCertificateRequest -from .types.service import UpdateCertificateRevocationListRequest - -__all__ = ( - 'CertificateAuthorityServiceAsyncClient', -'ActivateCertificateAuthorityRequest', -'Certificate', -'CertificateAuthority', -'CertificateAuthorityServiceClient', -'CertificateConfig', -'CertificateDescription', -'CertificateRevocationList', -'CreateCertificateAuthorityRequest', -'CreateCertificateRequest', -'DisableCertificateAuthorityRequest', -'EnableCertificateAuthorityRequest', -'FetchCertificateAuthorityCsrRequest', -'FetchCertificateAuthorityCsrResponse', -'GetCertificateAuthorityRequest', -'GetCertificateRequest', -'GetCertificateRevocationListRequest', -'GetReusableConfigRequest', -'KeyUsage', -'ListCertificateAuthoritiesRequest', -'ListCertificateAuthoritiesResponse', -'ListCertificateRevocationListsRequest', -'ListCertificateRevocationListsResponse', -'ListCertificatesRequest', -'ListCertificatesResponse', -'ListReusableConfigsRequest', -'ListReusableConfigsResponse', -'ObjectId', -'OperationMetadata', -'PublicKey', -'RestoreCertificateAuthorityRequest', -'ReusableConfig', -'ReusableConfigValues', -'ReusableConfigWrapper', -'RevocationReason', -'RevokeCertificateRequest', -'ScheduleDeleteCertificateAuthorityRequest', -'Subject', -'SubjectAltNames', -'SubordinateConfig', -'UpdateCertificateAuthorityRequest', -'UpdateCertificateRequest', -'UpdateCertificateRevocationListRequest', -'X509Extension', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/py.typed b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/py.typed deleted file mode 100644 index 866f40f..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-security-privateca package uses inline types. diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/__init__.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/__init__.py deleted file mode 100644 index 33b4459..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from .client import CertificateAuthorityServiceClient -from .async_client import CertificateAuthorityServiceAsyncClient - -__all__ = ( - 'CertificateAuthorityServiceClient', - 'CertificateAuthorityServiceAsyncClient', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py deleted file mode 100644 index bd45800..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/async_client.py +++ /dev/null @@ -1,2001 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -import functools -import re -from typing import Dict, Sequence, Tuple, Type, Union -import pkg_resources - -import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import pagers -from google.cloud.security.privateca_v1beta1.types import resources -from google.cloud.security.privateca_v1beta1.types import service -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport -from .client import CertificateAuthorityServiceClient - - -class CertificateAuthorityServiceAsyncClient: - """[Certificate Authority - Service][google.cloud.security.privateca.v1beta1.CertificateAuthorityService] - manages private certificate authorities and issued certificates. - """ - - _client: CertificateAuthorityServiceClient - - DEFAULT_ENDPOINT = CertificateAuthorityServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = CertificateAuthorityServiceClient.DEFAULT_MTLS_ENDPOINT - - certificate_path = staticmethod(CertificateAuthorityServiceClient.certificate_path) - parse_certificate_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_path) - certificate_authority_path = staticmethod(CertificateAuthorityServiceClient.certificate_authority_path) - parse_certificate_authority_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_authority_path) - certificate_revocation_list_path = staticmethod(CertificateAuthorityServiceClient.certificate_revocation_list_path) - parse_certificate_revocation_list_path = staticmethod(CertificateAuthorityServiceClient.parse_certificate_revocation_list_path) - reusable_config_path = staticmethod(CertificateAuthorityServiceClient.reusable_config_path) - parse_reusable_config_path = staticmethod(CertificateAuthorityServiceClient.parse_reusable_config_path) - common_billing_account_path = staticmethod(CertificateAuthorityServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(CertificateAuthorityServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(CertificateAuthorityServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(CertificateAuthorityServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(CertificateAuthorityServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(CertificateAuthorityServiceClient.parse_common_organization_path) - common_project_path = staticmethod(CertificateAuthorityServiceClient.common_project_path) - parse_common_project_path = staticmethod(CertificateAuthorityServiceClient.parse_common_project_path) - common_location_path = staticmethod(CertificateAuthorityServiceClient.common_location_path) - parse_common_location_path = staticmethod(CertificateAuthorityServiceClient.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: - CertificateAuthorityServiceAsyncClient: The constructed client. - """ - return CertificateAuthorityServiceClient.from_service_account_info.__func__(CertificateAuthorityServiceAsyncClient, 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: - CertificateAuthorityServiceAsyncClient: The constructed client. - """ - return CertificateAuthorityServiceClient.from_service_account_file.__func__(CertificateAuthorityServiceAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> CertificateAuthorityServiceTransport: - """Returns the transport used by the client instance. - - Returns: - CertificateAuthorityServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(CertificateAuthorityServiceClient).get_transport_class, type(CertificateAuthorityServiceClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, CertificateAuthorityServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the certificate authority service client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ~.CertificateAuthorityServiceTransport]): 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 = CertificateAuthorityServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_certificate(self, - request: service.CreateCertificateRequest = None, - *, - parent: str = None, - certificate: resources.Certificate = None, - certificate_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Create a new - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - in a given Project, Location from a particular - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.CreateCertificateRequest`): - The request object. Request message for - [CertificateAuthorityService.CreateCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.CreateCertificate]. - parent (:class:`str`): - Required. The resource name of the location and - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - associated with the - [Certificate][google.cloud.security.privateca.v1beta1.Certificate], - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate (:class:`google.cloud.security.privateca_v1beta1.types.Certificate`): - Required. A - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - with initial field values. - - This corresponds to the ``certificate`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_id (:class:`str`): - Optional. It must be unique within a location and match - the regular expression ``[a-zA-Z0-9_-]{1,63}``. This - field is required when using a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the Enterprise - [CertificateAuthority.Tier][google.cloud.security.privateca.v1beta1.CertificateAuthority.Tier], - but is optional and its value is ignored otherwise. - - 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.cloud.security.privateca_v1beta1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, 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 = service.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_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_certificate(self, - request: service.GetCertificateRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Returns a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.GetCertificateRequest`): - The request object. Request message for - [CertificateAuthorityService.GetCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificate]. - name (:class:`str`): - Required. The - [name][google.cloud.security.privateca.v1beta1.Certificate.name] - of the - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - to get. - - 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.security.privateca_v1beta1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.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_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_certificates(self, - request: service.ListCertificatesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificatesAsyncPager: - r"""Lists - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.ListCertificatesRequest`): - The request object. Request message for - [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificates]. - parent (:class:`str`): - Required. The resource name of the location associated - with the - [Certificates][google.cloud.security.privateca.v1beta1.Certificate], - in the format - ``projects/*/locations/*/certificateauthorities/*``. - - 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificatesAsyncPager: - Response message for - [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificates]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.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_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListCertificatesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def revoke_certificate(self, - request: service.RevokeCertificateRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Revoke a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.RevokeCertificateRequest`): - The request object. Request message for - [CertificateAuthorityService.RevokeCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.RevokeCertificate]. - name (:class:`str`): - Required. The resource name for this - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - in the format - ``projects/*/locations/*/certificateAuthorities/*/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.security.privateca_v1beta1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.RevokeCertificateRequest(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.revoke_certificate, - 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 update_certificate(self, - request: service.UpdateCertificateRequest = None, - *, - certificate: resources.Certificate = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Update a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - Currently, the only field you can update is the - [labels][google.cloud.security.privateca.v1beta1.Certificate.labels] - field. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.UpdateCertificateRequest`): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificate]. - certificate (:class:`google.cloud.security.privateca_v1beta1.types.Certificate`): - Required. - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - with updated values. - - 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. A list of fields to be - updated in this request. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.security.privateca_v1beta1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([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 = service.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_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(( - ("certificate.name", request.certificate.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def activate_certificate_authority(self, - request: service.ActivateCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Activate a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - that is in state - [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. - After the parent Certificate Authority signs a certificate - signing request from - [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr], - this method can complete the activation process. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.ActivateCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. - name (:class:`str`): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.ActivateCertificateAuthorityRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.activate_certificate_authority, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def create_certificate_authority(self, - request: service.CreateCertificateAuthorityRequest = None, - *, - parent: str = None, - certificate_authority: resources.CertificateAuthority = None, - certificate_authority_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Create a new - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in a given Project and Location. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.CreateCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.CreateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.CreateCertificateAuthority]. - parent (:class:`str`): - Required. The resource name of the location associated - with the - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority], - 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_authority (:class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority`): - Required. A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - with initial field values. - - This corresponds to the ``certificate_authority`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_authority_id (:class:`str`): - Required. It must be unique within a location and match - the regular expression ``[a-zA-Z0-9_-]{1,63}`` - - This corresponds to the ``certificate_authority_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.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate_authority, certificate_authority_id]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.CreateCertificateAuthorityRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate_authority is not None: - request.certificate_authority = certificate_authority - if certificate_authority_id is not None: - request.certificate_authority_id = certificate_authority_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_authority, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def disable_certificate_authority(self, - request: service.DisableCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Disable a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.DisableCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.DisableCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.DisableCertificateAuthority]. - name (:class:`str`): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.DisableCertificateAuthorityRequest(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.disable_certificate_authority, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def enable_certificate_authority(self, - request: service.EnableCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Enable a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.EnableCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.EnableCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.EnableCertificateAuthority]. - name (:class:`str`): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.EnableCertificateAuthorityRequest(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.enable_certificate_authority, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def fetch_certificate_authority_csr(self, - request: service.FetchCertificateAuthorityCsrRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.FetchCertificateAuthorityCsrResponse: - r"""Fetch a certificate signing request (CSR) from a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - that is in state - [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. - The CSR must then be signed by the desired parent Certificate - Authority, which could be another - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - resource, or could be an on-prem certificate authority. See also - [ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.FetchCertificateAuthorityCsrRequest`): - The request object. Request message for - [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. - name (:class:`str`): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - 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.security.privateca_v1beta1.types.FetchCertificateAuthorityCsrResponse: - Response message for - [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.FetchCertificateAuthorityCsrRequest(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.fetch_certificate_authority_csr, - 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_certificate_authority(self, - request: service.GetCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CertificateAuthority: - r"""Returns a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.GetCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.GetCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificateAuthority]. - name (:class:`str`): - Required. The - [name][google.cloud.security.privateca.v1beta1.CertificateAuthority.name] - of the - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - to get. - - 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.security.privateca_v1beta1.types.CertificateAuthority: - A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.GetCertificateAuthorityRequest(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_authority, - 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_certificate_authorities(self, - request: service.ListCertificateAuthoritiesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateAuthoritiesAsyncPager: - r"""Lists - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesRequest`): - The request object. Request message for - [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateAuthorities]. - parent (:class:`str`): - Required. The resource name of the location associated - with the - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority], - 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesAsyncPager: - Response message for - [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateAuthorities]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.ListCertificateAuthoritiesRequest(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_authorities, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListCertificateAuthoritiesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def restore_certificate_authority(self, - request: service.RestoreCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Restore a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - that is scheduled for deletion. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.RestoreCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.RestoreCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.RestoreCertificateAuthority]. - name (:class:`str`): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.RestoreCertificateAuthorityRequest(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.restore_certificate_authority, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def schedule_delete_certificate_authority(self, - request: service.ScheduleDeleteCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Schedule a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - for deletion. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.ScheduleDeleteCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.ScheduleDeleteCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ScheduleDeleteCertificateAuthority]. - name (:class:`str`): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.ScheduleDeleteCertificateAuthorityRequest(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.schedule_delete_certificate_authority, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_certificate_authority(self, - request: service.UpdateCertificateAuthorityRequest = None, - *, - certificate_authority: resources.CertificateAuthority = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Update a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.UpdateCertificateAuthorityRequest`): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificateAuthority]. - certificate_authority (:class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority`): - Required. - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - with updated values. - - This corresponds to the ``certificate_authority`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. A list of fields to be - updated in this request. - - 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.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_authority, update_mask]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.UpdateCertificateAuthorityRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_authority is not None: - request.certificate_authority = certificate_authority - 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_authority, - 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(( - ("certificate_authority.name", request.certificate_authority.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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def get_certificate_revocation_list(self, - request: service.GetCertificateRevocationListRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CertificateRevocationList: - r"""Returns a - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.GetCertificateRevocationListRequest`): - The request object. Request message for - [CertificateAuthorityService.GetCertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificateRevocationList]. - name (:class:`str`): - Required. The - [name][google.cloud.security.privateca.v1beta1.CertificateRevocationList.name] - of the - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] - to get. - - 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.security.privateca_v1beta1.types.CertificateRevocationList: - A [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] corresponds to a signed X.509 certificate - Revocation List (CRL). A CRL contains the serial - numbers of certificates that should no longer be - trusted. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.GetCertificateRevocationListRequest(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_revocation_list, - 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_certificate_revocation_lists(self, - request: service.ListCertificateRevocationListsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateRevocationListsAsyncPager: - r"""Lists - [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsRequest`): - The request object. Request message for - [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateRevocationLists]. - parent (:class:`str`): - Required. The resource name of the location associated - with the - [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList], - in the format - ``projects/*/locations/*/certificateauthorities/*``. - - 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateRevocationListsAsyncPager: - Response message for - [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateRevocationLists]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.ListCertificateRevocationListsRequest(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_revocation_lists, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListCertificateRevocationListsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_certificate_revocation_list(self, - request: service.UpdateCertificateRevocationListRequest = None, - *, - certificate_revocation_list: resources.CertificateRevocationList = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Update a - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.UpdateCertificateRevocationListRequest`): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificateRevocationList]. - certificate_revocation_list (:class:`google.cloud.security.privateca_v1beta1.types.CertificateRevocationList`): - Required. - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] - with updated values. - - This corresponds to the ``certificate_revocation_list`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. A list of fields to be - updated in this request. - - 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.security.privateca_v1beta1.types.CertificateRevocationList` A [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] corresponds to a signed X.509 certificate - Revocation List (CRL). A CRL contains the serial - numbers of certificates that should no longer be - trusted. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_revocation_list, update_mask]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.UpdateCertificateRevocationListRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_revocation_list is not None: - request.certificate_revocation_list = certificate_revocation_list - 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_revocation_list, - 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(( - ("certificate_revocation_list.name", request.certificate_revocation_list.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, - resources.CertificateRevocationList, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def get_reusable_config(self, - request: service.GetReusableConfigRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.ReusableConfig: - r"""Returns a - [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.GetReusableConfigRequest`): - The request object. Request message for - [CertificateAuthorityService.GetReusableConfig][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetReusableConfig]. - name (:class:`str`): - Required. The [name][ReusableConfigs.name] of the - [ReusableConfigs][] to get. - - 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.security.privateca_v1beta1.types.ReusableConfig: - A [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] refers to a managed [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues]. Those, in - turn, are used to describe certain fields of an X.509 - certificate, such as the key usage fields, fields - specific to CA certificates, certificate policy - extensions and custom extensions. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.GetReusableConfigRequest(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_reusable_config, - 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_reusable_configs(self, - request: service.ListReusableConfigsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListReusableConfigsAsyncPager: - r"""Lists - [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig]. - - Args: - request (:class:`google.cloud.security.privateca_v1beta1.types.ListReusableConfigsRequest`): - The request object. Request message for - [CertificateAuthorityService.ListReusableConfigs][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListReusableConfigs]. - parent (:class:`str`): - Required. The resource name of the location associated - with the - [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig], - 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListReusableConfigsAsyncPager: - Response message for - [CertificateAuthorityService.ListReusableConfigs][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListReusableConfigs]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = service.ListReusableConfigsRequest(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_reusable_configs, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListReusableConfigsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - - - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-security-privateca", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "CertificateAuthorityServiceAsyncClient", -) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py deleted file mode 100644 index ae58472..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/client.py +++ /dev/null @@ -1,2215 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -from distutils import util -import os -import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources - -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import pagers -from google.cloud.security.privateca_v1beta1.types import resources -from google.cloud.security.privateca_v1beta1.types import service -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import CertificateAuthorityServiceGrpcTransport -from .transports.grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport - - -class CertificateAuthorityServiceClientMeta(type): - """Metaclass for the CertificateAuthorityService 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[CertificateAuthorityServiceTransport]] - _transport_registry["grpc"] = CertificateAuthorityServiceGrpcTransport - _transport_registry["grpc_asyncio"] = CertificateAuthorityServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[CertificateAuthorityServiceTransport]: - """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 CertificateAuthorityServiceClient(metaclass=CertificateAuthorityServiceClientMeta): - """[Certificate Authority - Service][google.cloud.security.privateca.v1beta1.CertificateAuthorityService] - manages private certificate authorities and issued certificates. - """ - - @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 = "privateca.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: - CertificateAuthorityServiceClient: 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: - CertificateAuthorityServiceClient: 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) -> CertificateAuthorityServiceTransport: - """Returns the transport used by the client instance. - - Returns: - CertificateAuthorityServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def certificate_path(project: str,location: str,certificate_authority: str,certificate: str,) -> str: - """Returns a fully-qualified certificate string.""" - return "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}/certificates/{certificate}".format(project=project, location=location, certificate_authority=certificate_authority, 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.+?)/certificateAuthorities/(?P.+?)/certificates/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def certificate_authority_path(project: str,location: str,certificate_authority: str,) -> str: - """Returns a fully-qualified certificate_authority string.""" - return "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}".format(project=project, location=location, certificate_authority=certificate_authority, ) - - @staticmethod - def parse_certificate_authority_path(path: str) -> Dict[str,str]: - """Parses a certificate_authority path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificateAuthorities/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def certificate_revocation_list_path(project: str,location: str,certificate_authority: str,certificate_revocation_list: str,) -> str: - """Returns a fully-qualified certificate_revocation_list string.""" - return "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list}".format(project=project, location=location, certificate_authority=certificate_authority, certificate_revocation_list=certificate_revocation_list, ) - - @staticmethod - def parse_certificate_revocation_list_path(path: str) -> Dict[str,str]: - """Parses a certificate_revocation_list path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/certificateAuthorities/(?P.+?)/certificateRevocationLists/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def reusable_config_path(project: str,location: str,reusable_config: str,) -> str: - """Returns a fully-qualified reusable_config string.""" - return "projects/{project}/locations/{location}/reusableConfigs/{reusable_config}".format(project=project, location=location, reusable_config=reusable_config, ) - - @staticmethod - def parse_reusable_config_path(path: str) -> Dict[str,str]: - """Parses a reusable_config path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/reusableConfigs/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_billing_account_path(billing_account: str, ) -> str: - """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path(folder: str, ) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder, ) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str,str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path(organization: str, ) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization, ) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str,str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path(project: str, ) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project, ) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str,str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_location_path(project: str, location: str, ) -> str: - """Returns a fully-qualified location string.""" - return "projects/{project}/locations/{location}".format(project=project, location=location, ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, CertificateAuthorityServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the certificate authority service client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, CertificateAuthorityServiceTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) - if client_options is None: - client_options = client_options_lib.ClientOptions() - - # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) - - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - if isinstance(transport, CertificateAuthorityServiceTransport): - # transport is a CertificateAuthorityServiceTransport instance. - if credentials or client_options.credentials_file: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") - if client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = transport - else: - Transport = type(self).get_transport_class(transport) - self._transport = Transport( - credentials=credentials, - credentials_file=client_options.credentials_file, - host=api_endpoint, - scopes=client_options.scopes, - client_cert_source_for_mtls=client_cert_source_func, - quota_project_id=client_options.quota_project_id, - client_info=client_info, - ) - - def create_certificate(self, - request: service.CreateCertificateRequest = None, - *, - parent: str = None, - certificate: resources.Certificate = None, - certificate_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Create a new - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - in a given Project, Location from a particular - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.CreateCertificateRequest): - The request object. Request message for - [CertificateAuthorityService.CreateCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.CreateCertificate]. - parent (str): - Required. The resource name of the location and - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - associated with the - [Certificate][google.cloud.security.privateca.v1beta1.Certificate], - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate (google.cloud.security.privateca_v1beta1.types.Certificate): - Required. A - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - with initial field values. - - This corresponds to the ``certificate`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_id (str): - Optional. It must be unique within a location and match - the regular expression ``[a-zA-Z0-9_-]{1,63}``. This - field is required when using a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the Enterprise - [CertificateAuthority.Tier][google.cloud.security.privateca.v1beta1.CertificateAuthority.Tier], - but is optional and its value is ignored otherwise. - - 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.cloud.security.privateca_v1beta1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, 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 service.CreateCertificateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CreateCertificateRequest): - request = service.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, - ) - - # Done; return the response. - return response - - def get_certificate(self, - request: service.GetCertificateRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Returns a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.GetCertificateRequest): - The request object. Request message for - [CertificateAuthorityService.GetCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificate]. - name (str): - Required. The - [name][google.cloud.security.privateca.v1beta1.Certificate.name] - of the - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - to get. - - 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.security.privateca_v1beta1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.GetCertificateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetCertificateRequest): - request = service.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 list_certificates(self, - request: service.ListCertificatesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificatesPager: - r"""Lists - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.ListCertificatesRequest): - The request object. Request message for - [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificates]. - parent (str): - Required. The resource name of the location associated - with the - [Certificates][google.cloud.security.privateca.v1beta1.Certificate], - in the format - ``projects/*/locations/*/certificateauthorities/*``. - - 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificatesPager: - Response message for - [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificates]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.ListCertificatesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListCertificatesRequest): - request = service.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 revoke_certificate(self, - request: service.RevokeCertificateRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Revoke a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.RevokeCertificateRequest): - The request object. Request message for - [CertificateAuthorityService.RevokeCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.RevokeCertificate]. - name (str): - Required. The resource name for this - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - in the format - ``projects/*/locations/*/certificateAuthorities/*/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.security.privateca_v1beta1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.RevokeCertificateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.RevokeCertificateRequest): - request = service.RevokeCertificateRequest(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.revoke_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 update_certificate(self, - request: service.UpdateCertificateRequest = None, - *, - certificate: resources.Certificate = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Certificate: - r"""Update a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - Currently, the only field you can update is the - [labels][google.cloud.security.privateca.v1beta1.Certificate.labels] - field. - - Args: - request (google.cloud.security.privateca_v1beta1.types.UpdateCertificateRequest): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificate]. - certificate (google.cloud.security.privateca_v1beta1.types.Certificate): - Required. - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - with updated values. - - 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. A list of fields to be - updated in this request. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.security.privateca_v1beta1.types.Certificate: - A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([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 service.UpdateCertificateRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UpdateCertificateRequest): - request = service.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, - ) - - # Done; return the response. - return response - - def activate_certificate_authority(self, - request: service.ActivateCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Activate a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - that is in state - [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. - After the parent Certificate Authority signs a certificate - signing request from - [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr], - this method can complete the activation process. - - Args: - request (google.cloud.security.privateca_v1beta1.types.ActivateCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.ActivateCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ActivateCertificateAuthorityRequest): - request = service.ActivateCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.activate_certificate_authority] - - # 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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def create_certificate_authority(self, - request: service.CreateCertificateAuthorityRequest = None, - *, - parent: str = None, - certificate_authority: resources.CertificateAuthority = None, - certificate_authority_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Create a new - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in a given Project and Location. - - Args: - request (google.cloud.security.privateca_v1beta1.types.CreateCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.CreateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.CreateCertificateAuthority]. - parent (str): - Required. The resource name of the location associated - with the - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority], - 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_authority (google.cloud.security.privateca_v1beta1.types.CertificateAuthority): - Required. A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - with initial field values. - - This corresponds to the ``certificate_authority`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - certificate_authority_id (str): - Required. It must be unique within a location and match - the regular expression ``[a-zA-Z0-9_-]{1,63}`` - - This corresponds to the ``certificate_authority_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.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, certificate_authority, certificate_authority_id]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.CreateCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CreateCertificateAuthorityRequest): - request = service.CreateCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if certificate_authority is not None: - request.certificate_authority = certificate_authority - if certificate_authority_id is not None: - request.certificate_authority_id = certificate_authority_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_certificate_authority] - - # 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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def disable_certificate_authority(self, - request: service.DisableCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Disable a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.DisableCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.DisableCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.DisableCertificateAuthority]. - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.DisableCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.DisableCertificateAuthorityRequest): - request = service.DisableCertificateAuthorityRequest(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.disable_certificate_authority] - - # 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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def enable_certificate_authority(self, - request: service.EnableCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Enable a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.EnableCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.EnableCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.EnableCertificateAuthority]. - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.EnableCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.EnableCertificateAuthorityRequest): - request = service.EnableCertificateAuthorityRequest(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.enable_certificate_authority] - - # 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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def fetch_certificate_authority_csr(self, - request: service.FetchCertificateAuthorityCsrRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.FetchCertificateAuthorityCsrResponse: - r"""Fetch a certificate signing request (CSR) from a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - that is in state - [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. - The CSR must then be signed by the desired parent Certificate - Authority, which could be another - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - resource, or could be an on-prem certificate authority. See also - [ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.FetchCertificateAuthorityCsrRequest): - The request object. Request message for - [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - 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.security.privateca_v1beta1.types.FetchCertificateAuthorityCsrResponse: - Response message for - [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.FetchCertificateAuthorityCsrRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.FetchCertificateAuthorityCsrRequest): - request = service.FetchCertificateAuthorityCsrRequest(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.fetch_certificate_authority_csr] - - # 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_certificate_authority(self, - request: service.GetCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CertificateAuthority: - r"""Returns a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.GetCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.GetCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificateAuthority]. - name (str): - Required. The - [name][google.cloud.security.privateca.v1beta1.CertificateAuthority.name] - of the - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - to get. - - 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.security.privateca_v1beta1.types.CertificateAuthority: - A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.GetCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetCertificateAuthorityRequest): - request = service.GetCertificateAuthorityRequest(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_authority] - - # 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_certificate_authorities(self, - request: service.ListCertificateAuthoritiesRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateAuthoritiesPager: - r"""Lists - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesRequest): - The request object. Request message for - [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateAuthorities]. - parent (str): - Required. The resource name of the location associated - with the - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority], - 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateAuthoritiesPager: - Response message for - [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateAuthorities]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.ListCertificateAuthoritiesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListCertificateAuthoritiesRequest): - request = service.ListCertificateAuthoritiesRequest(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_authorities] - - # 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.ListCertificateAuthoritiesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def restore_certificate_authority(self, - request: service.RestoreCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Restore a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - that is scheduled for deletion. - - Args: - request (google.cloud.security.privateca_v1beta1.types.RestoreCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.RestoreCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.RestoreCertificateAuthority]. - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.RestoreCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.RestoreCertificateAuthorityRequest): - request = service.RestoreCertificateAuthorityRequest(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.restore_certificate_authority] - - # 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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def schedule_delete_certificate_authority(self, - request: service.ScheduleDeleteCertificateAuthorityRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Schedule a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - for deletion. - - Args: - request (google.cloud.security.privateca_v1beta1.types.ScheduleDeleteCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.ScheduleDeleteCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ScheduleDeleteCertificateAuthority]. - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.ScheduleDeleteCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ScheduleDeleteCertificateAuthorityRequest): - request = service.ScheduleDeleteCertificateAuthorityRequest(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.schedule_delete_certificate_authority] - - # 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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_certificate_authority(self, - request: service.UpdateCertificateAuthorityRequest = None, - *, - certificate_authority: resources.CertificateAuthority = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Update a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.UpdateCertificateAuthorityRequest): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificateAuthority]. - certificate_authority (google.cloud.security.privateca_v1beta1.types.CertificateAuthority): - Required. - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - with updated values. - - This corresponds to the ``certificate_authority`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be - updated in this request. - - 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.security.privateca_v1beta1.types.CertificateAuthority` A [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] represents an individual Certificate Authority. - A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_authority, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.UpdateCertificateAuthorityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UpdateCertificateAuthorityRequest): - request = service.UpdateCertificateAuthorityRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_authority is not None: - request.certificate_authority = certificate_authority - 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_authority] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("certificate_authority.name", request.certificate_authority.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, - resources.CertificateAuthority, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def get_certificate_revocation_list(self, - request: service.GetCertificateRevocationListRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.CertificateRevocationList: - r"""Returns a - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.GetCertificateRevocationListRequest): - The request object. Request message for - [CertificateAuthorityService.GetCertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificateRevocationList]. - name (str): - Required. The - [name][google.cloud.security.privateca.v1beta1.CertificateRevocationList.name] - of the - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] - to get. - - 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.security.privateca_v1beta1.types.CertificateRevocationList: - A [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] corresponds to a signed X.509 certificate - Revocation List (CRL). A CRL contains the serial - numbers of certificates that should no longer be - trusted. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.GetCertificateRevocationListRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetCertificateRevocationListRequest): - request = service.GetCertificateRevocationListRequest(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_revocation_list] - - # 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_certificate_revocation_lists(self, - request: service.ListCertificateRevocationListsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCertificateRevocationListsPager: - r"""Lists - [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsRequest): - The request object. Request message for - [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateRevocationLists]. - parent (str): - Required. The resource name of the location associated - with the - [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList], - in the format - ``projects/*/locations/*/certificateauthorities/*``. - - 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListCertificateRevocationListsPager: - Response message for - [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateRevocationLists]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.ListCertificateRevocationListsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListCertificateRevocationListsRequest): - request = service.ListCertificateRevocationListsRequest(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_revocation_lists] - - # 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.ListCertificateRevocationListsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_certificate_revocation_list(self, - request: service.UpdateCertificateRevocationListRequest = None, - *, - certificate_revocation_list: resources.CertificateRevocationList = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Update a - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.UpdateCertificateRevocationListRequest): - The request object. Request message for - [CertificateAuthorityService.UpdateCertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificateRevocationList]. - certificate_revocation_list (google.cloud.security.privateca_v1beta1.types.CertificateRevocationList): - Required. - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] - with updated values. - - This corresponds to the ``certificate_revocation_list`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be - updated in this request. - - 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.security.privateca_v1beta1.types.CertificateRevocationList` A [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] corresponds to a signed X.509 certificate - Revocation List (CRL). A CRL contains the serial - numbers of certificates that should no longer be - trusted. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([certificate_revocation_list, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.UpdateCertificateRevocationListRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UpdateCertificateRevocationListRequest): - request = service.UpdateCertificateRevocationListRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if certificate_revocation_list is not None: - request.certificate_revocation_list = certificate_revocation_list - 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_revocation_list] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("certificate_revocation_list.name", request.certificate_revocation_list.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, - resources.CertificateRevocationList, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def get_reusable_config(self, - request: service.GetReusableConfigRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.ReusableConfig: - r"""Returns a - [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.GetReusableConfigRequest): - The request object. Request message for - [CertificateAuthorityService.GetReusableConfig][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetReusableConfig]. - name (str): - Required. The [name][ReusableConfigs.name] of the - [ReusableConfigs][] to get. - - 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.security.privateca_v1beta1.types.ReusableConfig: - A [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] refers to a managed [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues]. Those, in - turn, are used to describe certain fields of an X.509 - certificate, such as the key usage fields, fields - specific to CA certificates, certificate policy - extensions and custom extensions. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.GetReusableConfigRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetReusableConfigRequest): - request = service.GetReusableConfigRequest(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_reusable_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 list_reusable_configs(self, - request: service.ListReusableConfigsRequest = None, - *, - parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListReusableConfigsPager: - r"""Lists - [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig]. - - Args: - request (google.cloud.security.privateca_v1beta1.types.ListReusableConfigsRequest): - The request object. Request message for - [CertificateAuthorityService.ListReusableConfigs][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListReusableConfigs]. - parent (str): - Required. The resource name of the location associated - with the - [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig], - 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.security.privateca_v1beta1.services.certificate_authority_service.pagers.ListReusableConfigsPager: - Response message for - [CertificateAuthorityService.ListReusableConfigs][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListReusableConfigs]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a service.ListReusableConfigsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListReusableConfigsRequest): - request = service.ListReusableConfigsRequest(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_reusable_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.ListReusableConfigsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - - - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-security-privateca", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "CertificateAuthorityServiceClient", -) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py deleted file mode 100644 index 2765ec9..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/pagers.py +++ /dev/null @@ -1,507 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple, Optional - -from google.cloud.security.privateca_v1beta1.types import resources -from google.cloud.security.privateca_v1beta1.types import service - - -class ListCertificatesPager: - """A pager for iterating through ``list_certificates`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1beta1.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.security.privateca_v1beta1.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[..., service.ListCertificatesResponse], - request: service.ListCertificatesRequest, - response: service.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.security.privateca_v1beta1.types.ListCertificatesRequest): - The initial request object. - response (google.cloud.security.privateca_v1beta1.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 = service.ListCertificatesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[service.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) -> Iterable[resources.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.security.privateca_v1beta1.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.security.privateca_v1beta1.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[service.ListCertificatesResponse]], - request: service.ListCertificatesRequest, - response: service.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.security.privateca_v1beta1.types.ListCertificatesRequest): - The initial request object. - response (google.cloud.security.privateca_v1beta1.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 = service.ListCertificatesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[service.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) -> AsyncIterable[resources.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 ListCertificateAuthoritiesPager: - """A pager for iterating through ``list_certificate_authorities`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``certificate_authorities`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCertificateAuthorities`` requests and continue to iterate - through the ``certificate_authorities`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., service.ListCertificateAuthoritiesResponse], - request: service.ListCertificateAuthoritiesRequest, - response: service.ListCertificateAuthoritiesResponse, - *, - 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.security.privateca_v1beta1.types.ListCertificateAuthoritiesRequest): - The initial request object. - response (google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListCertificateAuthoritiesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[service.ListCertificateAuthoritiesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.CertificateAuthority]: - for page in self.pages: - yield from page.certificate_authorities - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateAuthoritiesAsyncPager: - """A pager for iterating through ``list_certificate_authorities`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``certificate_authorities`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCertificateAuthorities`` requests and continue to iterate - through the ``certificate_authorities`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., Awaitable[service.ListCertificateAuthoritiesResponse]], - request: service.ListCertificateAuthoritiesRequest, - response: service.ListCertificateAuthoritiesResponse, - *, - 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.security.privateca_v1beta1.types.ListCertificateAuthoritiesRequest): - The initial request object. - response (google.cloud.security.privateca_v1beta1.types.ListCertificateAuthoritiesResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListCertificateAuthoritiesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[service.ListCertificateAuthoritiesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.CertificateAuthority]: - async def async_generator(): - async for page in self.pages: - for response in page.certificate_authorities: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateRevocationListsPager: - """A pager for iterating through ``list_certificate_revocation_lists`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``certificate_revocation_lists`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCertificateRevocationLists`` requests and continue to iterate - through the ``certificate_revocation_lists`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., service.ListCertificateRevocationListsResponse], - request: service.ListCertificateRevocationListsRequest, - response: service.ListCertificateRevocationListsResponse, - *, - 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.security.privateca_v1beta1.types.ListCertificateRevocationListsRequest): - The initial request object. - response (google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListCertificateRevocationListsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[service.ListCertificateRevocationListsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.CertificateRevocationList]: - for page in self.pages: - yield from page.certificate_revocation_lists - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCertificateRevocationListsAsyncPager: - """A pager for iterating through ``list_certificate_revocation_lists`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``certificate_revocation_lists`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCertificateRevocationLists`` requests and continue to iterate - through the ``certificate_revocation_lists`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., Awaitable[service.ListCertificateRevocationListsResponse]], - request: service.ListCertificateRevocationListsRequest, - response: service.ListCertificateRevocationListsResponse, - *, - 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.security.privateca_v1beta1.types.ListCertificateRevocationListsRequest): - The initial request object. - response (google.cloud.security.privateca_v1beta1.types.ListCertificateRevocationListsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListCertificateRevocationListsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[service.ListCertificateRevocationListsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.CertificateRevocationList]: - async def async_generator(): - async for page in self.pages: - for response in page.certificate_revocation_lists: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListReusableConfigsPager: - """A pager for iterating through ``list_reusable_configs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1beta1.types.ListReusableConfigsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``reusable_configs`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListReusableConfigs`` requests and continue to iterate - through the ``reusable_configs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1beta1.types.ListReusableConfigsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., service.ListReusableConfigsResponse], - request: service.ListReusableConfigsRequest, - response: service.ListReusableConfigsResponse, - *, - 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.security.privateca_v1beta1.types.ListReusableConfigsRequest): - The initial request object. - response (google.cloud.security.privateca_v1beta1.types.ListReusableConfigsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListReusableConfigsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[service.ListReusableConfigsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[resources.ReusableConfig]: - for page in self.pages: - yield from page.reusable_configs - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListReusableConfigsAsyncPager: - """A pager for iterating through ``list_reusable_configs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.security.privateca_v1beta1.types.ListReusableConfigsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``reusable_configs`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListReusableConfigs`` requests and continue to iterate - through the ``reusable_configs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.security.privateca_v1beta1.types.ListReusableConfigsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., Awaitable[service.ListReusableConfigsResponse]], - request: service.ListReusableConfigsRequest, - response: service.ListReusableConfigsResponse, - *, - 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.security.privateca_v1beta1.types.ListReusableConfigsRequest): - The initial request object. - response (google.cloud.security.privateca_v1beta1.types.ListReusableConfigsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = service.ListReusableConfigsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[service.ListReusableConfigsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[resources.ReusableConfig]: - async def async_generator(): - async for page in self.pages: - for response in page.reusable_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/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/__init__.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/__init__.py deleted file mode 100644 index 8a08053..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -from typing import Dict, Type - -from .base import CertificateAuthorityServiceTransport -from .grpc import CertificateAuthorityServiceGrpcTransport -from .grpc_asyncio import CertificateAuthorityServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[CertificateAuthorityServiceTransport]] -_transport_registry['grpc'] = CertificateAuthorityServiceGrpcTransport -_transport_registry['grpc_asyncio'] = CertificateAuthorityServiceGrpcAsyncIOTransport - -__all__ = ( - 'CertificateAuthorityServiceTransport', - 'CertificateAuthorityServiceGrpcTransport', - 'CertificateAuthorityServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py deleted file mode 100644 index a6deba5..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py +++ /dev/null @@ -1,456 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version -import pkg_resources - -import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore - -from google.cloud.security.privateca_v1beta1.types import resources -from google.cloud.security.privateca_v1beta1.types import service -from google.longrunning import operations_pb2 # type: ignore - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-cloud-security-privateca', - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - -_API_CORE_VERSION = google.api_core.__version__ - - -class CertificateAuthorityServiceTransport(abc.ABC): - """Abstract transport class for CertificateAuthorityService.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) - - DEFAULT_HOST: str = 'privateca.googleapis.com' - def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - **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. - """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' - self._host = host - - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) - - # Save the scopes. - self._scopes = scopes or self.AUTH_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) - - # Save the credentials. - self._credentials = credentials - - # TODO(busunkim): These two class methods are in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-api-core - # and google-auth are increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - - # TODO: Remove this function once google-api-core >= 1.26.0 is required - @classmethod - def _get_self_signed_jwt_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Union[Optional[Sequence[str]], str]]: - """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" - - self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} - - if _API_CORE_VERSION and ( - packaging.version.parse(_API_CORE_VERSION) - >= packaging.version.parse("1.26.0") - ): - self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES - self_signed_jwt_kwargs["scopes"] = scopes - self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST - else: - self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES - - return self_signed_jwt_kwargs - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.create_certificate: gapic_v1.method.wrap_method( - self.create_certificate, - default_timeout=None, - client_info=client_info, - ), - self.get_certificate: gapic_v1.method.wrap_method( - self.get_certificate, - default_timeout=None, - client_info=client_info, - ), - self.list_certificates: gapic_v1.method.wrap_method( - self.list_certificates, - default_timeout=None, - client_info=client_info, - ), - self.revoke_certificate: gapic_v1.method.wrap_method( - self.revoke_certificate, - default_timeout=None, - client_info=client_info, - ), - self.update_certificate: gapic_v1.method.wrap_method( - self.update_certificate, - default_timeout=None, - client_info=client_info, - ), - self.activate_certificate_authority: gapic_v1.method.wrap_method( - self.activate_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.create_certificate_authority: gapic_v1.method.wrap_method( - self.create_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.disable_certificate_authority: gapic_v1.method.wrap_method( - self.disable_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.enable_certificate_authority: gapic_v1.method.wrap_method( - self.enable_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.fetch_certificate_authority_csr: gapic_v1.method.wrap_method( - self.fetch_certificate_authority_csr, - default_timeout=None, - client_info=client_info, - ), - self.get_certificate_authority: gapic_v1.method.wrap_method( - self.get_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.list_certificate_authorities: gapic_v1.method.wrap_method( - self.list_certificate_authorities, - default_timeout=None, - client_info=client_info, - ), - self.restore_certificate_authority: gapic_v1.method.wrap_method( - self.restore_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.schedule_delete_certificate_authority: gapic_v1.method.wrap_method( - self.schedule_delete_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.update_certificate_authority: gapic_v1.method.wrap_method( - self.update_certificate_authority, - default_timeout=None, - client_info=client_info, - ), - self.get_certificate_revocation_list: gapic_v1.method.wrap_method( - self.get_certificate_revocation_list, - default_timeout=None, - client_info=client_info, - ), - self.list_certificate_revocation_lists: gapic_v1.method.wrap_method( - self.list_certificate_revocation_lists, - default_timeout=None, - client_info=client_info, - ), - self.update_certificate_revocation_list: gapic_v1.method.wrap_method( - self.update_certificate_revocation_list, - default_timeout=None, - client_info=client_info, - ), - self.get_reusable_config: gapic_v1.method.wrap_method( - self.get_reusable_config, - default_timeout=None, - client_info=client_info, - ), - self.list_reusable_configs: gapic_v1.method.wrap_method( - self.list_reusable_configs, - default_timeout=None, - client_info=client_info, - ), - } - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def create_certificate(self) -> Callable[ - [service.CreateCertificateRequest], - Union[ - resources.Certificate, - Awaitable[resources.Certificate] - ]]: - raise NotImplementedError() - - @property - def get_certificate(self) -> Callable[ - [service.GetCertificateRequest], - Union[ - resources.Certificate, - Awaitable[resources.Certificate] - ]]: - raise NotImplementedError() - - @property - def list_certificates(self) -> Callable[ - [service.ListCertificatesRequest], - Union[ - service.ListCertificatesResponse, - Awaitable[service.ListCertificatesResponse] - ]]: - raise NotImplementedError() - - @property - def revoke_certificate(self) -> Callable[ - [service.RevokeCertificateRequest], - Union[ - resources.Certificate, - Awaitable[resources.Certificate] - ]]: - raise NotImplementedError() - - @property - def update_certificate(self) -> Callable[ - [service.UpdateCertificateRequest], - Union[ - resources.Certificate, - Awaitable[resources.Certificate] - ]]: - raise NotImplementedError() - - @property - def activate_certificate_authority(self) -> Callable[ - [service.ActivateCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def create_certificate_authority(self) -> Callable[ - [service.CreateCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def disable_certificate_authority(self) -> Callable[ - [service.DisableCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def enable_certificate_authority(self) -> Callable[ - [service.EnableCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def fetch_certificate_authority_csr(self) -> Callable[ - [service.FetchCertificateAuthorityCsrRequest], - Union[ - service.FetchCertificateAuthorityCsrResponse, - Awaitable[service.FetchCertificateAuthorityCsrResponse] - ]]: - raise NotImplementedError() - - @property - def get_certificate_authority(self) -> Callable[ - [service.GetCertificateAuthorityRequest], - Union[ - resources.CertificateAuthority, - Awaitable[resources.CertificateAuthority] - ]]: - raise NotImplementedError() - - @property - def list_certificate_authorities(self) -> Callable[ - [service.ListCertificateAuthoritiesRequest], - Union[ - service.ListCertificateAuthoritiesResponse, - Awaitable[service.ListCertificateAuthoritiesResponse] - ]]: - raise NotImplementedError() - - @property - def restore_certificate_authority(self) -> Callable[ - [service.RestoreCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def schedule_delete_certificate_authority(self) -> Callable[ - [service.ScheduleDeleteCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_certificate_authority(self) -> Callable[ - [service.UpdateCertificateAuthorityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_certificate_revocation_list(self) -> Callable[ - [service.GetCertificateRevocationListRequest], - Union[ - resources.CertificateRevocationList, - Awaitable[resources.CertificateRevocationList] - ]]: - raise NotImplementedError() - - @property - def list_certificate_revocation_lists(self) -> Callable[ - [service.ListCertificateRevocationListsRequest], - Union[ - service.ListCertificateRevocationListsResponse, - Awaitable[service.ListCertificateRevocationListsResponse] - ]]: - raise NotImplementedError() - - @property - def update_certificate_revocation_list(self) -> Callable[ - [service.UpdateCertificateRevocationListRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_reusable_config(self) -> Callable[ - [service.GetReusableConfigRequest], - Union[ - resources.ReusableConfig, - Awaitable[resources.ReusableConfig] - ]]: - raise NotImplementedError() - - @property - def list_reusable_configs(self) -> Callable[ - [service.ListReusableConfigsRequest], - Union[ - service.ListReusableConfigsResponse, - Awaitable[service.ListReusableConfigsResponse] - ]]: - raise NotImplementedError() - - -__all__ = ( - 'CertificateAuthorityServiceTransport', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py deleted file mode 100644 index 9ab03ab..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py +++ /dev/null @@ -1,814 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.security.privateca_v1beta1.types import resources -from google.cloud.security.privateca_v1beta1.types import service -from google.longrunning import operations_pb2 # type: ignore -from .base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO - - -class CertificateAuthorityServiceGrpcTransport(CertificateAuthorityServiceTransport): - """gRPC backend transport for CertificateAuthorityService. - - [Certificate Authority - Service][google.cloud.security.privateca.v1beta1.CertificateAuthorityService] - manages private certificate authorities and issued certificates. - - 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 = 'privateca.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel(cls, - host: str = 'privateca.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - **self_signed_jwt_kwargs, - **kwargs - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def create_certificate(self) -> Callable[ - [service.CreateCertificateRequest], - resources.Certificate]: - r"""Return a callable for the create certificate method over gRPC. - - Create a new - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - in a given Project, Location from a particular - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Returns: - Callable[[~.CreateCertificateRequest], - ~.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 'create_certificate' not in self._stubs: - self._stubs['create_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificate', - request_serializer=service.CreateCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['create_certificate'] - - @property - def get_certificate(self) -> Callable[ - [service.GetCertificateRequest], - resources.Certificate]: - r"""Return a callable for the get certificate method over gRPC. - - Returns a - [Certificate][google.cloud.security.privateca.v1beta1.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.security.privateca.v1beta1.CertificateAuthorityService/GetCertificate', - request_serializer=service.GetCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['get_certificate'] - - @property - def list_certificates(self) -> Callable[ - [service.ListCertificatesRequest], - service.ListCertificatesResponse]: - r"""Return a callable for the list certificates method over gRPC. - - Lists - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - 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.security.privateca.v1beta1.CertificateAuthorityService/ListCertificates', - request_serializer=service.ListCertificatesRequest.serialize, - response_deserializer=service.ListCertificatesResponse.deserialize, - ) - return self._stubs['list_certificates'] - - @property - def revoke_certificate(self) -> Callable[ - [service.RevokeCertificateRequest], - resources.Certificate]: - r"""Return a callable for the revoke certificate method over gRPC. - - Revoke a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - - Returns: - Callable[[~.RevokeCertificateRequest], - ~.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 'revoke_certificate' not in self._stubs: - self._stubs['revoke_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RevokeCertificate', - request_serializer=service.RevokeCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['revoke_certificate'] - - @property - def update_certificate(self) -> Callable[ - [service.UpdateCertificateRequest], - resources.Certificate]: - r"""Return a callable for the update certificate method over gRPC. - - Update a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - Currently, the only field you can update is the - [labels][google.cloud.security.privateca.v1beta1.Certificate.labels] - field. - - Returns: - Callable[[~.UpdateCertificateRequest], - ~.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 'update_certificate' not in self._stubs: - self._stubs['update_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificate', - request_serializer=service.UpdateCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['update_certificate'] - - @property - def activate_certificate_authority(self) -> Callable[ - [service.ActivateCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the activate certificate authority method over gRPC. - - Activate a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - that is in state - [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. - After the parent Certificate Authority signs a certificate - signing request from - [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr], - this method can complete the activation process. - - Returns: - Callable[[~.ActivateCertificateAuthorityRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'activate_certificate_authority' not in self._stubs: - self._stubs['activate_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ActivateCertificateAuthority', - request_serializer=service.ActivateCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['activate_certificate_authority'] - - @property - def create_certificate_authority(self) -> Callable[ - [service.CreateCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the create certificate authority method over gRPC. - - Create a new - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in a given Project and Location. - - Returns: - Callable[[~.CreateCertificateAuthorityRequest], - ~.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_authority' not in self._stubs: - self._stubs['create_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificateAuthority', - request_serializer=service.CreateCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate_authority'] - - @property - def disable_certificate_authority(self) -> Callable[ - [service.DisableCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the disable certificate authority method over gRPC. - - Disable a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Returns: - Callable[[~.DisableCertificateAuthorityRequest], - ~.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 'disable_certificate_authority' not in self._stubs: - self._stubs['disable_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/DisableCertificateAuthority', - request_serializer=service.DisableCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['disable_certificate_authority'] - - @property - def enable_certificate_authority(self) -> Callable[ - [service.EnableCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the enable certificate authority method over gRPC. - - Enable a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Returns: - Callable[[~.EnableCertificateAuthorityRequest], - ~.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 'enable_certificate_authority' not in self._stubs: - self._stubs['enable_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/EnableCertificateAuthority', - request_serializer=service.EnableCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['enable_certificate_authority'] - - @property - def fetch_certificate_authority_csr(self) -> Callable[ - [service.FetchCertificateAuthorityCsrRequest], - service.FetchCertificateAuthorityCsrResponse]: - r"""Return a callable for the fetch certificate authority - csr method over gRPC. - - Fetch a certificate signing request (CSR) from a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - that is in state - [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. - The CSR must then be signed by the desired parent Certificate - Authority, which could be another - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - resource, or could be an on-prem certificate authority. See also - [ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. - - Returns: - Callable[[~.FetchCertificateAuthorityCsrRequest], - ~.FetchCertificateAuthorityCsrResponse]: - 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 'fetch_certificate_authority_csr' not in self._stubs: - self._stubs['fetch_certificate_authority_csr'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/FetchCertificateAuthorityCsr', - request_serializer=service.FetchCertificateAuthorityCsrRequest.serialize, - response_deserializer=service.FetchCertificateAuthorityCsrResponse.deserialize, - ) - return self._stubs['fetch_certificate_authority_csr'] - - @property - def get_certificate_authority(self) -> Callable[ - [service.GetCertificateAuthorityRequest], - resources.CertificateAuthority]: - r"""Return a callable for the get certificate authority method over gRPC. - - Returns a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Returns: - Callable[[~.GetCertificateAuthorityRequest], - ~.CertificateAuthority]: - 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_authority' not in self._stubs: - self._stubs['get_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificateAuthority', - request_serializer=service.GetCertificateAuthorityRequest.serialize, - response_deserializer=resources.CertificateAuthority.deserialize, - ) - return self._stubs['get_certificate_authority'] - - @property - def list_certificate_authorities(self) -> Callable[ - [service.ListCertificateAuthoritiesRequest], - service.ListCertificateAuthoritiesResponse]: - r"""Return a callable for the list certificate authorities method over gRPC. - - Lists - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Returns: - Callable[[~.ListCertificateAuthoritiesRequest], - ~.ListCertificateAuthoritiesResponse]: - 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_authorities' not in self._stubs: - self._stubs['list_certificate_authorities'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificateAuthorities', - request_serializer=service.ListCertificateAuthoritiesRequest.serialize, - response_deserializer=service.ListCertificateAuthoritiesResponse.deserialize, - ) - return self._stubs['list_certificate_authorities'] - - @property - def restore_certificate_authority(self) -> Callable[ - [service.RestoreCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the restore certificate authority method over gRPC. - - Restore a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - that is scheduled for deletion. - - Returns: - Callable[[~.RestoreCertificateAuthorityRequest], - ~.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 'restore_certificate_authority' not in self._stubs: - self._stubs['restore_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RestoreCertificateAuthority', - request_serializer=service.RestoreCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['restore_certificate_authority'] - - @property - def schedule_delete_certificate_authority(self) -> Callable[ - [service.ScheduleDeleteCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the schedule delete certificate - authority method over gRPC. - - Schedule a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - for deletion. - - Returns: - Callable[[~.ScheduleDeleteCertificateAuthorityRequest], - ~.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 'schedule_delete_certificate_authority' not in self._stubs: - self._stubs['schedule_delete_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ScheduleDeleteCertificateAuthority', - request_serializer=service.ScheduleDeleteCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['schedule_delete_certificate_authority'] - - @property - def update_certificate_authority(self) -> Callable[ - [service.UpdateCertificateAuthorityRequest], - operations_pb2.Operation]: - r"""Return a callable for the update certificate authority method over gRPC. - - Update a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Returns: - Callable[[~.UpdateCertificateAuthorityRequest], - ~.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_authority' not in self._stubs: - self._stubs['update_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateAuthority', - request_serializer=service.UpdateCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_authority'] - - @property - def get_certificate_revocation_list(self) -> Callable[ - [service.GetCertificateRevocationListRequest], - resources.CertificateRevocationList]: - r"""Return a callable for the get certificate revocation - list method over gRPC. - - Returns a - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - - Returns: - Callable[[~.GetCertificateRevocationListRequest], - ~.CertificateRevocationList]: - 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_revocation_list' not in self._stubs: - self._stubs['get_certificate_revocation_list'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificateRevocationList', - request_serializer=service.GetCertificateRevocationListRequest.serialize, - response_deserializer=resources.CertificateRevocationList.deserialize, - ) - return self._stubs['get_certificate_revocation_list'] - - @property - def list_certificate_revocation_lists(self) -> Callable[ - [service.ListCertificateRevocationListsRequest], - service.ListCertificateRevocationListsResponse]: - r"""Return a callable for the list certificate revocation - lists method over gRPC. - - Lists - [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - - Returns: - Callable[[~.ListCertificateRevocationListsRequest], - ~.ListCertificateRevocationListsResponse]: - 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_revocation_lists' not in self._stubs: - self._stubs['list_certificate_revocation_lists'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificateRevocationLists', - request_serializer=service.ListCertificateRevocationListsRequest.serialize, - response_deserializer=service.ListCertificateRevocationListsResponse.deserialize, - ) - return self._stubs['list_certificate_revocation_lists'] - - @property - def update_certificate_revocation_list(self) -> Callable[ - [service.UpdateCertificateRevocationListRequest], - operations_pb2.Operation]: - r"""Return a callable for the update certificate revocation - list method over gRPC. - - Update a - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - - Returns: - Callable[[~.UpdateCertificateRevocationListRequest], - ~.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_revocation_list' not in self._stubs: - self._stubs['update_certificate_revocation_list'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateRevocationList', - request_serializer=service.UpdateCertificateRevocationListRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_revocation_list'] - - @property - def get_reusable_config(self) -> Callable[ - [service.GetReusableConfigRequest], - resources.ReusableConfig]: - r"""Return a callable for the get reusable config method over gRPC. - - Returns a - [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig]. - - Returns: - Callable[[~.GetReusableConfigRequest], - ~.ReusableConfig]: - 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_reusable_config' not in self._stubs: - self._stubs['get_reusable_config'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetReusableConfig', - request_serializer=service.GetReusableConfigRequest.serialize, - response_deserializer=resources.ReusableConfig.deserialize, - ) - return self._stubs['get_reusable_config'] - - @property - def list_reusable_configs(self) -> Callable[ - [service.ListReusableConfigsRequest], - service.ListReusableConfigsResponse]: - r"""Return a callable for the list reusable configs method over gRPC. - - Lists - [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig]. - - Returns: - Callable[[~.ListReusableConfigsRequest], - ~.ListReusableConfigsResponse]: - 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_reusable_configs' not in self._stubs: - self._stubs['list_reusable_configs'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListReusableConfigs', - request_serializer=service.ListReusableConfigsRequest.serialize, - response_deserializer=service.ListReusableConfigsResponse.deserialize, - ) - return self._stubs['list_reusable_configs'] - - -__all__ = ( - 'CertificateAuthorityServiceGrpcTransport', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py deleted file mode 100644 index c3515ff..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,818 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.security.privateca_v1beta1.types import resources -from google.cloud.security.privateca_v1beta1.types import service -from google.longrunning import operations_pb2 # type: ignore -from .base import CertificateAuthorityServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import CertificateAuthorityServiceGrpcTransport - - -class CertificateAuthorityServiceGrpcAsyncIOTransport(CertificateAuthorityServiceTransport): - """gRPC AsyncIO backend transport for CertificateAuthorityService. - - [Certificate Authority - Service][google.cloud.security.privateca.v1beta1.CertificateAuthorityService] - manages private certificate authorities and issued certificates. - - 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 = 'privateca.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - **self_signed_jwt_kwargs, - **kwargs - ) - - def __init__(self, *, - host: str = 'privateca.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsAsyncClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def create_certificate(self) -> Callable[ - [service.CreateCertificateRequest], - Awaitable[resources.Certificate]]: - r"""Return a callable for the create certificate method over gRPC. - - Create a new - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - in a given Project, Location from a particular - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Returns: - Callable[[~.CreateCertificateRequest], - 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 'create_certificate' not in self._stubs: - self._stubs['create_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificate', - request_serializer=service.CreateCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['create_certificate'] - - @property - def get_certificate(self) -> Callable[ - [service.GetCertificateRequest], - Awaitable[resources.Certificate]]: - r"""Return a callable for the get certificate method over gRPC. - - Returns a - [Certificate][google.cloud.security.privateca.v1beta1.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.security.privateca.v1beta1.CertificateAuthorityService/GetCertificate', - request_serializer=service.GetCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['get_certificate'] - - @property - def list_certificates(self) -> Callable[ - [service.ListCertificatesRequest], - Awaitable[service.ListCertificatesResponse]]: - r"""Return a callable for the list certificates method over gRPC. - - Lists - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - 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.security.privateca.v1beta1.CertificateAuthorityService/ListCertificates', - request_serializer=service.ListCertificatesRequest.serialize, - response_deserializer=service.ListCertificatesResponse.deserialize, - ) - return self._stubs['list_certificates'] - - @property - def revoke_certificate(self) -> Callable[ - [service.RevokeCertificateRequest], - Awaitable[resources.Certificate]]: - r"""Return a callable for the revoke certificate method over gRPC. - - Revoke a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - - Returns: - Callable[[~.RevokeCertificateRequest], - 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 'revoke_certificate' not in self._stubs: - self._stubs['revoke_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RevokeCertificate', - request_serializer=service.RevokeCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['revoke_certificate'] - - @property - def update_certificate(self) -> Callable[ - [service.UpdateCertificateRequest], - Awaitable[resources.Certificate]]: - r"""Return a callable for the update certificate method over gRPC. - - Update a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - Currently, the only field you can update is the - [labels][google.cloud.security.privateca.v1beta1.Certificate.labels] - field. - - Returns: - Callable[[~.UpdateCertificateRequest], - 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 'update_certificate' not in self._stubs: - self._stubs['update_certificate'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificate', - request_serializer=service.UpdateCertificateRequest.serialize, - response_deserializer=resources.Certificate.deserialize, - ) - return self._stubs['update_certificate'] - - @property - def activate_certificate_authority(self) -> Callable[ - [service.ActivateCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the activate certificate authority method over gRPC. - - Activate a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - that is in state - [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. - After the parent Certificate Authority signs a certificate - signing request from - [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr], - this method can complete the activation process. - - Returns: - Callable[[~.ActivateCertificateAuthorityRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'activate_certificate_authority' not in self._stubs: - self._stubs['activate_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ActivateCertificateAuthority', - request_serializer=service.ActivateCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['activate_certificate_authority'] - - @property - def create_certificate_authority(self) -> Callable[ - [service.CreateCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create certificate authority method over gRPC. - - Create a new - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in a given Project and Location. - - Returns: - Callable[[~.CreateCertificateAuthorityRequest], - 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_authority' not in self._stubs: - self._stubs['create_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/CreateCertificateAuthority', - request_serializer=service.CreateCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_certificate_authority'] - - @property - def disable_certificate_authority(self) -> Callable[ - [service.DisableCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the disable certificate authority method over gRPC. - - Disable a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Returns: - Callable[[~.DisableCertificateAuthorityRequest], - 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 'disable_certificate_authority' not in self._stubs: - self._stubs['disable_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/DisableCertificateAuthority', - request_serializer=service.DisableCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['disable_certificate_authority'] - - @property - def enable_certificate_authority(self) -> Callable[ - [service.EnableCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the enable certificate authority method over gRPC. - - Enable a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Returns: - Callable[[~.EnableCertificateAuthorityRequest], - 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 'enable_certificate_authority' not in self._stubs: - self._stubs['enable_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/EnableCertificateAuthority', - request_serializer=service.EnableCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['enable_certificate_authority'] - - @property - def fetch_certificate_authority_csr(self) -> Callable[ - [service.FetchCertificateAuthorityCsrRequest], - Awaitable[service.FetchCertificateAuthorityCsrResponse]]: - r"""Return a callable for the fetch certificate authority - csr method over gRPC. - - Fetch a certificate signing request (CSR) from a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - that is in state - [PENDING_ACTIVATION][google.cloud.security.privateca.v1beta1.CertificateAuthority.State.PENDING_ACTIVATION] - and is of type - [SUBORDINATE][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type.SUBORDINATE]. - The CSR must then be signed by the desired parent Certificate - Authority, which could be another - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - resource, or could be an on-prem certificate authority. See also - [ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. - - Returns: - Callable[[~.FetchCertificateAuthorityCsrRequest], - Awaitable[~.FetchCertificateAuthorityCsrResponse]]: - 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 'fetch_certificate_authority_csr' not in self._stubs: - self._stubs['fetch_certificate_authority_csr'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/FetchCertificateAuthorityCsr', - request_serializer=service.FetchCertificateAuthorityCsrRequest.serialize, - response_deserializer=service.FetchCertificateAuthorityCsrResponse.deserialize, - ) - return self._stubs['fetch_certificate_authority_csr'] - - @property - def get_certificate_authority(self) -> Callable[ - [service.GetCertificateAuthorityRequest], - Awaitable[resources.CertificateAuthority]]: - r"""Return a callable for the get certificate authority method over gRPC. - - Returns a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Returns: - Callable[[~.GetCertificateAuthorityRequest], - Awaitable[~.CertificateAuthority]]: - 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_authority' not in self._stubs: - self._stubs['get_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificateAuthority', - request_serializer=service.GetCertificateAuthorityRequest.serialize, - response_deserializer=resources.CertificateAuthority.deserialize, - ) - return self._stubs['get_certificate_authority'] - - @property - def list_certificate_authorities(self) -> Callable[ - [service.ListCertificateAuthoritiesRequest], - Awaitable[service.ListCertificateAuthoritiesResponse]]: - r"""Return a callable for the list certificate authorities method over gRPC. - - Lists - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Returns: - Callable[[~.ListCertificateAuthoritiesRequest], - Awaitable[~.ListCertificateAuthoritiesResponse]]: - 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_authorities' not in self._stubs: - self._stubs['list_certificate_authorities'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificateAuthorities', - request_serializer=service.ListCertificateAuthoritiesRequest.serialize, - response_deserializer=service.ListCertificateAuthoritiesResponse.deserialize, - ) - return self._stubs['list_certificate_authorities'] - - @property - def restore_certificate_authority(self) -> Callable[ - [service.RestoreCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the restore certificate authority method over gRPC. - - Restore a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - that is scheduled for deletion. - - Returns: - Callable[[~.RestoreCertificateAuthorityRequest], - 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 'restore_certificate_authority' not in self._stubs: - self._stubs['restore_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/RestoreCertificateAuthority', - request_serializer=service.RestoreCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['restore_certificate_authority'] - - @property - def schedule_delete_certificate_authority(self) -> Callable[ - [service.ScheduleDeleteCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the schedule delete certificate - authority method over gRPC. - - Schedule a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - for deletion. - - Returns: - Callable[[~.ScheduleDeleteCertificateAuthorityRequest], - 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 'schedule_delete_certificate_authority' not in self._stubs: - self._stubs['schedule_delete_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ScheduleDeleteCertificateAuthority', - request_serializer=service.ScheduleDeleteCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['schedule_delete_certificate_authority'] - - @property - def update_certificate_authority(self) -> Callable[ - [service.UpdateCertificateAuthorityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update certificate authority method over gRPC. - - Update a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Returns: - Callable[[~.UpdateCertificateAuthorityRequest], - 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_authority' not in self._stubs: - self._stubs['update_certificate_authority'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateAuthority', - request_serializer=service.UpdateCertificateAuthorityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_authority'] - - @property - def get_certificate_revocation_list(self) -> Callable[ - [service.GetCertificateRevocationListRequest], - Awaitable[resources.CertificateRevocationList]]: - r"""Return a callable for the get certificate revocation - list method over gRPC. - - Returns a - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - - Returns: - Callable[[~.GetCertificateRevocationListRequest], - Awaitable[~.CertificateRevocationList]]: - 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_revocation_list' not in self._stubs: - self._stubs['get_certificate_revocation_list'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetCertificateRevocationList', - request_serializer=service.GetCertificateRevocationListRequest.serialize, - response_deserializer=resources.CertificateRevocationList.deserialize, - ) - return self._stubs['get_certificate_revocation_list'] - - @property - def list_certificate_revocation_lists(self) -> Callable[ - [service.ListCertificateRevocationListsRequest], - Awaitable[service.ListCertificateRevocationListsResponse]]: - r"""Return a callable for the list certificate revocation - lists method over gRPC. - - Lists - [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - - Returns: - Callable[[~.ListCertificateRevocationListsRequest], - Awaitable[~.ListCertificateRevocationListsResponse]]: - 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_revocation_lists' not in self._stubs: - self._stubs['list_certificate_revocation_lists'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListCertificateRevocationLists', - request_serializer=service.ListCertificateRevocationListsRequest.serialize, - response_deserializer=service.ListCertificateRevocationListsResponse.deserialize, - ) - return self._stubs['list_certificate_revocation_lists'] - - @property - def update_certificate_revocation_list(self) -> Callable[ - [service.UpdateCertificateRevocationListRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update certificate revocation - list method over gRPC. - - Update a - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - - Returns: - Callable[[~.UpdateCertificateRevocationListRequest], - 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_revocation_list' not in self._stubs: - self._stubs['update_certificate_revocation_list'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/UpdateCertificateRevocationList', - request_serializer=service.UpdateCertificateRevocationListRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_certificate_revocation_list'] - - @property - def get_reusable_config(self) -> Callable[ - [service.GetReusableConfigRequest], - Awaitable[resources.ReusableConfig]]: - r"""Return a callable for the get reusable config method over gRPC. - - Returns a - [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig]. - - Returns: - Callable[[~.GetReusableConfigRequest], - Awaitable[~.ReusableConfig]]: - 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_reusable_config' not in self._stubs: - self._stubs['get_reusable_config'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/GetReusableConfig', - request_serializer=service.GetReusableConfigRequest.serialize, - response_deserializer=resources.ReusableConfig.deserialize, - ) - return self._stubs['get_reusable_config'] - - @property - def list_reusable_configs(self) -> Callable[ - [service.ListReusableConfigsRequest], - Awaitable[service.ListReusableConfigsResponse]]: - r"""Return a callable for the list reusable configs method over gRPC. - - Lists - [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig]. - - Returns: - Callable[[~.ListReusableConfigsRequest], - Awaitable[~.ListReusableConfigsResponse]]: - 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_reusable_configs' not in self._stubs: - self._stubs['list_reusable_configs'] = self.grpc_channel.unary_unary( - '/google.cloud.security.privateca.v1beta1.CertificateAuthorityService/ListReusableConfigs', - request_serializer=service.ListReusableConfigsRequest.serialize, - response_deserializer=service.ListReusableConfigsResponse.deserialize, - ) - return self._stubs['list_reusable_configs'] - - -__all__ = ( - 'CertificateAuthorityServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/__init__.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/__init__.py deleted file mode 100644 index 30b7963..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/__init__.py +++ /dev/null @@ -1,106 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from .resources import ( - Certificate, - CertificateAuthority, - CertificateConfig, - CertificateDescription, - CertificateRevocationList, - KeyUsage, - ObjectId, - PublicKey, - ReusableConfig, - ReusableConfigValues, - ReusableConfigWrapper, - Subject, - SubjectAltNames, - SubordinateConfig, - X509Extension, - RevocationReason, -) -from .service import ( - ActivateCertificateAuthorityRequest, - CreateCertificateAuthorityRequest, - CreateCertificateRequest, - DisableCertificateAuthorityRequest, - EnableCertificateAuthorityRequest, - FetchCertificateAuthorityCsrRequest, - FetchCertificateAuthorityCsrResponse, - GetCertificateAuthorityRequest, - GetCertificateRequest, - GetCertificateRevocationListRequest, - GetReusableConfigRequest, - ListCertificateAuthoritiesRequest, - ListCertificateAuthoritiesResponse, - ListCertificateRevocationListsRequest, - ListCertificateRevocationListsResponse, - ListCertificatesRequest, - ListCertificatesResponse, - ListReusableConfigsRequest, - ListReusableConfigsResponse, - OperationMetadata, - RestoreCertificateAuthorityRequest, - RevokeCertificateRequest, - ScheduleDeleteCertificateAuthorityRequest, - UpdateCertificateAuthorityRequest, - UpdateCertificateRequest, - UpdateCertificateRevocationListRequest, -) - -__all__ = ( - 'Certificate', - 'CertificateAuthority', - 'CertificateConfig', - 'CertificateDescription', - 'CertificateRevocationList', - 'KeyUsage', - 'ObjectId', - 'PublicKey', - 'ReusableConfig', - 'ReusableConfigValues', - 'ReusableConfigWrapper', - 'Subject', - 'SubjectAltNames', - 'SubordinateConfig', - 'X509Extension', - 'RevocationReason', - 'ActivateCertificateAuthorityRequest', - 'CreateCertificateAuthorityRequest', - 'CreateCertificateRequest', - 'DisableCertificateAuthorityRequest', - 'EnableCertificateAuthorityRequest', - 'FetchCertificateAuthorityCsrRequest', - 'FetchCertificateAuthorityCsrResponse', - 'GetCertificateAuthorityRequest', - 'GetCertificateRequest', - 'GetCertificateRevocationListRequest', - 'GetReusableConfigRequest', - 'ListCertificateAuthoritiesRequest', - 'ListCertificateAuthoritiesResponse', - 'ListCertificateRevocationListsRequest', - 'ListCertificateRevocationListsResponse', - 'ListCertificatesRequest', - 'ListCertificatesResponse', - 'ListReusableConfigsRequest', - 'ListReusableConfigsResponse', - 'OperationMetadata', - 'RestoreCertificateAuthorityRequest', - 'RevokeCertificateRequest', - 'ScheduleDeleteCertificateAuthorityRequest', - 'UpdateCertificateAuthorityRequest', - 'UpdateCertificateRequest', - 'UpdateCertificateRevocationListRequest', -) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/resources.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/resources.py deleted file mode 100644 index ec1ccf3..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/resources.py +++ /dev/null @@ -1,1687 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import proto # type: ignore - -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.security.privateca.v1beta1', - manifest={ - 'RevocationReason', - 'CertificateAuthority', - 'CertificateRevocationList', - 'Certificate', - 'ReusableConfig', - 'ReusableConfigValues', - 'ReusableConfigWrapper', - 'SubordinateConfig', - 'PublicKey', - 'CertificateConfig', - 'CertificateDescription', - 'ObjectId', - 'X509Extension', - 'KeyUsage', - 'Subject', - 'SubjectAltNames', - }, -) - - -class RevocationReason(proto.Enum): - r"""A - [RevocationReason][google.cloud.security.privateca.v1beta1.RevocationReason] - indicates whether a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - has been revoked, and the reason for revocation. These correspond to - standard revocation reasons from RFC 5280. Note that the enum labels - and values in this definition are not the same ASN.1 values defined - in RFC 5280. These values will be translated to the correct ASN.1 - values when a CRL is created. - """ - REVOCATION_REASON_UNSPECIFIED = 0 - KEY_COMPROMISE = 1 - CERTIFICATE_AUTHORITY_COMPROMISE = 2 - AFFILIATION_CHANGED = 3 - SUPERSEDED = 4 - CESSATION_OF_OPERATION = 5 - CERTIFICATE_HOLD = 6 - PRIVILEGE_WITHDRAWN = 7 - ATTRIBUTE_AUTHORITY_COMPROMISE = 8 - - -class CertificateAuthority(proto.Message): - r"""A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - represents an individual Certificate Authority. A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can be used to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - Attributes: - name (str): - Output only. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - type_ (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.Type): - Required. Immutable. The - [Type][google.cloud.security.privateca.v1beta1.CertificateAuthority.Type] - of this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - tier (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.Tier): - Required. Immutable. The - [Tier][google.cloud.security.privateca.v1beta1.CertificateAuthority.Tier] - of this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - config (google.cloud.security.privateca_v1beta1.types.CertificateConfig): - Required. Immutable. The config used to - create a self-signed X.509 certificate or CSR. - lifetime (google.protobuf.duration_pb2.Duration): - Required. The desired lifetime of the CA certificate. Used - to create the "not_before_time" and "not_after_time" fields - inside an X.509 certificate. - key_spec (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.KeyVersionSpec): - Required. Immutable. Used when issuing certificates for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - If this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - is a self-signed CertificateAuthority, this key is also used - to sign the self-signed CA certificate. Otherwise, it is - used to sign a CSR. - certificate_policy (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.CertificateAuthorityPolicy): - Optional. The - [CertificateAuthorityPolicy][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy] - to enforce when issuing - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - from this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - issuing_options (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.IssuingOptions): - Optional. The - [IssuingOptions][google.cloud.security.privateca.v1beta1.CertificateAuthority.IssuingOptions] - to follow when issuing - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - from this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - subordinate_config (google.cloud.security.privateca_v1beta1.types.SubordinateConfig): - Optional. If this is a subordinate - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority], - this field will be set with the subordinate configuration, - which describes its issuers. This may be updated, but this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - must continue to validate. - state (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.State): - Output only. The - [State][google.cloud.security.privateca.v1beta1.CertificateAuthority.State] - for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - pem_ca_certificates (Sequence[str]): - Output only. This - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]'s - certificate chain, including the current - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]'s - certificate. Ordered such that the root issuer is the final - element (consistent with RFC 5246). For a self-signed CA, - this will only list the current - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]'s - certificate. - ca_certificate_descriptions (Sequence[google.cloud.security.privateca_v1beta1.types.CertificateDescription]): - Output only. A structured description of this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]'s - CA certificate and its issuers. Ordered as self-to-root. - gcs_bucket (str): - Immutable. The name of a Cloud Storage bucket where this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - will publish content, such as the CA certificate and CRLs. - This must be a bucket name, without any prefixes (such as - ``gs://``) or suffixes (such as ``.googleapis.com``). For - example, to use a bucket named ``my-bucket``, you would - simply specify ``my-bucket``. If not specified, a managed - bucket will be created. - access_urls (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.AccessUrls): - Output only. URLs for accessing content - published by this CA, such as the CA certificate - and CRLs. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - was updated. - delete_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - will be deleted, if scheduled for deletion. - labels (Sequence[google.cloud.security.privateca_v1beta1.types.CertificateAuthority.LabelsEntry]): - Optional. Labels with user-defined metadata. - """ - class Type(proto.Enum): - r"""The type of a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority], - indicating its issuing chain. - """ - TYPE_UNSPECIFIED = 0 - SELF_SIGNED = 1 - SUBORDINATE = 2 - - class Tier(proto.Enum): - r"""The tier of a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority], - indicating its supported functionality and/or billing SKU. - """ - TIER_UNSPECIFIED = 0 - ENTERPRISE = 1 - DEVOPS = 2 - - class State(proto.Enum): - r"""The state of a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority], - indicating if it can be used. - """ - STATE_UNSPECIFIED = 0 - ENABLED = 1 - DISABLED = 2 - PENDING_ACTIVATION = 3 - PENDING_DELETION = 4 - - class SignHashAlgorithm(proto.Enum): - r"""The algorithm of a Cloud KMS CryptoKeyVersion of a - [CryptoKey][google.cloud.kms.v1.CryptoKey] with the - [CryptoKeyPurpose][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose] - value ``ASYMMETRIC_SIGN``. These values correspond to the - [CryptoKeyVersionAlgorithm][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionAlgorithm] - values. For RSA signing algorithms, the PSS algorithms should be - preferred, use PKCS1 algorithms if required for compatibility. For - further recommandations, see - https://cloud.google.com/kms/docs/algorithms#algorithm_recommendations. - """ - SIGN_HASH_ALGORITHM_UNSPECIFIED = 0 - RSA_PSS_2048_SHA256 = 1 - RSA_PSS_3072_SHA256 = 2 - RSA_PSS_4096_SHA256 = 3 - RSA_PKCS1_2048_SHA256 = 6 - RSA_PKCS1_3072_SHA256 = 7 - RSA_PKCS1_4096_SHA256 = 8 - EC_P256_SHA256 = 4 - EC_P384_SHA384 = 5 - - class IssuingOptions(proto.Message): - r"""Options that affect all certificates issued by a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Attributes: - include_ca_cert_url (bool): - Required. When true, includes a URL to the - issuing CA certificate in the "authority - information access" X.509 extension. - include_crl_access_url (bool): - Required. When true, includes a URL to the CRL corresponding - to certificates issued from a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - CRLs will expire 7 days from their creation. However, we - will rebuild daily. CRLs are also rebuilt shortly after a - certificate is revoked. - """ - - include_ca_cert_url = proto.Field( - proto.BOOL, - number=1, - ) - include_crl_access_url = proto.Field( - proto.BOOL, - number=2, - ) - - class CertificateAuthorityPolicy(proto.Message): - r"""The issuing policy for a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - will not be successfully issued from this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - if they violate the policy. - - Attributes: - allowed_config_list (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.CertificateAuthorityPolicy.AllowedConfigList): - Optional. All - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - issued by the - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - must match at least one listed - [ReusableConfigWrapper][google.cloud.security.privateca.v1beta1.ReusableConfigWrapper] - in the list. - overwrite_config_values (google.cloud.security.privateca_v1beta1.types.ReusableConfigWrapper): - Optional. All - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - issued by the - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - will use the provided configuration values, overwriting any - requested configuration values. - allowed_locations_and_organizations (Sequence[google.cloud.security.privateca_v1beta1.types.Subject]): - Optional. If any - [Subject][google.cloud.security.privateca.v1beta1.Subject] - is specified here, then all - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - issued by the - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - must match at least one listed - [Subject][google.cloud.security.privateca.v1beta1.Subject]. - If a - [Subject][google.cloud.security.privateca.v1beta1.Subject] - has an empty field, any value will be allowed for that - field. - allowed_common_names (Sequence[str]): - Optional. If any value is specified here, then all - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - issued by the - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - must match at least one listed value. If no value is - specified, all values will be allowed for this fied. Glob - patterns are also supported. - allowed_sans (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames): - Optional. If a - [AllowedSubjectAltNames][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames] - is specified here, then all - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - issued by the - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - must match - [AllowedSubjectAltNames][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames]. - If no value or an empty value is specified, any value will - be allowed for the - [SubjectAltNames][google.cloud.security.privateca.v1beta1.SubjectAltNames] - field. - maximum_lifetime (google.protobuf.duration_pb2.Duration): - Optional. The maximum lifetime allowed by the - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - Note that if the any part if the issuing chain expires - before a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]'s - requested maximum_lifetime, the effective lifetime will be - explicitly truncated. - allowed_issuance_modes (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.CertificateAuthorityPolicy.IssuanceModes): - Optional. If specified, then only methods allowed in the - [IssuanceModes][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.IssuanceModes] - may be used to issue - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - """ - - class AllowedConfigList(proto.Message): - r""" - Attributes: - allowed_config_values (Sequence[google.cloud.security.privateca_v1beta1.types.ReusableConfigWrapper]): - Required. All - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - issued by the - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - must match at least one listed - [ReusableConfigWrapper][google.cloud.security.privateca.v1beta1.ReusableConfigWrapper]. - If a - [ReusableConfigWrapper][google.cloud.security.privateca.v1beta1.ReusableConfigWrapper] - has an empty field, any value will be allowed for that - field. - """ - - allowed_config_values = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='ReusableConfigWrapper', - ) - - class AllowedSubjectAltNames(proto.Message): - r"""[AllowedSubjectAltNames][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames] - specifies the allowed values for - [SubjectAltNames][google.cloud.security.privateca.v1beta1.SubjectAltNames] - by the - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - when issuing - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - - Attributes: - allowed_dns_names (Sequence[str]): - Optional. Contains valid, fully-qualified host names. Glob - patterns are also supported. To allow an explicit wildcard - certificate, escape with backlash (i.e. "*"). E.g. for - globbed entries: '*bar.com' will allow foo.bar.com, but not - *.bar.com, unless the - [allow_globbing_dns_wildcards][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames.allow_globbing_dns_wildcards] - field is set. E.g. for wildcard entries: '*.bar.com' will - allow '*.bar.com', but not 'foo.bar.com'. - allowed_uris (Sequence[str]): - Optional. Contains valid RFC 3986 URIs. Glob patterns are - also supported. To match across path seperators (i.e. '/') - use the double star glob pattern (i.e. '**'). - allowed_email_addresses (Sequence[str]): - Optional. Contains valid RFC 2822 E-mail - addresses. Glob patterns are also supported. - allowed_ips (Sequence[str]): - Optional. Contains valid 32-bit IPv4 - addresses and subnet ranges or RFC 4291 IPv6 - addresses and subnet ranges. Subnet ranges are - specified using the '/' notation (e.g. - 10.0.0.0/8, 2001:700:300:1800::/64). Glob - patterns are supported only for ip address - entries (i.e. not for subnet ranges). - allow_globbing_dns_wildcards (bool): - Optional. Specifies if glob patterns used for - [allowed_dns_names][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames.allowed_dns_names] - allows wildcard certificates. - allow_custom_sans (bool): - Optional. Specifies if to allow custom - X509Extension values. - """ - - allowed_dns_names = proto.RepeatedField( - proto.STRING, - number=1, - ) - allowed_uris = proto.RepeatedField( - proto.STRING, - number=2, - ) - allowed_email_addresses = proto.RepeatedField( - proto.STRING, - number=3, - ) - allowed_ips = proto.RepeatedField( - proto.STRING, - number=4, - ) - allow_globbing_dns_wildcards = proto.Field( - proto.BOOL, - number=5, - ) - allow_custom_sans = proto.Field( - proto.BOOL, - number=6, - ) - - class IssuanceModes(proto.Message): - r"""[IssuanceModes][google.cloud.security.privateca.v1beta1.CertificateAuthority.CertificateAuthorityPolicy.IssuanceModes] - specifies the allowed ways in which - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - may be requested from this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Attributes: - allow_csr_based_issuance (bool): - Required. When true, allows callers to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - by specifying a CSR. - allow_config_based_issuance (bool): - Required. When true, allows callers to create - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - by specifying a - [CertificateConfig][google.cloud.security.privateca.v1beta1.CertificateConfig]. - """ - - allow_csr_based_issuance = proto.Field( - proto.BOOL, - number=1, - ) - allow_config_based_issuance = proto.Field( - proto.BOOL, - number=2, - ) - - allowed_config_list = proto.Field( - proto.MESSAGE, - number=1, - oneof='config_policy', - message='CertificateAuthority.CertificateAuthorityPolicy.AllowedConfigList', - ) - overwrite_config_values = proto.Field( - proto.MESSAGE, - number=2, - oneof='config_policy', - message='ReusableConfigWrapper', - ) - allowed_locations_and_organizations = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='Subject', - ) - allowed_common_names = proto.RepeatedField( - proto.STRING, - number=4, - ) - allowed_sans = proto.Field( - proto.MESSAGE, - number=5, - message='CertificateAuthority.CertificateAuthorityPolicy.AllowedSubjectAltNames', - ) - maximum_lifetime = proto.Field( - proto.MESSAGE, - number=6, - message=duration_pb2.Duration, - ) - allowed_issuance_modes = proto.Field( - proto.MESSAGE, - number=8, - message='CertificateAuthority.CertificateAuthorityPolicy.IssuanceModes', - ) - - class AccessUrls(proto.Message): - r"""URLs where a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - will publish content. - - Attributes: - ca_certificate_access_url (str): - The URL where this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]'s - CA certificate is published. This will only be set for CAs - that have been activated. - crl_access_url (str): - The URL where this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]'s - CRLs are published. This will only be set for CAs that have - been activated. - """ - - ca_certificate_access_url = proto.Field( - proto.STRING, - number=1, - ) - crl_access_url = proto.Field( - proto.STRING, - number=2, - ) - - class KeyVersionSpec(proto.Message): - r"""A Cloud KMS key configuration that a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - will use. - - Attributes: - cloud_kms_key_version (str): - Required. The resource name for an existing Cloud KMS - CryptoKeyVersion in the format - ``projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*``. - This option enables full flexibility in the key's - capabilities and properties. - algorithm (google.cloud.security.privateca_v1beta1.types.CertificateAuthority.SignHashAlgorithm): - Required. The algorithm to use for creating a managed Cloud - KMS key for a for a simplified experience. All managed keys - will be have their - [ProtectionLevel][google.cloud.kms.v1.ProtectionLevel] as - ``HSM``. - """ - - cloud_kms_key_version = proto.Field( - proto.STRING, - number=1, - oneof='KeyVersion', - ) - algorithm = proto.Field( - proto.ENUM, - number=2, - oneof='KeyVersion', - enum='CertificateAuthority.SignHashAlgorithm', - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - type_ = proto.Field( - proto.ENUM, - number=2, - enum=Type, - ) - tier = proto.Field( - proto.ENUM, - number=3, - enum=Tier, - ) - config = proto.Field( - proto.MESSAGE, - number=4, - message='CertificateConfig', - ) - lifetime = proto.Field( - proto.MESSAGE, - number=5, - message=duration_pb2.Duration, - ) - key_spec = proto.Field( - proto.MESSAGE, - number=6, - message=KeyVersionSpec, - ) - certificate_policy = proto.Field( - proto.MESSAGE, - number=7, - message=CertificateAuthorityPolicy, - ) - issuing_options = proto.Field( - proto.MESSAGE, - number=8, - message=IssuingOptions, - ) - subordinate_config = proto.Field( - proto.MESSAGE, - number=19, - message='SubordinateConfig', - ) - state = proto.Field( - proto.ENUM, - number=10, - enum=State, - ) - pem_ca_certificates = proto.RepeatedField( - proto.STRING, - number=9, - ) - ca_certificate_descriptions = proto.RepeatedField( - proto.MESSAGE, - number=12, - message='CertificateDescription', - ) - gcs_bucket = proto.Field( - proto.STRING, - number=13, - ) - access_urls = proto.Field( - proto.MESSAGE, - number=14, - message=AccessUrls, - ) - create_time = proto.Field( - proto.MESSAGE, - number=15, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=16, - message=timestamp_pb2.Timestamp, - ) - delete_time = proto.Field( - proto.MESSAGE, - number=17, - message=timestamp_pb2.Timestamp, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=18, - ) - - -class CertificateRevocationList(proto.Message): - r"""A - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] - corresponds to a signed X.509 certificate Revocation List (CRL). A - CRL contains the serial numbers of certificates that should no - longer be trusted. - - Attributes: - name (str): - Output only. The resource path for this - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] - in the format - ``projects/*/locations/*/certificateAuthorities/*/ certificateRevocationLists/*``. - sequence_number (int): - Output only. The CRL sequence number that appears in - pem_crl. - revoked_certificates (Sequence[google.cloud.security.privateca_v1beta1.types.CertificateRevocationList.RevokedCertificate]): - Output only. The revoked serial numbers that appear in - pem_crl. - pem_crl (str): - Output only. The PEM-encoded X.509 CRL. - access_url (str): - Output only. The location where 'pem_crl' can be accessed. - state (google.cloud.security.privateca_v1beta1.types.CertificateRevocationList.State): - Output only. The - [State][google.cloud.security.privateca.v1beta1.CertificateRevocationList.State] - for this - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] - was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] - was updated. - labels (Sequence[google.cloud.security.privateca_v1beta1.types.CertificateRevocationList.LabelsEntry]): - Optional. Labels with user-defined metadata. - """ - class State(proto.Enum): - r"""The state of a - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList], - indicating if it is current. - """ - STATE_UNSPECIFIED = 0 - ACTIVE = 1 - SUPERSEDED = 2 - - class RevokedCertificate(proto.Message): - r"""Describes a revoked - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - - Attributes: - certificate (str): - The resource path for the - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - in the format - ``projects/*/locations/*/certificateAuthorities/*/certificates/*``. - hex_serial_number (str): - The serial number of the - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - revocation_reason (google.cloud.security.privateca_v1beta1.types.RevocationReason): - The reason the - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - was revoked. - """ - - certificate = proto.Field( - proto.STRING, - number=1, - ) - hex_serial_number = proto.Field( - proto.STRING, - number=2, - ) - revocation_reason = proto.Field( - proto.ENUM, - number=3, - enum='RevocationReason', - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - sequence_number = proto.Field( - proto.INT64, - number=2, - ) - revoked_certificates = proto.RepeatedField( - proto.MESSAGE, - number=3, - message=RevokedCertificate, - ) - pem_crl = proto.Field( - proto.STRING, - number=4, - ) - access_url = proto.Field( - proto.STRING, - number=5, - ) - state = proto.Field( - proto.ENUM, - number=6, - enum=State, - ) - create_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=9, - ) - - -class Certificate(proto.Message): - r"""A [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - corresponds to a signed X.509 certificate issued by a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - - Attributes: - name (str): - Output only. The resource path for this - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - in the format - ``projects/*/locations/*/certificateAuthorities/*/certificates/*``. - pem_csr (str): - Immutable. A pem-encoded X.509 certificate - signing request (CSR). - config (google.cloud.security.privateca_v1beta1.types.CertificateConfig): - Immutable. A description of the certificate - and key that does not require X.509 or ASN.1. - lifetime (google.protobuf.duration_pb2.Duration): - Required. Immutable. The desired lifetime of a certificate. - Used to create the "not_before_time" and "not_after_time" - fields inside an X.509 certificate. Note that the lifetime - may be truncated if it would extend past the life of any - certificate authority in the issuing chain. - revocation_details (google.cloud.security.privateca_v1beta1.types.Certificate.RevocationDetails): - Output only. Details regarding the revocation of this - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - This - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - is considered revoked if and only if this field is present. - pem_certificate (str): - Output only. The pem-encoded, signed X.509 - certificate. - certificate_description (google.cloud.security.privateca_v1beta1.types.CertificateDescription): - Output only. A structured description of the - issued X.509 certificate. - pem_certificate_chain (Sequence[str]): - Output only. The chain that may be used to - verify the X.509 certificate. Expected to be in - issuer-to-root order according to RFC 5246. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - was updated. - labels (Sequence[google.cloud.security.privateca_v1beta1.types.Certificate.LabelsEntry]): - Optional. Labels with user-defined metadata. - """ - - class RevocationDetails(proto.Message): - r"""Describes fields that are relavent to the revocation of a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate]. - - Attributes: - revocation_state (google.cloud.security.privateca_v1beta1.types.RevocationReason): - Indicates why a - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - was revoked. - revocation_time (google.protobuf.timestamp_pb2.Timestamp): - The time at which this - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - was revoked. - """ - - revocation_state = proto.Field( - proto.ENUM, - number=1, - enum='RevocationReason', - ) - revocation_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - pem_csr = proto.Field( - proto.STRING, - number=2, - oneof='certificate_config', - ) - config = proto.Field( - proto.MESSAGE, - number=3, - oneof='certificate_config', - message='CertificateConfig', - ) - lifetime = proto.Field( - proto.MESSAGE, - number=4, - message=duration_pb2.Duration, - ) - revocation_details = proto.Field( - proto.MESSAGE, - number=5, - message=RevocationDetails, - ) - pem_certificate = proto.Field( - proto.STRING, - number=6, - ) - certificate_description = proto.Field( - proto.MESSAGE, - number=7, - message='CertificateDescription', - ) - pem_certificate_chain = proto.RepeatedField( - proto.STRING, - number=8, - ) - create_time = proto.Field( - proto.MESSAGE, - number=9, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=10, - message=timestamp_pb2.Timestamp, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=11, - ) - - -class ReusableConfig(proto.Message): - r"""A - [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] - refers to a managed - [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues]. - Those, in turn, are used to describe certain fields of an X.509 - certificate, such as the key usage fields, fields specific to CA - certificates, certificate policy extensions and custom extensions. - - Attributes: - name (str): - Output only. The resource path for this - [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] - in the format ``projects/*/locations/*/reusableConfigs/*``. - values (google.cloud.security.privateca_v1beta1.types.ReusableConfigValues): - Required. The config values. - description (str): - Optional. A human-readable description of - scenarios these ReusableConfigValues may be - compatible with. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] - was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this - [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] - was updated. - labels (Sequence[google.cloud.security.privateca_v1beta1.types.ReusableConfig.LabelsEntry]): - Optional. Labels with user-defined metadata. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - values = proto.Field( - proto.MESSAGE, - number=2, - message='ReusableConfigValues', - ) - description = proto.Field( - proto.STRING, - number=3, - ) - create_time = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=6, - ) - - -class ReusableConfigValues(proto.Message): - r"""A - [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues] - is used to describe certain fields of an X.509 certificate, such as - the key usage fields, fields specific to CA certificates, - certificate policy extensions and custom extensions. - - Attributes: - key_usage (google.cloud.security.privateca_v1beta1.types.KeyUsage): - Optional. Indicates the intended use for keys - that correspond to a certificate. - ca_options (google.cloud.security.privateca_v1beta1.types.ReusableConfigValues.CaOptions): - Optional. Describes options in this - [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues] - that are relevant in a CA certificate. - policy_ids (Sequence[google.cloud.security.privateca_v1beta1.types.ObjectId]): - Optional. Describes the X.509 certificate - policy object identifiers, per - https://tools.ietf.org/html/rfc5280#section-4.2.1.4. - aia_ocsp_servers (Sequence[str]): - Optional. Describes Online Certificate Status - Protocol (OCSP) endpoint addresses that appear - in the "Authority Information Access" extension - in the certificate. - additional_extensions (Sequence[google.cloud.security.privateca_v1beta1.types.X509Extension]): - Optional. Describes custom X.509 extensions. - """ - - class CaOptions(proto.Message): - r"""Describes values that are relevant in a CA certificate. - Attributes: - is_ca (google.protobuf.wrappers_pb2.BoolValue): - Optional. Refers to the "CA" X.509 extension, - which is a boolean value. When this value is - missing, the extension will be omitted from the - CA certificate. - max_issuer_path_length (google.protobuf.wrappers_pb2.Int32Value): - Optional. Refers to the path length - restriction X.509 extension. For a CA - certificate, this value describes the depth of - subordinate CA certificates that are allowed. - If this value is less than 0, the request will - fail. If this value is missing, the max path - length will be omitted from the CA certificate. - """ - - is_ca = proto.Field( - proto.MESSAGE, - number=1, - message=wrappers_pb2.BoolValue, - ) - max_issuer_path_length = proto.Field( - proto.MESSAGE, - number=2, - message=wrappers_pb2.Int32Value, - ) - - key_usage = proto.Field( - proto.MESSAGE, - number=1, - message='KeyUsage', - ) - ca_options = proto.Field( - proto.MESSAGE, - number=2, - message=CaOptions, - ) - policy_ids = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='ObjectId', - ) - aia_ocsp_servers = proto.RepeatedField( - proto.STRING, - number=4, - ) - additional_extensions = proto.RepeatedField( - proto.MESSAGE, - number=5, - message='X509Extension', - ) - - -class ReusableConfigWrapper(proto.Message): - r"""A - [ReusableConfigWrapper][google.cloud.security.privateca.v1beta1.ReusableConfigWrapper] - describes values that may assist in creating an X.509 certificate, - or a reference to a pre-defined set of values. - - Attributes: - reusable_config (str): - Required. A resource path to a - [ReusableConfig][google.cloud.security.privateca.v1beta1.ReusableConfig] - in the format ``projects/*/locations/*/reusableConfigs/*``. - reusable_config_values (google.cloud.security.privateca_v1beta1.types.ReusableConfigValues): - Required. A user-specified inline - [ReusableConfigValues][google.cloud.security.privateca.v1beta1.ReusableConfigValues]. - """ - - reusable_config = proto.Field( - proto.STRING, - number=1, - oneof='config_values', - ) - reusable_config_values = proto.Field( - proto.MESSAGE, - number=2, - oneof='config_values', - message='ReusableConfigValues', - ) - - -class SubordinateConfig(proto.Message): - r"""Describes a subordinate CA's issuers. This is either a resource path - to a known issuing - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority], - or a PEM issuer certificate chain. - - Attributes: - certificate_authority (str): - Required. This can refer to a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the same project that was used to create a subordinate - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - This field is used for information and usability purposes - only. The resource name is in the format - ``projects/*/locations/*/certificateAuthorities/*``. - pem_issuer_chain (google.cloud.security.privateca_v1beta1.types.SubordinateConfig.SubordinateConfigChain): - Required. Contains the PEM certificate chain for the issuers - of this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority], - but not pem certificate for this CA itself. - """ - - class SubordinateConfigChain(proto.Message): - r"""This message describes a subordinate CA's issuer certificate - chain. This wrapper exists for compatibility reasons. - - Attributes: - pem_certificates (Sequence[str]): - Required. Expected to be in leaf-to-root - order according to RFC 5246. - """ - - pem_certificates = proto.RepeatedField( - proto.STRING, - number=1, - ) - - certificate_authority = proto.Field( - proto.STRING, - number=1, - oneof='subordinate_config', - ) - pem_issuer_chain = proto.Field( - proto.MESSAGE, - number=2, - oneof='subordinate_config', - message=SubordinateConfigChain, - ) - - -class PublicKey(proto.Message): - r"""A [PublicKey][google.cloud.security.privateca.v1beta1.PublicKey] - describes a public key. - - Attributes: - type_ (google.cloud.security.privateca_v1beta1.types.PublicKey.KeyType): - Required. The type of public key. - key (bytes): - Required. A public key. Padding and encoding - varies by 'KeyType' and is described along with - the KeyType values. - """ - class KeyType(proto.Enum): - r"""Types of public keys that are supported. At a minimum, we support - RSA and ECDSA, for the key sizes or curves listed: - https://cloud.google.com/kms/docs/algorithms#asymmetric_signing_algorithms - """ - KEY_TYPE_UNSPECIFIED = 0 - PEM_RSA_KEY = 1 - PEM_EC_KEY = 2 - - type_ = proto.Field( - proto.ENUM, - number=1, - enum=KeyType, - ) - key = proto.Field( - proto.BYTES, - number=2, - ) - - -class CertificateConfig(proto.Message): - r"""A - [CertificateConfig][google.cloud.security.privateca.v1beta1.CertificateConfig] - describes an X.509 certificate or CSR that is to be created, as an - alternative to using ASN.1. - - Attributes: - subject_config (google.cloud.security.privateca_v1beta1.types.CertificateConfig.SubjectConfig): - Required. Specifies some of the values in a - certificate that are related to the subject. - reusable_config (google.cloud.security.privateca_v1beta1.types.ReusableConfigWrapper): - Required. Describes how some of the technical - fields in a certificate should be populated. - public_key (google.cloud.security.privateca_v1beta1.types.PublicKey): - Optional. The public key that corresponds to this config. - This is, for example, used when issuing - [Certificates][google.cloud.security.privateca.v1beta1.Certificate], - but not when creating a self-signed - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - or - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - CSR. - """ - - class SubjectConfig(proto.Message): - r"""These values are used to create the distinguished name and - subject alternative name fields in an X.509 certificate. - - Attributes: - subject (google.cloud.security.privateca_v1beta1.types.Subject): - Required. Contains distinguished name fields - such as the location and organization. - common_name (str): - Optional. The "common name" of the - distinguished name. - subject_alt_name (google.cloud.security.privateca_v1beta1.types.SubjectAltNames): - Optional. The subject alternative name - fields. - """ - - subject = proto.Field( - proto.MESSAGE, - number=1, - message='Subject', - ) - common_name = proto.Field( - proto.STRING, - number=2, - ) - subject_alt_name = proto.Field( - proto.MESSAGE, - number=3, - message='SubjectAltNames', - ) - - subject_config = proto.Field( - proto.MESSAGE, - number=1, - message=SubjectConfig, - ) - reusable_config = proto.Field( - proto.MESSAGE, - number=2, - message='ReusableConfigWrapper', - ) - public_key = proto.Field( - proto.MESSAGE, - number=3, - message='PublicKey', - ) - - -class CertificateDescription(proto.Message): - r"""A - [CertificateDescription][google.cloud.security.privateca.v1beta1.CertificateDescription] - describes an X.509 certificate or CSR that has been issued, as an - alternative to using ASN.1 / X.509. - - Attributes: - subject_description (google.cloud.security.privateca_v1beta1.types.CertificateDescription.SubjectDescription): - Describes some of the values in a certificate - that are related to the subject and lifetime. - config_values (google.cloud.security.privateca_v1beta1.types.ReusableConfigValues): - Describes some of the technical fields in a - certificate. - public_key (google.cloud.security.privateca_v1beta1.types.PublicKey): - The public key that corresponds to an issued - certificate. - subject_key_id (google.cloud.security.privateca_v1beta1.types.CertificateDescription.KeyId): - Provides a means of identifiying certificates - that contain a particular public key, per - https://tools.ietf.org/html/rfc5280#section-4.2.1.2. - authority_key_id (google.cloud.security.privateca_v1beta1.types.CertificateDescription.KeyId): - Identifies the subject_key_id of the parent certificate, per - https://tools.ietf.org/html/rfc5280#section-4.2.1.1 - crl_distribution_points (Sequence[str]): - Describes a list of locations to obtain CRL - information, i.e. the DistributionPoint.fullName - described by - https://tools.ietf.org/html/rfc5280#section-4.2.1.13 - aia_issuing_certificate_urls (Sequence[str]): - Describes lists of issuer CA certificate URLs - that appear in the "Authority Information - Access" extension in the certificate. - cert_fingerprint (google.cloud.security.privateca_v1beta1.types.CertificateDescription.CertificateFingerprint): - The hash of the x.509 certificate. - """ - - class SubjectDescription(proto.Message): - r"""These values describe fields in an issued X.509 certificate - such as the distinguished name, subject alternative names, - serial number, and lifetime. - - Attributes: - subject (google.cloud.security.privateca_v1beta1.types.Subject): - Contains distinguished name fields such as - the location and organization. - common_name (str): - The "common name" of the distinguished name. - subject_alt_name (google.cloud.security.privateca_v1beta1.types.SubjectAltNames): - The subject alternative name fields. - hex_serial_number (str): - The serial number encoded in lowercase - hexadecimal. - lifetime (google.protobuf.duration_pb2.Duration): - For convenience, the actual lifetime of an issued - certificate. Corresponds to 'not_after_time' - - 'not_before_time'. - not_before_time (google.protobuf.timestamp_pb2.Timestamp): - The time at which the certificate becomes - valid. - not_after_time (google.protobuf.timestamp_pb2.Timestamp): - The time at which the certificate expires. - """ - - subject = proto.Field( - proto.MESSAGE, - number=1, - message='Subject', - ) - common_name = proto.Field( - proto.STRING, - number=2, - ) - subject_alt_name = proto.Field( - proto.MESSAGE, - number=3, - message='SubjectAltNames', - ) - hex_serial_number = proto.Field( - proto.STRING, - number=4, - ) - lifetime = proto.Field( - proto.MESSAGE, - number=5, - message=duration_pb2.Duration, - ) - not_before_time = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - not_after_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - - class KeyId(proto.Message): - r"""A KeyId identifies a specific public key, usually by hashing - the public key. - - Attributes: - key_id (str): - Optional. The value of this KeyId encoded in - lowercase hexadecimal. This is most likely the - 160 bit SHA-1 hash of the public key. - """ - - key_id = proto.Field( - proto.STRING, - number=1, - ) - - class CertificateFingerprint(proto.Message): - r"""A group of fingerprints for the x509 certificate. - Attributes: - sha256_hash (str): - The SHA 256 hash, encoded in hexadecimal, of - the DER x509 certificate. - """ - - sha256_hash = proto.Field( - proto.STRING, - number=1, - ) - - subject_description = proto.Field( - proto.MESSAGE, - number=1, - message=SubjectDescription, - ) - config_values = proto.Field( - proto.MESSAGE, - number=2, - message='ReusableConfigValues', - ) - public_key = proto.Field( - proto.MESSAGE, - number=3, - message='PublicKey', - ) - subject_key_id = proto.Field( - proto.MESSAGE, - number=4, - message=KeyId, - ) - authority_key_id = proto.Field( - proto.MESSAGE, - number=5, - message=KeyId, - ) - crl_distribution_points = proto.RepeatedField( - proto.STRING, - number=6, - ) - aia_issuing_certificate_urls = proto.RepeatedField( - proto.STRING, - number=7, - ) - cert_fingerprint = proto.Field( - proto.MESSAGE, - number=8, - message=CertificateFingerprint, - ) - - -class ObjectId(proto.Message): - r"""An [ObjectId][google.cloud.security.privateca.v1beta1.ObjectId] - specifies an object identifier (OID). These provide context and - describe types in ASN.1 messages. - - Attributes: - object_id_path (Sequence[int]): - Required. The parts of an OID path. The most - significant parts of the path come first. - """ - - object_id_path = proto.RepeatedField( - proto.INT32, - number=1, - ) - - -class X509Extension(proto.Message): - r"""An - [X509Extension][google.cloud.security.privateca.v1beta1.X509Extension] - specifies an X.509 extension, which may be used in different parts - of X.509 objects like certificates, CSRs, and CRLs. - - Attributes: - object_id (google.cloud.security.privateca_v1beta1.types.ObjectId): - Required. The OID for this X.509 extension. - critical (bool): - Required. Indicates whether or not this - extension is critical (i.e., if the client does - not know how to handle this extension, the - client should consider this to be an error). - value (bytes): - Required. The value of this X.509 extension. - """ - - object_id = proto.Field( - proto.MESSAGE, - number=1, - message='ObjectId', - ) - critical = proto.Field( - proto.BOOL, - number=2, - ) - value = proto.Field( - proto.BYTES, - number=3, - ) - - -class KeyUsage(proto.Message): - r"""A [KeyUsage][google.cloud.security.privateca.v1beta1.KeyUsage] - describes key usage values that may appear in an X.509 certificate. - - Attributes: - base_key_usage (google.cloud.security.privateca_v1beta1.types.KeyUsage.KeyUsageOptions): - Describes high-level ways in which a key may - be used. - extended_key_usage (google.cloud.security.privateca_v1beta1.types.KeyUsage.ExtendedKeyUsageOptions): - Detailed scenarios in which a key may be - used. - unknown_extended_key_usages (Sequence[google.cloud.security.privateca_v1beta1.types.ObjectId]): - Used to describe extended key usages that are not listed in - the - [KeyUsage.ExtendedKeyUsageOptions][google.cloud.security.privateca.v1beta1.KeyUsage.ExtendedKeyUsageOptions] - message. - """ - - class KeyUsageOptions(proto.Message): - r"""[KeyUsage.KeyUsageOptions][google.cloud.security.privateca.v1beta1.KeyUsage.KeyUsageOptions] - corresponds to the key usage values described in - https://tools.ietf.org/html/rfc5280#section-4.2.1.3. - - Attributes: - digital_signature (bool): - The key may be used for digital signatures. - content_commitment (bool): - The key may be used for cryptographic - commitments. Note that this may also be referred - to as "non-repudiation". - key_encipherment (bool): - The key may be used to encipher other keys. - data_encipherment (bool): - The key may be used to encipher data. - key_agreement (bool): - The key may be used in a key agreement - protocol. - cert_sign (bool): - The key may be used to sign certificates. - crl_sign (bool): - The key may be used sign certificate - revocation lists. - encipher_only (bool): - The key may be used to encipher only. - decipher_only (bool): - The key may be used to decipher only. - """ - - digital_signature = proto.Field( - proto.BOOL, - number=1, - ) - content_commitment = proto.Field( - proto.BOOL, - number=2, - ) - key_encipherment = proto.Field( - proto.BOOL, - number=3, - ) - data_encipherment = proto.Field( - proto.BOOL, - number=4, - ) - key_agreement = proto.Field( - proto.BOOL, - number=5, - ) - cert_sign = proto.Field( - proto.BOOL, - number=6, - ) - crl_sign = proto.Field( - proto.BOOL, - number=7, - ) - encipher_only = proto.Field( - proto.BOOL, - number=8, - ) - decipher_only = proto.Field( - proto.BOOL, - number=9, - ) - - class ExtendedKeyUsageOptions(proto.Message): - r"""[KeyUsage.ExtendedKeyUsageOptions][google.cloud.security.privateca.v1beta1.KeyUsage.ExtendedKeyUsageOptions] - has fields that correspond to certain common OIDs that could be - specified as an extended key usage value. - - Attributes: - server_auth (bool): - Corresponds to OID 1.3.6.1.5.5.7.3.1. - Officially described as "TLS WWW server - authentication", though regularly used for non- - WWW TLS. - client_auth (bool): - Corresponds to OID 1.3.6.1.5.5.7.3.2. - Officially described as "TLS WWW client - authentication", though regularly used for non- - WWW TLS. - code_signing (bool): - Corresponds to OID 1.3.6.1.5.5.7.3.3. - Officially described as "Signing of downloadable - executable code client authentication". - email_protection (bool): - Corresponds to OID 1.3.6.1.5.5.7.3.4. - Officially described as "Email protection". - time_stamping (bool): - Corresponds to OID 1.3.6.1.5.5.7.3.8. - Officially described as "Binding the hash of an - object to a time". - ocsp_signing (bool): - Corresponds to OID 1.3.6.1.5.5.7.3.9. - Officially described as "Signing OCSP - responses". - """ - - server_auth = proto.Field( - proto.BOOL, - number=1, - ) - client_auth = proto.Field( - proto.BOOL, - number=2, - ) - code_signing = proto.Field( - proto.BOOL, - number=3, - ) - email_protection = proto.Field( - proto.BOOL, - number=4, - ) - time_stamping = proto.Field( - proto.BOOL, - number=5, - ) - ocsp_signing = proto.Field( - proto.BOOL, - number=6, - ) - - base_key_usage = proto.Field( - proto.MESSAGE, - number=1, - message=KeyUsageOptions, - ) - extended_key_usage = proto.Field( - proto.MESSAGE, - number=2, - message=ExtendedKeyUsageOptions, - ) - unknown_extended_key_usages = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='ObjectId', - ) - - -class Subject(proto.Message): - r"""[Subject][google.cloud.security.privateca.v1beta1.Subject] describes - parts of a distinguished name that, in turn, describes the subject - of the certificate. - - Attributes: - country_code (str): - The country code of the subject. - organization (str): - The organization of the subject. - organizational_unit (str): - The organizational_unit of the subject. - locality (str): - The locality or city of the subject. - province (str): - The province, territory, or regional state of - the subject. - street_address (str): - The street address of the subject. - postal_code (str): - The postal code of the subject. - """ - - country_code = proto.Field( - proto.STRING, - number=1, - ) - organization = proto.Field( - proto.STRING, - number=2, - ) - organizational_unit = proto.Field( - proto.STRING, - number=3, - ) - locality = proto.Field( - proto.STRING, - number=4, - ) - province = proto.Field( - proto.STRING, - number=5, - ) - street_address = proto.Field( - proto.STRING, - number=6, - ) - postal_code = proto.Field( - proto.STRING, - number=7, - ) - - -class SubjectAltNames(proto.Message): - r"""[SubjectAltNames][google.cloud.security.privateca.v1beta1.SubjectAltNames] - corresponds to a more modern way of listing what the asserted - identity is in a certificate (i.e., compared to the "common name" in - the distinguished name). - - Attributes: - dns_names (Sequence[str]): - Contains only valid, fully-qualified host - names. - uris (Sequence[str]): - Contains only valid RFC 3986 URIs. - email_addresses (Sequence[str]): - Contains only valid RFC 2822 E-mail - addresses. - ip_addresses (Sequence[str]): - Contains only valid 32-bit IPv4 addresses or - RFC 4291 IPv6 addresses. - custom_sans (Sequence[google.cloud.security.privateca_v1beta1.types.X509Extension]): - Contains additional subject alternative name - values. - """ - - dns_names = proto.RepeatedField( - proto.STRING, - number=1, - ) - uris = proto.RepeatedField( - proto.STRING, - number=2, - ) - email_addresses = proto.RepeatedField( - proto.STRING, - number=3, - ) - ip_addresses = proto.RepeatedField( - proto.STRING, - number=4, - ) - custom_sans = proto.RepeatedField( - proto.MESSAGE, - number=5, - message='X509Extension', - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/service.py b/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/service.py deleted file mode 100644 index d42d12d..0000000 --- a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/types/service.py +++ /dev/null @@ -1,1121 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import proto # type: ignore - -from google.cloud.security.privateca_v1beta1.types import resources -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.security.privateca.v1beta1', - manifest={ - 'CreateCertificateRequest', - 'GetCertificateRequest', - 'ListCertificatesRequest', - 'ListCertificatesResponse', - 'RevokeCertificateRequest', - 'UpdateCertificateRequest', - 'ActivateCertificateAuthorityRequest', - 'CreateCertificateAuthorityRequest', - 'DisableCertificateAuthorityRequest', - 'EnableCertificateAuthorityRequest', - 'FetchCertificateAuthorityCsrRequest', - 'FetchCertificateAuthorityCsrResponse', - 'GetCertificateAuthorityRequest', - 'ListCertificateAuthoritiesRequest', - 'ListCertificateAuthoritiesResponse', - 'RestoreCertificateAuthorityRequest', - 'ScheduleDeleteCertificateAuthorityRequest', - 'UpdateCertificateAuthorityRequest', - 'GetCertificateRevocationListRequest', - 'ListCertificateRevocationListsRequest', - 'ListCertificateRevocationListsResponse', - 'UpdateCertificateRevocationListRequest', - 'GetReusableConfigRequest', - 'ListReusableConfigsRequest', - 'ListReusableConfigsResponse', - 'OperationMetadata', - }, -) - - -class CreateCertificateRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.CreateCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.CreateCertificate]. - - Attributes: - parent (str): - Required. The resource name of the location and - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - associated with the - [Certificate][google.cloud.security.privateca.v1beta1.Certificate], - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - certificate_id (str): - Optional. It must be unique within a location and match the - regular expression ``[a-zA-Z0-9_-]{1,63}``. This field is - required when using a - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the Enterprise - [CertificateAuthority.Tier][google.cloud.security.privateca.v1beta1.CertificateAuthority.Tier], - but is optional and its value is ignored otherwise. - certificate (google.cloud.security.privateca_v1beta1.types.Certificate): - Required. A - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - with initial field values. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - certificate_id = proto.Field( - proto.STRING, - number=2, - ) - certificate = proto.Field( - proto.MESSAGE, - number=3, - message=resources.Certificate, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - - -class GetCertificateRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.GetCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificate]. - - Attributes: - name (str): - Required. The - [name][google.cloud.security.privateca.v1beta1.Certificate.name] - of the - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - to get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListCertificatesRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificates]. - - Attributes: - parent (str): - Required. The resource name of the location associated with - the - [Certificates][google.cloud.security.privateca.v1beta1.Certificate], - in the format - ``projects/*/locations/*/certificateauthorities/*``. - page_size (int): - Optional. Limit on the number of - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - to include in the response. Further - [Certificates][google.cloud.security.privateca.v1beta1.Certificate] - can subsequently be obtained by including the - [ListCertificatesResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListCertificatesResponse.next_page_token] - in a subsequent request. If unspecified, the server will - pick an appropriate default. - page_token (str): - Optional. Pagination token, returned earlier via - [ListCertificatesResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListCertificatesResponse.next_page_token]. - filter (str): - Optional. Only include resources that match the filter in - the response. For details on supported filters and syntax, - see `Certificates Filtering - documentation `__. - order_by (str): - Optional. Specify how the results should be sorted. For - details on supported fields and syntax, see `Certificates - Sorting - documentation `__. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCertificatesResponse(proto.Message): - r"""Response message for - [CertificateAuthorityService.ListCertificates][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificates]. - - Attributes: - certificates (Sequence[google.cloud.security.privateca_v1beta1.types.Certificate]): - The list of - [Certificates][google.cloud.security.privateca.v1beta1.Certificate]. - next_page_token (str): - A token to retrieve next page of results. Pass this value in - [ListCertificatesRequest.next_page_token][] to retrieve the - next page of results. - unreachable (Sequence[str]): - A list of locations (e.g. "us-west1") that - could not be reached. - """ - - @property - def raw_page(self): - return self - - certificates = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.Certificate, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class RevokeCertificateRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.RevokeCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.RevokeCertificate]. - - Attributes: - name (str): - Required. The resource name for this - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - in the format - ``projects/*/locations/*/certificateAuthorities/*/certificates/*``. - reason (google.cloud.security.privateca_v1beta1.types.RevocationReason): - Required. The - [RevocationReason][google.cloud.security.privateca.v1beta1.RevocationReason] - for revoking this certificate. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - reason = proto.Field( - proto.ENUM, - number=2, - enum=resources.RevocationReason, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - - -class UpdateCertificateRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.UpdateCertificate][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificate]. - - Attributes: - certificate (google.cloud.security.privateca_v1beta1.types.Certificate): - Required. - [Certificate][google.cloud.security.privateca.v1beta1.Certificate] - with updated values. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be updated in - this request. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - certificate = proto.Field( - proto.MESSAGE, - number=1, - message=resources.Certificate, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - - -class ActivateCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.ActivateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ActivateCertificateAuthority]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - pem_ca_certificate (str): - Required. The signed CA certificate issued from - [FetchCertificateAuthorityCsrResponse.pem_csr][google.cloud.security.privateca.v1beta1.FetchCertificateAuthorityCsrResponse.pem_csr]. - subordinate_config (google.cloud.security.privateca_v1beta1.types.SubordinateConfig): - Required. Must include information about the issuer of - 'pem_ca_certificate', and any further issuers until the - self-signed CA. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - pem_ca_certificate = proto.Field( - proto.STRING, - number=2, - ) - subordinate_config = proto.Field( - proto.MESSAGE, - number=3, - message=resources.SubordinateConfig, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - - -class CreateCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.CreateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.CreateCertificateAuthority]. - - Attributes: - parent (str): - Required. The resource name of the location associated with - the - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority], - in the format ``projects/*/locations/*``. - certificate_authority_id (str): - Required. It must be unique within a location and match the - regular expression ``[a-zA-Z0-9_-]{1,63}`` - certificate_authority (google.cloud.security.privateca_v1beta1.types.CertificateAuthority): - Required. A - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - with initial field values. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - certificate_authority_id = proto.Field( - proto.STRING, - number=2, - ) - certificate_authority = proto.Field( - proto.MESSAGE, - number=3, - message=resources.CertificateAuthority, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - - -class DisableCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.DisableCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.DisableCertificateAuthority]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class EnableCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.EnableCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.EnableCertificateAuthority]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class FetchCertificateAuthorityCsrRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class FetchCertificateAuthorityCsrResponse(proto.Message): - r"""Response message for - [CertificateAuthorityService.FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.FetchCertificateAuthorityCsr]. - - Attributes: - pem_csr (str): - Output only. The PEM-encoded signed - certificate signing request (CSR). - """ - - pem_csr = proto.Field( - proto.STRING, - number=1, - ) - - -class GetCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.GetCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificateAuthority]. - - Attributes: - name (str): - Required. The - [name][google.cloud.security.privateca.v1beta1.CertificateAuthority.name] - of the - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - to get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListCertificateAuthoritiesRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateAuthorities]. - - Attributes: - parent (str): - Required. The resource name of the location associated with - the - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority], - in the format ``projects/*/locations/*``. - page_size (int): - Optional. Limit on the number of - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority] - to include in the response. Further - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority] - can subsequently be obtained by including the - [ListCertificateAuthoritiesResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListCertificateAuthoritiesResponse.next_page_token] - in a subsequent request. If unspecified, the server will - pick an appropriate default. - page_token (str): - Optional. Pagination token, returned earlier via - [ListCertificateAuthoritiesResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListCertificateAuthoritiesResponse.next_page_token]. - filter (str): - Optional. Only include resources that match - the filter in the response. - order_by (str): - Optional. Specify how the results should be - sorted. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCertificateAuthoritiesResponse(proto.Message): - r"""Response message for - [CertificateAuthorityService.ListCertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateAuthorities]. - - Attributes: - certificate_authorities (Sequence[google.cloud.security.privateca_v1beta1.types.CertificateAuthority]): - The list of - [CertificateAuthorities][google.cloud.security.privateca.v1beta1.CertificateAuthority]. - next_page_token (str): - A token to retrieve next page of results. Pass this value in - [ListCertificateAuthoritiesRequest.next_page_token][] to - retrieve the next page of results. - unreachable (Sequence[str]): - A list of locations (e.g. "us-west1") that - could not be reached. - """ - - @property - def raw_page(self): - return self - - certificate_authorities = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.CertificateAuthority, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class RestoreCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.RestoreCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.RestoreCertificateAuthority]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class ScheduleDeleteCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.ScheduleDeleteCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ScheduleDeleteCertificateAuthority]. - - Attributes: - name (str): - Required. The resource name for this - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - in the format - ``projects/*/locations/*/certificateAuthorities/*``. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class UpdateCertificateAuthorityRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.UpdateCertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificateAuthority]. - - Attributes: - certificate_authority (google.cloud.security.privateca_v1beta1.types.CertificateAuthority): - Required. - [CertificateAuthority][google.cloud.security.privateca.v1beta1.CertificateAuthority] - with updated values. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be updated in - this request. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - certificate_authority = proto.Field( - proto.MESSAGE, - number=1, - message=resources.CertificateAuthority, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - - -class GetCertificateRevocationListRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.GetCertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetCertificateRevocationList]. - - Attributes: - name (str): - Required. The - [name][google.cloud.security.privateca.v1beta1.CertificateRevocationList.name] - of the - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] - to get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListCertificateRevocationListsRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateRevocationLists]. - - Attributes: - parent (str): - Required. The resource name of the location associated with - the - [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList], - in the format - ``projects/*/locations/*/certificateauthorities/*``. - page_size (int): - Optional. Limit on the number of - [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList] - to include in the response. Further - [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList] - can subsequently be obtained by including the - [ListCertificateRevocationListsResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListCertificateRevocationListsResponse.next_page_token] - in a subsequent request. If unspecified, the server will - pick an appropriate default. - page_token (str): - Optional. Pagination token, returned earlier via - [ListCertificateRevocationListsResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListCertificateRevocationListsResponse.next_page_token]. - filter (str): - Optional. Only include resources that match - the filter in the response. - order_by (str): - Optional. Specify how the results should be - sorted. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCertificateRevocationListsResponse(proto.Message): - r"""Response message for - [CertificateAuthorityService.ListCertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListCertificateRevocationLists]. - - Attributes: - certificate_revocation_lists (Sequence[google.cloud.security.privateca_v1beta1.types.CertificateRevocationList]): - The list of - [CertificateRevocationLists][google.cloud.security.privateca.v1beta1.CertificateRevocationList]. - next_page_token (str): - A token to retrieve next page of results. Pass this value in - [ListCertificateRevocationListsRequest.next_page_token][] to - retrieve the next page of results. - unreachable (Sequence[str]): - A list of locations (e.g. "us-west1") that - could not be reached. - """ - - @property - def raw_page(self): - return self - - certificate_revocation_lists = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.CertificateRevocationList, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class UpdateCertificateRevocationListRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.UpdateCertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.UpdateCertificateRevocationList]. - - Attributes: - certificate_revocation_list (google.cloud.security.privateca_v1beta1.types.CertificateRevocationList): - Required. - [CertificateRevocationList][google.cloud.security.privateca.v1beta1.CertificateRevocationList] - with updated values. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. A list of fields to be updated in - this request. - request_id (str): - Optional. An ID to identify requests. Specify - a unique request ID so that if you must retry - your request, the server will know to ignore the - request if it has already been completed. The - server will guarantee that for at least 60 - minutes since the first request. - - For example, consider a situation where you make - an initial request and t he request times out. - If you make the request again with the same - request ID, the server can check if original - operation with the same request ID was received, - and if so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - certificate_revocation_list = proto.Field( - proto.MESSAGE, - number=1, - message=resources.CertificateRevocationList, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - - -class GetReusableConfigRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.GetReusableConfig][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.GetReusableConfig]. - - Attributes: - name (str): - Required. The [name][ReusableConfigs.name] of the - [ReusableConfigs][] to get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListReusableConfigsRequest(proto.Message): - r"""Request message for - [CertificateAuthorityService.ListReusableConfigs][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListReusableConfigs]. - - Attributes: - parent (str): - Required. The resource name of the location associated with - the - [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig], - in the format ``projects/*/locations/*``. - page_size (int): - Optional. Limit on the number of - [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig] - to include in the response. Further - [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig] - can subsequently be obtained by including the - [ListReusableConfigsResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListReusableConfigsResponse.next_page_token] - in a subsequent request. If unspecified, the server will - pick an appropriate default. - page_token (str): - Optional. Pagination token, returned earlier via - [ListReusableConfigsResponse.next_page_token][google.cloud.security.privateca.v1beta1.ListReusableConfigsResponse.next_page_token]. - filter (str): - Optional. Only include resources that match - the filter in the response. - order_by (str): - Optional. Specify how the results should be - sorted. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListReusableConfigsResponse(proto.Message): - r"""Response message for - [CertificateAuthorityService.ListReusableConfigs][google.cloud.security.privateca.v1beta1.CertificateAuthorityService.ListReusableConfigs]. - - Attributes: - reusable_configs (Sequence[google.cloud.security.privateca_v1beta1.types.ReusableConfig]): - The list of - [ReusableConfigs][google.cloud.security.privateca.v1beta1.ReusableConfig]. - next_page_token (str): - A token to retrieve next page of results. Pass this value in - [ListReusableConfigsRequest.next_page_token][] to retrieve - the next page of results. - unreachable (Sequence[str]): - A list of locations (e.g. "us-west1") that - could not be reached. - """ - - @property - def raw_page(self): - return self - - reusable_configs = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.ReusableConfig, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class OperationMetadata(proto.Message): - r"""Represents the metadata of the long-running operation. - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - target (str): - Output only. Server-defined resource path for - the target of the operation. - verb (str): - Output only. Name of the verb executed by the - operation. - status_message (str): - Output only. Human-readable status of the - operation, if any. - requested_cancellation (bool): - Output only. Identifies whether the user has requested - cancellation of the operation. Operations that have - successfully been cancelled have [Operation.error][] value - with a [google.rpc.Status.code][google.rpc.Status.code] of - 1, corresponding to ``Code.CANCELLED``. - api_version (str): - Output only. API version used to start the - operation. - """ - - create_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - target = proto.Field( - proto.STRING, - number=3, - ) - verb = proto.Field( - proto.STRING, - number=4, - ) - status_message = proto.Field( - proto.STRING, - number=5, - ) - requested_cancellation = proto.Field( - proto.BOOL, - number=6, - ) - api_version = proto.Field( - proto.STRING, - number=7, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1beta1/mypy.ini b/owl-bot-staging/v1beta1/mypy.ini deleted file mode 100644 index 4505b48..0000000 --- a/owl-bot-staging/v1beta1/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.6 -namespace_packages = True diff --git a/owl-bot-staging/v1beta1/noxfile.py b/owl-bot-staging/v1beta1/noxfile.py deleted file mode 100644 index e0f659d..0000000 --- a/owl-bot-staging/v1beta1/noxfile.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") - - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", -] - -@nox.session(python=['3.6', '3.7', '3.8', '3.9']) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'asyncmock', 'pytest-asyncio') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/security/privateca_v1beta1/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python='3.7') -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=['3.6', '3.7']) -def mypy(session): - """Run the type checker.""" - session.install('mypy') - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python='3.6') -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx<3.0.0", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) diff --git a/owl-bot-staging/v1beta1/scripts/fixup_privateca_v1beta1_keywords.py b/owl-bot-staging/v1beta1/scripts/fixup_privateca_v1beta1_keywords.py deleted file mode 100644 index afc0c8d..0000000 --- a/owl-bot-staging/v1beta1/scripts/fixup_privateca_v1beta1_keywords.py +++ /dev/null @@ -1,195 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class privatecaCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'activate_certificate_authority': ('name', 'pem_ca_certificate', 'subordinate_config', 'request_id', ), - 'create_certificate': ('parent', 'certificate', 'certificate_id', 'request_id', ), - 'create_certificate_authority': ('parent', 'certificate_authority_id', 'certificate_authority', 'request_id', ), - 'disable_certificate_authority': ('name', 'request_id', ), - 'enable_certificate_authority': ('name', 'request_id', ), - 'fetch_certificate_authority_csr': ('name', ), - 'get_certificate': ('name', ), - 'get_certificate_authority': ('name', ), - 'get_certificate_revocation_list': ('name', ), - 'get_reusable_config': ('name', ), - 'list_certificate_authorities': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificate_revocation_lists': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_reusable_configs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'restore_certificate_authority': ('name', 'request_id', ), - 'revoke_certificate': ('name', 'reason', 'request_id', ), - 'schedule_delete_certificate_authority': ('name', 'request_id', ), - 'update_certificate': ('certificate', 'update_mask', 'request_id', ), - 'update_certificate_authority': ('certificate_authority', 'update_mask', 'request_id', ), - 'update_certificate_revocation_list': ('certificate_revocation_list', 'update_mask', 'request_id', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=privatecaCallTransformer(), -): - """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 privateca client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/v1beta1/setup.py b/owl-bot-staging/v1beta1/setup.py deleted file mode 100644 index 9796ba8..0000000 --- a/owl-bot-staging/v1beta1/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import io -import os -import setuptools # type: ignore - -version = '0.1.0' - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, 'README.rst') -with io.open(readme_filename, encoding='utf-8') as readme_file: - readme = readme_file.read() - -setuptools.setup( - name='google-cloud-security-privateca', - version=version, - long_description=readme, - packages=setuptools.PEP420PackageFinder.find(), - namespace_packages=('google', 'google.cloud', 'google.cloud.security'), - platforms='Posix; MacOS X; Windows', - include_package_data=True, - install_requires=( - 'google-api-core[grpc] >= 1.22.2, < 2.0.0dev', - 'libcst >= 0.2.5', - 'proto-plus >= 1.15.0', - 'packaging >= 14.3', ), - python_requires='>=3.6', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Topic :: Internet', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - zip_safe=False, -) diff --git a/owl-bot-staging/v1beta1/tests/__init__.py b/owl-bot-staging/v1beta1/tests/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta1/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1beta1/tests/unit/__init__.py b/owl-bot-staging/v1beta1/tests/unit/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta1/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py b/owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta1/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/__init__.py b/owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py b/owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py deleted file mode 100644 index a7cf7a2..0000000 --- a/owl-bot-staging/v1beta1/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py +++ /dev/null @@ -1,6611 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -import mock -import packaging.version - -import grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import CertificateAuthorityServiceAsyncClient -from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import CertificateAuthorityServiceClient -from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import pagers -from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import transports -from google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.base import _API_CORE_VERSION -from google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.base import _GOOGLE_AUTH_VERSION -from google.cloud.security.privateca_v1beta1.types import resources -from google.cloud.security.privateca_v1beta1.types import service -from google.longrunning import operations_pb2 -from google.oauth2 import service_account -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.protobuf import wrappers_pb2 # type: ignore -import google.auth - - -# TODO(busunkim): Once google-api-core >= 1.26.0 is required: -# - Delete all the api-core and auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - -requires_api_core_lt_1_26_0 = pytest.mark.skipif( - packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), - reason="This test requires google-api-core < 1.26.0", -) - -requires_api_core_gte_1_26_0 = pytest.mark.skipif( - packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), - reason="This test requires google-api-core >= 1.26.0", -) - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(None) is None - assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert CertificateAuthorityServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class", [ - CertificateAuthorityServiceClient, - CertificateAuthorityServiceAsyncClient, -]) -def test_certificate_authority_service_client_from_service_account_info(client_class): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == 'privateca.googleapis.com:443' - - -@pytest.mark.parametrize("client_class", [ - CertificateAuthorityServiceClient, - CertificateAuthorityServiceAsyncClient, -]) -def test_certificate_authority_service_client_from_service_account_file(client_class): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: - factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json") - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == 'privateca.googleapis.com:443' - - -def test_certificate_authority_service_client_get_transport_class(): - transport = CertificateAuthorityServiceClient.get_transport_class() - available_transports = [ - transports.CertificateAuthorityServiceGrpcTransport, - ] - assert transport in available_transports - - transport = CertificateAuthorityServiceClient.get_transport_class("grpc") - assert transport == transports.CertificateAuthorityServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc"), - (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(CertificateAuthorityServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceClient)) -@mock.patch.object(CertificateAuthorityServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceAsyncClient)) -def test_certificate_authority_service_client_client_options(client_class, transport_class, transport_name): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(CertificateAuthorityServiceClient, '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(CertificateAuthorityServiceClient, 'get_transport_class') as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - client = client_class() - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError): - client = client_class() - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc", "true"), - (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc", "false"), - (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(CertificateAuthorityServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceClient)) -@mock.patch.object(CertificateAuthorityServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CertificateAuthorityServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_certificate_authority_service_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc"), - (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_certificate_authority_service_client_client_options_scopes(client_class, transport_class, transport_name): - # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CertificateAuthorityServiceClient, transports.CertificateAuthorityServiceGrpcTransport, "grpc"), - (CertificateAuthorityServiceAsyncClient, transports.CertificateAuthorityServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_certificate_authority_service_client_client_options_credentials_file(client_class, transport_class, transport_name): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_certificate_authority_service_client_client_options_from_dict(): - with mock.patch('google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = CertificateAuthorityServiceClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) - - -def test_create_certificate(transport: str = 'grpc', request_type=service.CreateCertificateRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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 = resources.Certificate( - name='name_value', - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - pem_csr='pem_csr_value', - ) - 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] == service.CreateCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -def test_create_certificate_from_dict(): - test_create_certificate(request_type=dict) - - -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 = CertificateAuthorityServiceClient( - 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] == service.CreateCertificateRequest() - - -@pytest.mark.asyncio -async def test_create_certificate_async(transport: str = 'grpc_asyncio', request_type=service.CreateCertificateRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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(resources.Certificate( - name='name_value', - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - )) - 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] == service.CreateCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -@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 = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.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 = resources.Certificate() - 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 = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.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(resources.Certificate()) - 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 = CertificateAuthorityServiceClient( - 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 = resources.Certificate() - # 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=resources.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] - assert args[0].parent == 'parent_value' - assert args[0].certificate == resources.Certificate(name='name_value') - assert args[0].certificate_id == 'certificate_id_value' - - -def test_create_certificate_flattened_error(): - client = CertificateAuthorityServiceClient( - 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( - service.CreateCertificateRequest(), - parent='parent_value', - certificate=resources.Certificate(name='name_value'), - certificate_id='certificate_id_value', - ) - - -@pytest.mark.asyncio -async def test_create_certificate_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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 = resources.Certificate() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) - # 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=resources.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] - assert args[0].parent == 'parent_value' - assert args[0].certificate == resources.Certificate(name='name_value') - assert args[0].certificate_id == 'certificate_id_value' - - -@pytest.mark.asyncio -async def test_create_certificate_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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( - service.CreateCertificateRequest(), - parent='parent_value', - certificate=resources.Certificate(name='name_value'), - certificate_id='certificate_id_value', - ) - - -def test_get_certificate(transport: str = 'grpc', request_type=service.GetCertificateRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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 = resources.Certificate( - name='name_value', - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - pem_csr='pem_csr_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] == service.GetCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -def test_get_certificate_from_dict(): - test_get_certificate(request_type=dict) - - -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 = CertificateAuthorityServiceClient( - 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] == service.GetCertificateRequest() - - -@pytest.mark.asyncio -async def test_get_certificate_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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(resources.Certificate( - name='name_value', - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - )) - 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] == service.GetCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -@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 = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.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 = resources.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 = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.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(resources.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 = CertificateAuthorityServiceClient( - 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 = resources.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] - assert args[0].name == 'name_value' - - -def test_get_certificate_flattened_error(): - client = CertificateAuthorityServiceClient( - 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( - service.GetCertificateRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_certificate_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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 = resources.Certificate() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.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] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_certificate_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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( - service.GetCertificateRequest(), - name='name_value', - ) - - -def test_list_certificates(transport: str = 'grpc', request_type=service.ListCertificatesRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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 = service.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] == service.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_from_dict(): - test_list_certificates(request_type=dict) - - -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 = CertificateAuthorityServiceClient( - 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] == service.ListCertificatesRequest() - - -@pytest.mark.asyncio -async def test_list_certificates_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificatesRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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(service.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] == service.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 = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.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 = service.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 = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.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(service.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 = CertificateAuthorityServiceClient( - 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 = service.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] - assert args[0].parent == 'parent_value' - - -def test_list_certificates_flattened_error(): - client = CertificateAuthorityServiceClient( - 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( - service.ListCertificatesRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_certificates_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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 = service.ListCertificatesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.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] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_certificates_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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( - service.ListCertificatesRequest(), - parent='parent_value', - ) - - -def test_list_certificates_pager(): - client = CertificateAuthorityServiceClient( - 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: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - resources.Certificate(), - ], - next_page_token='abc', - ), - service.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - ], - next_page_token='ghi', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_certificates(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.Certificate) - for i in results) - -def test_list_certificates_pages(): - client = CertificateAuthorityServiceClient( - 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: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - resources.Certificate(), - ], - next_page_token='abc', - ), - service.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - ], - next_page_token='ghi', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.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 = CertificateAuthorityServiceAsyncClient( - 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 = ( - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - resources.Certificate(), - ], - next_page_token='abc', - ), - service.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - ], - next_page_token='ghi', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_certificates(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.Certificate) - for i in responses) - -@pytest.mark.asyncio -async def test_list_certificates_async_pages(): - client = CertificateAuthorityServiceAsyncClient( - 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 = ( - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - resources.Certificate(), - ], - next_page_token='abc', - ), - service.ListCertificatesResponse( - certificates=[], - next_page_token='def', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - ], - next_page_token='ghi', - ), - service.ListCertificatesResponse( - certificates=[ - resources.Certificate(), - resources.Certificate(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_certificates(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_revoke_certificate(transport: str = 'grpc', request_type=service.RevokeCertificateRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.revoke_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Certificate( - name='name_value', - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - pem_csr='pem_csr_value', - ) - response = client.revoke_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] == service.RevokeCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -def test_revoke_certificate_from_dict(): - test_revoke_certificate(request_type=dict) - - -def test_revoke_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 = CertificateAuthorityServiceClient( - 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.revoke_certificate), - '__call__') as call: - client.revoke_certificate() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.RevokeCertificateRequest() - - -@pytest.mark.asyncio -async def test_revoke_certificate_async(transport: str = 'grpc_asyncio', request_type=service.RevokeCertificateRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.revoke_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate( - name='name_value', - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - )) - response = await client.revoke_certificate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.RevokeCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -@pytest.mark.asyncio -async def test_revoke_certificate_async_from_dict(): - await test_revoke_certificate_async(request_type=dict) - - -def test_revoke_certificate_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.RevokeCertificateRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.revoke_certificate), - '__call__') as call: - call.return_value = resources.Certificate() - client.revoke_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_revoke_certificate_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.RevokeCertificateRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.revoke_certificate), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) - await client.revoke_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_revoke_certificate_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.revoke_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Certificate() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.revoke_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] - assert args[0].name == 'name_value' - - -def test_revoke_certificate_flattened_error(): - client = CertificateAuthorityServiceClient( - 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.revoke_certificate( - service.RevokeCertificateRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_revoke_certificate_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.revoke_certificate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Certificate() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.revoke_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] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_revoke_certificate_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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.revoke_certificate( - service.RevokeCertificateRequest(), - name='name_value', - ) - - -def test_update_certificate(transport: str = 'grpc', request_type=service.UpdateCertificateRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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 = resources.Certificate( - name='name_value', - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - pem_csr='pem_csr_value', - ) - 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] == service.UpdateCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -def test_update_certificate_from_dict(): - test_update_certificate(request_type=dict) - - -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 = CertificateAuthorityServiceClient( - 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] == service.UpdateCertificateRequest() - - -@pytest.mark.asyncio -async def test_update_certificate_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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(resources.Certificate( - name='name_value', - pem_certificate='pem_certificate_value', - pem_certificate_chain=['pem_certificate_chain_value'], - )) - 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] == service.UpdateCertificateRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == 'name_value' - assert response.pem_certificate == 'pem_certificate_value' - assert response.pem_certificate_chain == ['pem_certificate_chain_value'] - - -@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 = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateRequest() - - request.certificate.name = 'certificate.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 = resources.Certificate() - 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=certificate.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_certificate_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateRequest() - - request.certificate.name = 'certificate.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(resources.Certificate()) - 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=certificate.name/value', - ) in kw['metadata'] - - -def test_update_certificate_flattened(): - client = CertificateAuthorityServiceClient( - 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 = resources.Certificate() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_certificate( - certificate=resources.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] - assert args[0].certificate == resources.Certificate(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_certificate_flattened_error(): - client = CertificateAuthorityServiceClient( - 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( - service.UpdateCertificateRequest(), - certificate=resources.Certificate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_certificate_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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 = resources.Certificate() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Certificate()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_certificate( - certificate=resources.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] - assert args[0].certificate == resources.Certificate(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_certificate_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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( - service.UpdateCertificateRequest(), - certificate=resources.Certificate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_activate_certificate_authority(transport: str = 'grpc', request_type=service.ActivateCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.activate_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_activate_certificate_authority_from_dict(): - test_activate_certificate_authority(request_type=dict) - - -def test_activate_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - client.activate_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_activate_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.ActivateCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.activate_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_activate_certificate_authority_async_from_dict(): - await test_activate_certificate_authority_async(request_type=dict) - - -def test_activate_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ActivateCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.activate_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_activate_certificate_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ActivateCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.activate_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -def test_activate_certificate_authority_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.activate_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_activate_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.activate_certificate_authority( - service.ActivateCertificateAuthorityRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_activate_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.activate_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_activate_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.activate_certificate_authority( - service.ActivateCertificateAuthorityRequest(), - name='name_value', - ) - - -def test_create_certificate_authority(transport: str = 'grpc', request_type=service.CreateCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_certificate_authority_from_dict(): - test_create_certificate_authority(request_type=dict) - - -def test_create_certificate_authority_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 = CertificateAuthorityServiceClient( - 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_authority), - '__call__') as call: - client.create_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_create_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.CreateCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__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_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_certificate_authority_async_from_dict(): - await test_create_certificate_authority_async(request_type=dict) - - -def test_create_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateCertificateAuthorityRequest() - - 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_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_certificate_authority(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_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateCertificateAuthorityRequest() - - 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_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_certificate_authority(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_authority_flattened(): - client = CertificateAuthorityServiceClient( - 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_authority), - '__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_authority( - parent='parent_value', - certificate_authority=resources.CertificateAuthority(name='name_value'), - certificate_authority_id='certificate_authority_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') - assert args[0].certificate_authority_id == 'certificate_authority_id_value' - - -def test_create_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_authority( - service.CreateCertificateAuthorityRequest(), - parent='parent_value', - certificate_authority=resources.CertificateAuthority(name='name_value'), - certificate_authority_id='certificate_authority_id_value', - ) - - -@pytest.mark.asyncio -async def test_create_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority), - '__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_authority( - parent='parent_value', - certificate_authority=resources.CertificateAuthority(name='name_value'), - certificate_authority_id='certificate_authority_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') - assert args[0].certificate_authority_id == 'certificate_authority_id_value' - - -@pytest.mark.asyncio -async def test_create_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority( - service.CreateCertificateAuthorityRequest(), - parent='parent_value', - certificate_authority=resources.CertificateAuthority(name='name_value'), - certificate_authority_id='certificate_authority_id_value', - ) - - -def test_disable_certificate_authority(transport: str = 'grpc', request_type=service.DisableCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.disable_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.disable_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_disable_certificate_authority_from_dict(): - test_disable_certificate_authority(request_type=dict) - - -def test_disable_certificate_authority_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 = CertificateAuthorityServiceClient( - 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.disable_certificate_authority), - '__call__') as call: - client.disable_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_disable_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.DisableCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.disable_certificate_authority), - '__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.disable_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_disable_certificate_authority_async_from_dict(): - await test_disable_certificate_authority_async(request_type=dict) - - -def test_disable_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.DisableCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.disable_certificate_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.disable_certificate_authority(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_disable_certificate_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.DisableCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.disable_certificate_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.disable_certificate_authority(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_disable_certificate_authority_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.disable_certificate_authority), - '__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.disable_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_disable_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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.disable_certificate_authority( - service.DisableCertificateAuthorityRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_disable_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.disable_certificate_authority), - '__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.disable_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_disable_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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.disable_certificate_authority( - service.DisableCertificateAuthorityRequest(), - name='name_value', - ) - - -def test_enable_certificate_authority(transport: str = 'grpc', request_type=service.EnableCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.enable_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.enable_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_enable_certificate_authority_from_dict(): - test_enable_certificate_authority(request_type=dict) - - -def test_enable_certificate_authority_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 = CertificateAuthorityServiceClient( - 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.enable_certificate_authority), - '__call__') as call: - client.enable_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_enable_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.EnableCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.enable_certificate_authority), - '__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.enable_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_enable_certificate_authority_async_from_dict(): - await test_enable_certificate_authority_async(request_type=dict) - - -def test_enable_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.EnableCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.enable_certificate_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.enable_certificate_authority(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_enable_certificate_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.EnableCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.enable_certificate_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.enable_certificate_authority(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_enable_certificate_authority_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.enable_certificate_authority), - '__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.enable_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_enable_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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.enable_certificate_authority( - service.EnableCertificateAuthorityRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_enable_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.enable_certificate_authority), - '__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.enable_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_enable_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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.enable_certificate_authority( - service.EnableCertificateAuthorityRequest(), - name='name_value', - ) - - -def test_fetch_certificate_authority_csr(transport: str = 'grpc', request_type=service.FetchCertificateAuthorityCsrRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.fetch_certificate_authority_csr), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.FetchCertificateAuthorityCsrResponse( - pem_csr='pem_csr_value', - ) - response = client.fetch_certificate_authority_csr(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCertificateAuthorityCsrRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, service.FetchCertificateAuthorityCsrResponse) - assert response.pem_csr == 'pem_csr_value' - - -def test_fetch_certificate_authority_csr_from_dict(): - test_fetch_certificate_authority_csr(request_type=dict) - - -def test_fetch_certificate_authority_csr_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 = CertificateAuthorityServiceClient( - 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.fetch_certificate_authority_csr), - '__call__') as call: - client.fetch_certificate_authority_csr() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCertificateAuthorityCsrRequest() - - -@pytest.mark.asyncio -async def test_fetch_certificate_authority_csr_async(transport: str = 'grpc_asyncio', request_type=service.FetchCertificateAuthorityCsrRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.fetch_certificate_authority_csr), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCertificateAuthorityCsrResponse( - pem_csr='pem_csr_value', - )) - response = await client.fetch_certificate_authority_csr(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCertificateAuthorityCsrRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, service.FetchCertificateAuthorityCsrResponse) - assert response.pem_csr == 'pem_csr_value' - - -@pytest.mark.asyncio -async def test_fetch_certificate_authority_csr_async_from_dict(): - await test_fetch_certificate_authority_csr_async(request_type=dict) - - -def test_fetch_certificate_authority_csr_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.FetchCertificateAuthorityCsrRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_certificate_authority_csr), - '__call__') as call: - call.return_value = service.FetchCertificateAuthorityCsrResponse() - client.fetch_certificate_authority_csr(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_fetch_certificate_authority_csr_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.FetchCertificateAuthorityCsrRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_certificate_authority_csr), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCertificateAuthorityCsrResponse()) - await client.fetch_certificate_authority_csr(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_fetch_certificate_authority_csr_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_certificate_authority_csr), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.FetchCertificateAuthorityCsrResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.fetch_certificate_authority_csr( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_fetch_certificate_authority_csr_flattened_error(): - client = CertificateAuthorityServiceClient( - 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.fetch_certificate_authority_csr( - service.FetchCertificateAuthorityCsrRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_fetch_certificate_authority_csr_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_certificate_authority_csr), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.FetchCertificateAuthorityCsrResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.FetchCertificateAuthorityCsrResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.fetch_certificate_authority_csr( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_fetch_certificate_authority_csr_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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.fetch_certificate_authority_csr( - service.FetchCertificateAuthorityCsrRequest(), - name='name_value', - ) - - -def test_get_certificate_authority(transport: str = 'grpc', request_type=service.GetCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateAuthority( - name='name_value', - type_=resources.CertificateAuthority.Type.SELF_SIGNED, - tier=resources.CertificateAuthority.Tier.ENTERPRISE, - state=resources.CertificateAuthority.State.ENABLED, - pem_ca_certificates=['pem_ca_certificates_value'], - gcs_bucket='gcs_bucket_value', - ) - response = client.get_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateAuthority) - assert response.name == 'name_value' - assert response.type_ == resources.CertificateAuthority.Type.SELF_SIGNED - assert response.tier == resources.CertificateAuthority.Tier.ENTERPRISE - assert response.state == resources.CertificateAuthority.State.ENABLED - assert response.pem_ca_certificates == ['pem_ca_certificates_value'] - assert response.gcs_bucket == 'gcs_bucket_value' - - -def test_get_certificate_authority_from_dict(): - test_get_certificate_authority(request_type=dict) - - -def test_get_certificate_authority_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 = CertificateAuthorityServiceClient( - 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_authority), - '__call__') as call: - client.get_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_get_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateAuthority( - name='name_value', - type_=resources.CertificateAuthority.Type.SELF_SIGNED, - tier=resources.CertificateAuthority.Tier.ENTERPRISE, - state=resources.CertificateAuthority.State.ENABLED, - pem_ca_certificates=['pem_ca_certificates_value'], - gcs_bucket='gcs_bucket_value', - )) - response = await client.get_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateAuthority) - assert response.name == 'name_value' - assert response.type_ == resources.CertificateAuthority.Type.SELF_SIGNED - assert response.tier == resources.CertificateAuthority.Tier.ENTERPRISE - assert response.state == resources.CertificateAuthority.State.ENABLED - assert response.pem_ca_certificates == ['pem_ca_certificates_value'] - assert response.gcs_bucket == 'gcs_bucket_value' - - -@pytest.mark.asyncio -async def test_get_certificate_authority_async_from_dict(): - await test_get_certificate_authority_async(request_type=dict) - - -def test_get_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCertificateAuthorityRequest() - - 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_authority), - '__call__') as call: - call.return_value = resources.CertificateAuthority() - client.get_certificate_authority(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_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCertificateAuthorityRequest() - - 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_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateAuthority()) - await client.get_certificate_authority(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_authority_flattened(): - client = CertificateAuthorityServiceClient( - 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateAuthority() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_get_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_authority( - service.GetCertificateAuthorityRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateAuthority() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateAuthority()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority( - service.GetCertificateAuthorityRequest(), - name='name_value', - ) - - -def test_list_certificate_authorities(transport: str = 'grpc', request_type=service.ListCertificateAuthoritiesRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authorities), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateAuthoritiesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_certificate_authorities(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateAuthoritiesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateAuthoritiesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificate_authorities_from_dict(): - test_list_certificate_authorities(request_type=dict) - - -def test_list_certificate_authorities_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 = CertificateAuthorityServiceClient( - 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_authorities), - '__call__') as call: - client.list_certificate_authorities() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateAuthoritiesRequest() - - -@pytest.mark.asyncio -async def test_list_certificate_authorities_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificateAuthoritiesRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authorities), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateAuthoritiesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_certificate_authorities(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateAuthoritiesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateAuthoritiesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_certificate_authorities_async_from_dict(): - await test_list_certificate_authorities_async(request_type=dict) - - -def test_list_certificate_authorities_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCertificateAuthoritiesRequest() - - 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_authorities), - '__call__') as call: - call.return_value = service.ListCertificateAuthoritiesResponse() - client.list_certificate_authorities(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_authorities_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCertificateAuthoritiesRequest() - - 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_authorities), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateAuthoritiesResponse()) - await client.list_certificate_authorities(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_authorities_flattened(): - client = CertificateAuthorityServiceClient( - 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_authorities), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateAuthoritiesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_certificate_authorities( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -def test_list_certificate_authorities_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_authorities( - service.ListCertificateAuthoritiesRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_certificate_authorities_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authorities), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateAuthoritiesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateAuthoritiesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_certificate_authorities( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_certificate_authorities_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authorities( - service.ListCertificateAuthoritiesRequest(), - parent='parent_value', - ) - - -def test_list_certificate_authorities_pager(): - client = CertificateAuthorityServiceClient( - 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_authorities), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - next_page_token='abc', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[], - next_page_token='def', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - ], - next_page_token='ghi', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_certificate_authorities(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.CertificateAuthority) - for i in results) - -def test_list_certificate_authorities_pages(): - client = CertificateAuthorityServiceClient( - 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_authorities), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - next_page_token='abc', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[], - next_page_token='def', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - ], - next_page_token='ghi', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - ), - RuntimeError, - ) - pages = list(client.list_certificate_authorities(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_authorities_async_pager(): - client = CertificateAuthorityServiceAsyncClient( - 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_authorities), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - next_page_token='abc', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[], - next_page_token='def', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - ], - next_page_token='ghi', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_certificate_authorities(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.CertificateAuthority) - for i in responses) - -@pytest.mark.asyncio -async def test_list_certificate_authorities_async_pages(): - client = CertificateAuthorityServiceAsyncClient( - 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_authorities), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - next_page_token='abc', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[], - next_page_token='def', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - ], - next_page_token='ghi', - ), - service.ListCertificateAuthoritiesResponse( - certificate_authorities=[ - resources.CertificateAuthority(), - resources.CertificateAuthority(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_certificate_authorities(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_restore_certificate_authority(transport: str = 'grpc', request_type=service.RestoreCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.restore_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.restore_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.RestoreCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_restore_certificate_authority_from_dict(): - test_restore_certificate_authority(request_type=dict) - - -def test_restore_certificate_authority_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 = CertificateAuthorityServiceClient( - 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.restore_certificate_authority), - '__call__') as call: - client.restore_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.RestoreCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_restore_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.RestoreCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.restore_certificate_authority), - '__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.restore_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.RestoreCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_restore_certificate_authority_async_from_dict(): - await test_restore_certificate_authority_async(request_type=dict) - - -def test_restore_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.RestoreCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.restore_certificate_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.restore_certificate_authority(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_restore_certificate_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.RestoreCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.restore_certificate_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.restore_certificate_authority(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_restore_certificate_authority_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.restore_certificate_authority), - '__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.restore_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_restore_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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.restore_certificate_authority( - service.RestoreCertificateAuthorityRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_restore_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.restore_certificate_authority), - '__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.restore_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_restore_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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.restore_certificate_authority( - service.RestoreCertificateAuthorityRequest(), - name='name_value', - ) - - -def test_schedule_delete_certificate_authority(transport: str = 'grpc', request_type=service.ScheduleDeleteCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.schedule_delete_certificate_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.schedule_delete_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.ScheduleDeleteCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_schedule_delete_certificate_authority_from_dict(): - test_schedule_delete_certificate_authority(request_type=dict) - - -def test_schedule_delete_certificate_authority_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 = CertificateAuthorityServiceClient( - 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.schedule_delete_certificate_authority), - '__call__') as call: - client.schedule_delete_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ScheduleDeleteCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_schedule_delete_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.ScheduleDeleteCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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.schedule_delete_certificate_authority), - '__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.schedule_delete_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ScheduleDeleteCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_schedule_delete_certificate_authority_async_from_dict(): - await test_schedule_delete_certificate_authority_async(request_type=dict) - - -def test_schedule_delete_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ScheduleDeleteCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.schedule_delete_certificate_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.schedule_delete_certificate_authority(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_schedule_delete_certificate_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ScheduleDeleteCertificateAuthorityRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.schedule_delete_certificate_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.schedule_delete_certificate_authority(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_schedule_delete_certificate_authority_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.schedule_delete_certificate_authority), - '__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.schedule_delete_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_schedule_delete_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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.schedule_delete_certificate_authority( - service.ScheduleDeleteCertificateAuthorityRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_schedule_delete_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.schedule_delete_certificate_authority), - '__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.schedule_delete_certificate_authority( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_schedule_delete_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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.schedule_delete_certificate_authority( - service.ScheduleDeleteCertificateAuthorityRequest(), - name='name_value', - ) - - -def test_update_certificate_authority(transport: str = 'grpc', request_type=service.UpdateCertificateAuthorityRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_certificate_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_certificate_authority_from_dict(): - test_update_certificate_authority(request_type=dict) - - -def test_update_certificate_authority_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 = CertificateAuthorityServiceClient( - 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_authority), - '__call__') as call: - client.update_certificate_authority() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateAuthorityRequest() - - -@pytest.mark.asyncio -async def test_update_certificate_authority_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateAuthorityRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_authority), - '__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_authority(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateAuthorityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_certificate_authority_async_from_dict(): - await test_update_certificate_authority_async(request_type=dict) - - -def test_update_certificate_authority_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateAuthorityRequest() - - request.certificate_authority.name = 'certificate_authority.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_authority), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_certificate_authority(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_authority.name=certificate_authority.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_certificate_authority_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateAuthorityRequest() - - request.certificate_authority.name = 'certificate_authority.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_authority), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_certificate_authority(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_authority.name=certificate_authority.name/value', - ) in kw['metadata'] - - -def test_update_certificate_authority_flattened(): - client = CertificateAuthorityServiceClient( - 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_authority), - '__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_authority( - certificate_authority=resources.CertificateAuthority(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_certificate_authority_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_authority( - service.UpdateCertificateAuthorityRequest(), - certificate_authority=resources.CertificateAuthority(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_certificate_authority_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority), - '__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_authority( - certificate_authority=resources.CertificateAuthority(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].certificate_authority == resources.CertificateAuthority(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_certificate_authority_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_authority( - service.UpdateCertificateAuthorityRequest(), - certificate_authority=resources.CertificateAuthority(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_get_certificate_revocation_list(transport: str = 'grpc', request_type=service.GetCertificateRevocationListRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_revocation_list), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateRevocationList( - name='name_value', - sequence_number=1601, - pem_crl='pem_crl_value', - access_url='access_url_value', - state=resources.CertificateRevocationList.State.ACTIVE, - ) - response = client.get_certificate_revocation_list(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRevocationListRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateRevocationList) - assert response.name == 'name_value' - assert response.sequence_number == 1601 - assert response.pem_crl == 'pem_crl_value' - assert response.access_url == 'access_url_value' - assert response.state == resources.CertificateRevocationList.State.ACTIVE - - -def test_get_certificate_revocation_list_from_dict(): - test_get_certificate_revocation_list(request_type=dict) - - -def test_get_certificate_revocation_list_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 = CertificateAuthorityServiceClient( - 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_revocation_list), - '__call__') as call: - client.get_certificate_revocation_list() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRevocationListRequest() - - -@pytest.mark.asyncio -async def test_get_certificate_revocation_list_async(transport: str = 'grpc_asyncio', request_type=service.GetCertificateRevocationListRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_revocation_list), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateRevocationList( - name='name_value', - sequence_number=1601, - pem_crl='pem_crl_value', - access_url='access_url_value', - state=resources.CertificateRevocationList.State.ACTIVE, - )) - response = await client.get_certificate_revocation_list(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRevocationListRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateRevocationList) - assert response.name == 'name_value' - assert response.sequence_number == 1601 - assert response.pem_crl == 'pem_crl_value' - assert response.access_url == 'access_url_value' - assert response.state == resources.CertificateRevocationList.State.ACTIVE - - -@pytest.mark.asyncio -async def test_get_certificate_revocation_list_async_from_dict(): - await test_get_certificate_revocation_list_async(request_type=dict) - - -def test_get_certificate_revocation_list_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCertificateRevocationListRequest() - - 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_revocation_list), - '__call__') as call: - call.return_value = resources.CertificateRevocationList() - client.get_certificate_revocation_list(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_revocation_list_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCertificateRevocationListRequest() - - 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_revocation_list), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateRevocationList()) - await client.get_certificate_revocation_list(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_revocation_list_flattened(): - client = CertificateAuthorityServiceClient( - 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_revocation_list), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateRevocationList() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_certificate_revocation_list( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_get_certificate_revocation_list_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_revocation_list( - service.GetCertificateRevocationListRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_certificate_revocation_list_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_list), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.CertificateRevocationList() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CertificateRevocationList()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_certificate_revocation_list( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_certificate_revocation_list_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_list( - service.GetCertificateRevocationListRequest(), - name='name_value', - ) - - -def test_list_certificate_revocation_lists(transport: str = 'grpc', request_type=service.ListCertificateRevocationListsRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_revocation_lists), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateRevocationListsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_certificate_revocation_lists(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateRevocationListsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateRevocationListsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_certificate_revocation_lists_from_dict(): - test_list_certificate_revocation_lists(request_type=dict) - - -def test_list_certificate_revocation_lists_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 = CertificateAuthorityServiceClient( - 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_revocation_lists), - '__call__') as call: - client.list_certificate_revocation_lists() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateRevocationListsRequest() - - -@pytest.mark.asyncio -async def test_list_certificate_revocation_lists_async(transport: str = 'grpc_asyncio', request_type=service.ListCertificateRevocationListsRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_revocation_lists), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateRevocationListsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_certificate_revocation_lists(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateRevocationListsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateRevocationListsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_certificate_revocation_lists_async_from_dict(): - await test_list_certificate_revocation_lists_async(request_type=dict) - - -def test_list_certificate_revocation_lists_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCertificateRevocationListsRequest() - - 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_revocation_lists), - '__call__') as call: - call.return_value = service.ListCertificateRevocationListsResponse() - client.list_certificate_revocation_lists(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_revocation_lists_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCertificateRevocationListsRequest() - - 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_revocation_lists), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateRevocationListsResponse()) - await client.list_certificate_revocation_lists(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_revocation_lists_flattened(): - client = CertificateAuthorityServiceClient( - 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_revocation_lists), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateRevocationListsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_certificate_revocation_lists( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -def test_list_certificate_revocation_lists_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_revocation_lists( - service.ListCertificateRevocationListsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_certificate_revocation_lists_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_lists), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCertificateRevocationListsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCertificateRevocationListsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_certificate_revocation_lists( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_certificate_revocation_lists_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_lists( - service.ListCertificateRevocationListsRequest(), - parent='parent_value', - ) - - -def test_list_certificate_revocation_lists_pager(): - client = CertificateAuthorityServiceClient( - 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_revocation_lists), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - next_page_token='abc', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[], - next_page_token='def', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - ], - next_page_token='ghi', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_certificate_revocation_lists(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.CertificateRevocationList) - for i in results) - -def test_list_certificate_revocation_lists_pages(): - client = CertificateAuthorityServiceClient( - 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_revocation_lists), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - next_page_token='abc', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[], - next_page_token='def', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - ], - next_page_token='ghi', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - ), - RuntimeError, - ) - pages = list(client.list_certificate_revocation_lists(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_revocation_lists_async_pager(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_lists), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - next_page_token='abc', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[], - next_page_token='def', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - ], - next_page_token='ghi', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_certificate_revocation_lists(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.CertificateRevocationList) - for i in responses) - -@pytest.mark.asyncio -async def test_list_certificate_revocation_lists_async_pages(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_lists), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - next_page_token='abc', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[], - next_page_token='def', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - ], - next_page_token='ghi', - ), - service.ListCertificateRevocationListsResponse( - certificate_revocation_lists=[ - resources.CertificateRevocationList(), - resources.CertificateRevocationList(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_certificate_revocation_lists(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_update_certificate_revocation_list(transport: str = 'grpc', request_type=service.UpdateCertificateRevocationListRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_revocation_list), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_certificate_revocation_list(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRevocationListRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_certificate_revocation_list_from_dict(): - test_update_certificate_revocation_list(request_type=dict) - - -def test_update_certificate_revocation_list_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 = CertificateAuthorityServiceClient( - 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_revocation_list), - '__call__') as call: - client.update_certificate_revocation_list() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRevocationListRequest() - - -@pytest.mark.asyncio -async def test_update_certificate_revocation_list_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCertificateRevocationListRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_revocation_list), - '__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_revocation_list(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRevocationListRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_certificate_revocation_list_async_from_dict(): - await test_update_certificate_revocation_list_async(request_type=dict) - - -def test_update_certificate_revocation_list_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateRevocationListRequest() - - request.certificate_revocation_list.name = 'certificate_revocation_list.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_revocation_list), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_certificate_revocation_list(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_revocation_list.name=certificate_revocation_list.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_certificate_revocation_list_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCertificateRevocationListRequest() - - request.certificate_revocation_list.name = 'certificate_revocation_list.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_certificate_revocation_list), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_certificate_revocation_list(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_revocation_list.name=certificate_revocation_list.name/value', - ) in kw['metadata'] - - -def test_update_certificate_revocation_list_flattened(): - client = CertificateAuthorityServiceClient( - 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_revocation_list), - '__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_revocation_list( - certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].certificate_revocation_list == resources.CertificateRevocationList(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_certificate_revocation_list_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_revocation_list( - service.UpdateCertificateRevocationListRequest(), - certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_certificate_revocation_list_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_list), - '__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_revocation_list( - certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].certificate_revocation_list == resources.CertificateRevocationList(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_certificate_revocation_list_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_revocation_list( - service.UpdateCertificateRevocationListRequest(), - certificate_revocation_list=resources.CertificateRevocationList(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_get_reusable_config(transport: str = 'grpc', request_type=service.GetReusableConfigRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_reusable_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.ReusableConfig( - name='name_value', - description='description_value', - ) - response = client.get_reusable_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] == service.GetReusableConfigRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.ReusableConfig) - assert response.name == 'name_value' - assert response.description == 'description_value' - - -def test_get_reusable_config_from_dict(): - test_get_reusable_config(request_type=dict) - - -def test_get_reusable_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 = CertificateAuthorityServiceClient( - 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_reusable_config), - '__call__') as call: - client.get_reusable_config() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetReusableConfigRequest() - - -@pytest.mark.asyncio -async def test_get_reusable_config_async(transport: str = 'grpc_asyncio', request_type=service.GetReusableConfigRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_reusable_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.ReusableConfig( - name='name_value', - description='description_value', - )) - response = await client.get_reusable_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetReusableConfigRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.ReusableConfig) - assert response.name == 'name_value' - assert response.description == 'description_value' - - -@pytest.mark.asyncio -async def test_get_reusable_config_async_from_dict(): - await test_get_reusable_config_async(request_type=dict) - - -def test_get_reusable_config_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetReusableConfigRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_reusable_config), - '__call__') as call: - call.return_value = resources.ReusableConfig() - client.get_reusable_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_reusable_config_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetReusableConfigRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_reusable_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.ReusableConfig()) - await client.get_reusable_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_reusable_config_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_reusable_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.ReusableConfig() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_reusable_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] - assert args[0].name == 'name_value' - - -def test_get_reusable_config_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_reusable_config( - service.GetReusableConfigRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_reusable_config_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_reusable_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.ReusableConfig() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.ReusableConfig()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_reusable_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] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_reusable_config_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_reusable_config( - service.GetReusableConfigRequest(), - name='name_value', - ) - - -def test_list_reusable_configs(transport: str = 'grpc', request_type=service.ListReusableConfigsRequest): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_reusable_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListReusableConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_reusable_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] == service.ListReusableConfigsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListReusableConfigsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_reusable_configs_from_dict(): - test_list_reusable_configs(request_type=dict) - - -def test_list_reusable_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 = CertificateAuthorityServiceClient( - 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_reusable_configs), - '__call__') as call: - client.list_reusable_configs() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListReusableConfigsRequest() - - -@pytest.mark.asyncio -async def test_list_reusable_configs_async(transport: str = 'grpc_asyncio', request_type=service.ListReusableConfigsRequest): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional 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_reusable_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListReusableConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_reusable_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListReusableConfigsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListReusableConfigsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_reusable_configs_async_from_dict(): - await test_list_reusable_configs_async(request_type=dict) - - -def test_list_reusable_configs_field_headers(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListReusableConfigsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_reusable_configs), - '__call__') as call: - call.return_value = service.ListReusableConfigsResponse() - client.list_reusable_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_reusable_configs_field_headers_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListReusableConfigsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_reusable_configs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListReusableConfigsResponse()) - await client.list_reusable_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_reusable_configs_flattened(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_reusable_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListReusableConfigsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_reusable_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] - assert args[0].parent == 'parent_value' - - -def test_list_reusable_configs_flattened_error(): - client = CertificateAuthorityServiceClient( - 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_reusable_configs( - service.ListReusableConfigsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_reusable_configs_flattened_async(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_reusable_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListReusableConfigsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListReusableConfigsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_reusable_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] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_reusable_configs_flattened_error_async(): - client = CertificateAuthorityServiceAsyncClient( - 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_reusable_configs( - service.ListReusableConfigsRequest(), - parent='parent_value', - ) - - -def test_list_reusable_configs_pager(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_reusable_configs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListReusableConfigsResponse( - reusable_configs=[ - resources.ReusableConfig(), - resources.ReusableConfig(), - resources.ReusableConfig(), - ], - next_page_token='abc', - ), - service.ListReusableConfigsResponse( - reusable_configs=[], - next_page_token='def', - ), - service.ListReusableConfigsResponse( - reusable_configs=[ - resources.ReusableConfig(), - ], - next_page_token='ghi', - ), - service.ListReusableConfigsResponse( - reusable_configs=[ - resources.ReusableConfig(), - resources.ReusableConfig(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_reusable_configs(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, resources.ReusableConfig) - for i in results) - -def test_list_reusable_configs_pages(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_reusable_configs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListReusableConfigsResponse( - reusable_configs=[ - resources.ReusableConfig(), - resources.ReusableConfig(), - resources.ReusableConfig(), - ], - next_page_token='abc', - ), - service.ListReusableConfigsResponse( - reusable_configs=[], - next_page_token='def', - ), - service.ListReusableConfigsResponse( - reusable_configs=[ - resources.ReusableConfig(), - ], - next_page_token='ghi', - ), - service.ListReusableConfigsResponse( - reusable_configs=[ - resources.ReusableConfig(), - resources.ReusableConfig(), - ], - ), - RuntimeError, - ) - pages = list(client.list_reusable_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_reusable_configs_async_pager(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_reusable_configs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListReusableConfigsResponse( - reusable_configs=[ - resources.ReusableConfig(), - resources.ReusableConfig(), - resources.ReusableConfig(), - ], - next_page_token='abc', - ), - service.ListReusableConfigsResponse( - reusable_configs=[], - next_page_token='def', - ), - service.ListReusableConfigsResponse( - reusable_configs=[ - resources.ReusableConfig(), - ], - next_page_token='ghi', - ), - service.ListReusableConfigsResponse( - reusable_configs=[ - resources.ReusableConfig(), - resources.ReusableConfig(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_reusable_configs(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.ReusableConfig) - for i in responses) - -@pytest.mark.asyncio -async def test_list_reusable_configs_async_pages(): - client = CertificateAuthorityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_reusable_configs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListReusableConfigsResponse( - reusable_configs=[ - resources.ReusableConfig(), - resources.ReusableConfig(), - resources.ReusableConfig(), - ], - next_page_token='abc', - ), - service.ListReusableConfigsResponse( - reusable_configs=[], - next_page_token='def', - ), - service.ListReusableConfigsResponse( - reusable_configs=[ - resources.ReusableConfig(), - ], - next_page_token='ghi', - ), - service.ListReusableConfigsResponse( - reusable_configs=[ - resources.ReusableConfig(), - resources.ReusableConfig(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_reusable_configs(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CertificateAuthorityServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CertificateAuthorityServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = CertificateAuthorityServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.CertificateAuthorityServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.CertificateAuthorityServiceGrpcTransport, - transports.CertificateAuthorityServiceGrpcAsyncIOTransport, -]) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.CertificateAuthorityServiceGrpcTransport, - ) - -def test_certificate_authority_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.CertificateAuthorityServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_certificate_authority_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.CertificateAuthorityServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'create_certificate', - 'get_certificate', - 'list_certificates', - 'revoke_certificate', - 'update_certificate', - 'activate_certificate_authority', - 'create_certificate_authority', - 'disable_certificate_authority', - 'enable_certificate_authority', - 'fetch_certificate_authority_csr', - 'get_certificate_authority', - 'list_certificate_authorities', - 'restore_certificate_authority', - 'schedule_delete_certificate_authority', - 'update_certificate_authority', - 'get_certificate_revocation_list', - 'list_certificate_revocation_lists', - 'update_certificate_revocation_list', - 'get_reusable_config', - 'list_reusable_configs', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - -@requires_google_auth_gte_1_25_0 -def test_certificate_authority_service_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file - with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CertificateAuthorityServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id="octopus", - ) - - -@requires_google_auth_lt_1_25_0 -def test_certificate_authority_service_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CertificateAuthorityServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), - quota_project_id="octopus", - ) - - -def test_certificate_authority_service_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CertificateAuthorityServiceTransport() - adc.assert_called_once() - - -@requires_google_auth_gte_1_25_0 -def test_certificate_authority_service_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - CertificateAuthorityServiceClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id=None, - ) - - -@requires_google_auth_lt_1_25_0 -def test_certificate_authority_service_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - CertificateAuthorityServiceClient() - adc.assert_called_once_with( - scopes=( 'https://www.googleapis.com/auth/cloud-platform',), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.CertificateAuthorityServiceGrpcTransport, - transports.CertificateAuthorityServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_gte_1_25_0 -def test_certificate_authority_service_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.CertificateAuthorityServiceGrpcTransport, - transports.CertificateAuthorityServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_certificate_authority_service_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with(scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), - (transports.CertificateAuthorityServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -@requires_api_core_gte_1_26_0 -def test_certificate_authority_service_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) - - create_channel.assert_called_with( - "privateca.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="privateca.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), - (transports.CertificateAuthorityServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -@requires_api_core_lt_1_26_0 -def test_certificate_authority_service_transport_create_channel_old_api_core(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") - - create_channel.assert_called_with( - "privateca.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), - (transports.CertificateAuthorityServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -@requires_api_core_lt_1_26_0 -def test_certificate_authority_service_transport_create_channel_user_scopes(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( - "privateca.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - scopes=["1", "2"], - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.CertificateAuthorityServiceGrpcTransport, transports.CertificateAuthorityServiceGrpcAsyncIOTransport]) -def test_certificate_authority_service_grpc_transport_client_cert_source_for_mtls( - transport_class -): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), - 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_authority_service_host_no_port(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='privateca.googleapis.com'), - ) - assert client.transport._host == 'privateca.googleapis.com:443' - - -def test_certificate_authority_service_host_with_port(): - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='privateca.googleapis.com:8000'), - ) - assert client.transport._host == 'privateca.googleapis.com:8000' - -def test_certificate_authority_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CertificateAuthorityServiceGrpcTransport( - 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_authority_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CertificateAuthorityServiceGrpcAsyncIOTransport( - 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.CertificateAuthorityServiceGrpcTransport, transports.CertificateAuthorityServiceGrpcAsyncIOTransport]) -def test_certificate_authority_service_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), - 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.CertificateAuthorityServiceGrpcTransport, transports.CertificateAuthorityServiceGrpcAsyncIOTransport]) -def test_certificate_authority_service_transport_channel_mtls_with_adc( - transport_class -): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - ), - 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_authority_service_grpc_lro_client(): - client = CertificateAuthorityServiceClient( - 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_authority_service_grpc_lro_async_client(): - client = CertificateAuthorityServiceAsyncClient( - 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_certificate_path(): - project = "squid" - location = "clam" - certificate_authority = "whelk" - certificate = "octopus" - expected = "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}/certificates/{certificate}".format(project=project, location=location, certificate_authority=certificate_authority, certificate=certificate, ) - actual = CertificateAuthorityServiceClient.certificate_path(project, location, certificate_authority, certificate) - assert expected == actual - - -def test_parse_certificate_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - "certificate_authority": "cuttlefish", - "certificate": "mussel", - } - path = CertificateAuthorityServiceClient.certificate_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_certificate_path(path) - assert expected == actual - -def test_certificate_authority_path(): - project = "winkle" - location = "nautilus" - certificate_authority = "scallop" - expected = "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}".format(project=project, location=location, certificate_authority=certificate_authority, ) - actual = CertificateAuthorityServiceClient.certificate_authority_path(project, location, certificate_authority) - assert expected == actual - - -def test_parse_certificate_authority_path(): - expected = { - "project": "abalone", - "location": "squid", - "certificate_authority": "clam", - } - path = CertificateAuthorityServiceClient.certificate_authority_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_certificate_authority_path(path) - assert expected == actual - -def test_certificate_revocation_list_path(): - project = "whelk" - location = "octopus" - certificate_authority = "oyster" - certificate_revocation_list = "nudibranch" - expected = "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list}".format(project=project, location=location, certificate_authority=certificate_authority, certificate_revocation_list=certificate_revocation_list, ) - actual = CertificateAuthorityServiceClient.certificate_revocation_list_path(project, location, certificate_authority, certificate_revocation_list) - assert expected == actual - - -def test_parse_certificate_revocation_list_path(): - expected = { - "project": "cuttlefish", - "location": "mussel", - "certificate_authority": "winkle", - "certificate_revocation_list": "nautilus", - } - path = CertificateAuthorityServiceClient.certificate_revocation_list_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_certificate_revocation_list_path(path) - assert expected == actual - -def test_reusable_config_path(): - project = "scallop" - location = "abalone" - reusable_config = "squid" - expected = "projects/{project}/locations/{location}/reusableConfigs/{reusable_config}".format(project=project, location=location, reusable_config=reusable_config, ) - actual = CertificateAuthorityServiceClient.reusable_config_path(project, location, reusable_config) - assert expected == actual - - -def test_parse_reusable_config_path(): - expected = { - "project": "clam", - "location": "whelk", - "reusable_config": "octopus", - } - path = CertificateAuthorityServiceClient.reusable_config_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_reusable_config_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "oyster" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = CertificateAuthorityServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "nudibranch", - } - path = CertificateAuthorityServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder, ) - actual = CertificateAuthorityServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "mussel", - } - path = CertificateAuthorityServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "winkle" - expected = "organizations/{organization}".format(organization=organization, ) - actual = CertificateAuthorityServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "nautilus", - } - path = CertificateAuthorityServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "scallop" - expected = "projects/{project}".format(project=project, ) - actual = CertificateAuthorityServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "abalone", - } - path = CertificateAuthorityServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "squid" - location = "clam" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = CertificateAuthorityServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "whelk", - "location": "octopus", - } - path = CertificateAuthorityServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = CertificateAuthorityServiceClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_withDEFAULT_CLIENT_INFO(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object(transports.CertificateAuthorityServiceTransport, '_prep_wrapped_messages') as prep: - client = CertificateAuthorityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.CertificateAuthorityServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = CertificateAuthorityServiceClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) diff --git a/scripts/fixup_privateca_v1_keywords.py b/scripts/fixup_privateca_v1_keywords.py index 21095f3..65447c5 100644 --- a/scripts/fixup_privateca_v1_keywords.py +++ b/scripts/fixup_privateca_v1_keywords.py @@ -1,6 +1,5 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import argparse import os import libcst as cst @@ -41,36 +39,35 @@ def partition( class privatecaCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'activate_certificate_authority': ('name', 'pem_ca_certificate', 'subordinate_config', 'request_id', ), - 'create_ca_pool': ('parent', 'ca_pool_id', 'ca_pool', 'request_id', ), - 'create_certificate': ('parent', 'certificate', 'certificate_id', 'request_id', 'validate_only', 'issuing_certificate_authority_id', ), - 'create_certificate_authority': ('parent', 'certificate_authority_id', 'certificate_authority', 'request_id', ), - 'create_certificate_template': ('parent', 'certificate_template_id', 'certificate_template', 'request_id', ), - 'delete_ca_pool': ('name', 'request_id', ), - 'delete_certificate_authority': ('name', 'request_id', 'ignore_active_certificates', ), - 'delete_certificate_template': ('name', 'request_id', ), - 'disable_certificate_authority': ('name', 'request_id', ), - 'enable_certificate_authority': ('name', 'request_id', ), - 'fetch_ca_certs': ('ca_pool', 'request_id', ), - 'fetch_certificate_authority_csr': ('name', ), - 'get_ca_pool': ('name', ), - 'get_certificate': ('name', ), - 'get_certificate_authority': ('name', ), - 'get_certificate_revocation_list': ('name', ), - 'get_certificate_template': ('name', ), - 'list_ca_pools': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificate_authorities': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificate_revocation_lists': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificate_templates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'revoke_certificate': ('name', 'reason', 'request_id', ), - 'undelete_certificate_authority': ('name', 'request_id', ), - 'update_ca_pool': ('ca_pool', 'update_mask', 'request_id', ), - 'update_certificate': ('certificate', 'update_mask', 'request_id', ), - 'update_certificate_authority': ('certificate_authority', 'update_mask', 'request_id', ), - 'update_certificate_revocation_list': ('certificate_revocation_list', 'update_mask', 'request_id', ), - 'update_certificate_template': ('certificate_template', 'update_mask', 'request_id', ), - + 'activate_certificate_authority': ('name', 'pem_ca_certificate', 'subordinate_config', 'request_id', ), + 'create_ca_pool': ('parent', 'ca_pool_id', 'ca_pool', 'request_id', ), + 'create_certificate': ('parent', 'certificate', 'certificate_id', 'request_id', 'validate_only', 'issuing_certificate_authority_id', ), + 'create_certificate_authority': ('parent', 'certificate_authority_id', 'certificate_authority', 'request_id', ), + 'create_certificate_template': ('parent', 'certificate_template_id', 'certificate_template', 'request_id', ), + 'delete_ca_pool': ('name', 'request_id', ), + 'delete_certificate_authority': ('name', 'request_id', 'ignore_active_certificates', ), + 'delete_certificate_template': ('name', 'request_id', ), + 'disable_certificate_authority': ('name', 'request_id', ), + 'enable_certificate_authority': ('name', 'request_id', ), + 'fetch_ca_certs': ('ca_pool', 'request_id', ), + 'fetch_certificate_authority_csr': ('name', ), + 'get_ca_pool': ('name', ), + 'get_certificate': ('name', ), + 'get_certificate_authority': ('name', ), + 'get_certificate_revocation_list': ('name', ), + 'get_certificate_template': ('name', ), + 'list_ca_pools': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificate_authorities': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificate_revocation_lists': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificate_templates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'revoke_certificate': ('name', 'reason', 'request_id', ), + 'undelete_certificate_authority': ('name', 'request_id', ), + 'update_ca_pool': ('ca_pool', 'update_mask', 'request_id', ), + 'update_certificate': ('certificate', 'update_mask', 'request_id', ), + 'update_certificate_authority': ('certificate_authority', 'update_mask', 'request_id', ), + 'update_certificate_revocation_list': ('certificate_revocation_list', 'update_mask', 'request_id', ), + 'update_certificate_template': ('certificate_template', 'update_mask', 'request_id', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -101,7 +98,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: value=cst.Dict([ cst.DictElement( cst.SimpleString("'{}'".format(name)), - cst.Element(value=arg.value) +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 diff --git a/scripts/fixup_privateca_v1beta1_keywords.py b/scripts/fixup_privateca_v1beta1_keywords.py index b6ac80d..afc0c8d 100644 --- a/scripts/fixup_privateca_v1beta1_keywords.py +++ b/scripts/fixup_privateca_v1beta1_keywords.py @@ -1,6 +1,5 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import argparse import os import libcst as cst @@ -41,27 +39,26 @@ def partition( class privatecaCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'activate_certificate_authority': ('name', 'pem_ca_certificate', 'subordinate_config', 'request_id', ), - 'create_certificate': ('parent', 'certificate', 'certificate_id', 'request_id', ), - 'create_certificate_authority': ('parent', 'certificate_authority_id', 'certificate_authority', 'request_id', ), - 'disable_certificate_authority': ('name', 'request_id', ), - 'enable_certificate_authority': ('name', 'request_id', ), - 'fetch_certificate_authority_csr': ('name', ), - 'get_certificate': ('name', ), - 'get_certificate_authority': ('name', ), - 'get_certificate_revocation_list': ('name', ), - 'get_reusable_config': ('name', ), - 'list_certificate_authorities': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificate_revocation_lists': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_certificates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_reusable_configs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'restore_certificate_authority': ('name', 'request_id', ), - 'revoke_certificate': ('name', 'reason', 'request_id', ), - 'schedule_delete_certificate_authority': ('name', 'request_id', ), - 'update_certificate': ('certificate', 'update_mask', 'request_id', ), - 'update_certificate_authority': ('certificate_authority', 'update_mask', 'request_id', ), - 'update_certificate_revocation_list': ('certificate_revocation_list', 'update_mask', 'request_id', ), - + 'activate_certificate_authority': ('name', 'pem_ca_certificate', 'subordinate_config', 'request_id', ), + 'create_certificate': ('parent', 'certificate', 'certificate_id', 'request_id', ), + 'create_certificate_authority': ('parent', 'certificate_authority_id', 'certificate_authority', 'request_id', ), + 'disable_certificate_authority': ('name', 'request_id', ), + 'enable_certificate_authority': ('name', 'request_id', ), + 'fetch_certificate_authority_csr': ('name', ), + 'get_certificate': ('name', ), + 'get_certificate_authority': ('name', ), + 'get_certificate_revocation_list': ('name', ), + 'get_reusable_config': ('name', ), + 'list_certificate_authorities': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificate_revocation_lists': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_certificates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_reusable_configs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'restore_certificate_authority': ('name', 'request_id', ), + 'revoke_certificate': ('name', 'reason', 'request_id', ), + 'schedule_delete_certificate_authority': ('name', 'request_id', ), + 'update_certificate': ('certificate', 'update_mask', 'request_id', ), + 'update_certificate_authority': ('certificate_authority', 'update_mask', 'request_id', ), + 'update_certificate_revocation_list': ('certificate_revocation_list', 'update_mask', 'request_id', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -92,7 +89,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: value=cst.Dict([ cst.DictElement( cst.SimpleString("'{}'".format(name)), - cst.Element(value=arg.value) +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 diff --git a/owl-bot-staging/v1/google/cloud/security/privateca_v1/services/__init__.py b/tests/__init__.py similarity index 100% rename from owl-bot-staging/v1/google/cloud/security/privateca_v1/services/__init__.py rename to tests/__init__.py diff --git a/owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/__init__.py b/tests/unit/__init__.py similarity index 100% rename from owl-bot-staging/v1beta1/google/cloud/security/privateca_v1beta1/services/__init__.py rename to tests/unit/__init__.py diff --git a/owl-bot-staging/v1/tests/__init__.py b/tests/unit/gapic/__init__.py similarity index 99% rename from owl-bot-staging/v1/tests/__init__.py rename to tests/unit/gapic/__init__.py index b54a5fc..4de6597 100644 --- a/owl-bot-staging/v1/tests/__init__.py +++ b/tests/unit/gapic/__init__.py @@ -1,4 +1,3 @@ - # -*- coding: utf-8 -*- # Copyright 2020 Google LLC # diff --git a/tests/unit/gapic/privateca_v1/__init__.py b/tests/unit/gapic/privateca_v1/__init__.py index 42ffdf2..4de6597 100644 --- a/tests/unit/gapic/privateca_v1/__init__.py +++ b/tests/unit/gapic/privateca_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py b/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py index a1acc15..ad655bf 100644 --- a/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py +++ b/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 -from google.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.security.privateca_v1.services.certificate_authority_service import ( CertificateAuthorityServiceAsyncClient, @@ -47,14 +46,44 @@ from google.cloud.security.privateca_v1.services.certificate_authority_service import ( transports, ) +from google.cloud.security.privateca_v1.services.certificate_authority_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.security.privateca_v1.services.certificate_authority_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.security.privateca_v1.types import resources from google.cloud.security.privateca_v1.types import service from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.type import expr_pb2 as expr # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import expr_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -109,7 +138,7 @@ def test__get_default_mtls_endpoint(): [CertificateAuthorityServiceClient, CertificateAuthorityServiceAsyncClient,], ) def test_certificate_authority_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -127,7 +156,7 @@ def test_certificate_authority_service_client_from_service_account_info(client_c [CertificateAuthorityServiceClient, CertificateAuthorityServiceAsyncClient,], ) def test_certificate_authority_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -186,7 +215,7 @@ def test_certificate_authority_service_client_client_options( with mock.patch.object( CertificateAuthorityServiceClient, "get_transport_class" ) as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -494,7 +523,7 @@ def test_create_certificate( transport: str = "grpc", request_type=service.CreateCertificateRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -515,29 +544,20 @@ def test_create_certificate( pem_certificate_chain=["pem_certificate_chain_value"], pem_csr="pem_csr_value", ) - 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] == service.CreateCertificateRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.issuer_certificate_authority == "issuer_certificate_authority_value" - assert response.certificate_template == "certificate_template_value" - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -549,7 +569,7 @@ 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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -559,7 +579,6 @@ def test_create_certificate_empty_call(): client.create_certificate() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateRequest() @@ -568,7 +587,7 @@ async def test_create_certificate_async( transport: str = "grpc_asyncio", request_type=service.CreateCertificateRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -590,28 +609,20 @@ async def test_create_certificate_async( pem_certificate_chain=["pem_certificate_chain_value"], ) ) - 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] == service.CreateCertificateRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.issuer_certificate_authority == "issuer_certificate_authority_value" - assert response.certificate_template == "certificate_template_value" - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -622,12 +633,13 @@ async def test_create_certificate_async_from_dict(): def test_create_certificate_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateCertificateRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -635,7 +647,6 @@ def test_create_certificate_field_headers(): type(client.transport.create_certificate), "__call__" ) as call: call.return_value = resources.Certificate() - client.create_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -651,12 +662,13 @@ def test_create_certificate_field_headers(): @pytest.mark.asyncio async def test_create_certificate_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateCertificateRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -666,7 +678,6 @@ async def test_create_certificate_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Certificate() ) - await client.create_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -681,7 +692,7 @@ async def test_create_certificate_field_headers_async(): def test_create_certificate_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -690,7 +701,6 @@ def test_create_certificate_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.Certificate() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_certificate( @@ -703,17 +713,14 @@ def test_create_certificate_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].certificate == resources.Certificate(name="name_value") - assert args[0].certificate_id == "certificate_id_value" def test_create_certificate_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -730,7 +737,7 @@ def test_create_certificate_flattened_error(): @pytest.mark.asyncio async def test_create_certificate_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -755,18 +762,15 @@ async def test_create_certificate_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].certificate == resources.Certificate(name="name_value") - assert args[0].certificate_id == "certificate_id_value" @pytest.mark.asyncio async def test_create_certificate_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -784,7 +788,7 @@ def test_get_certificate( transport: str = "grpc", request_type=service.GetCertificateRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -803,29 +807,20 @@ def test_get_certificate( pem_certificate_chain=["pem_certificate_chain_value"], pem_csr="pem_csr_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] == service.GetCertificateRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.issuer_certificate_authority == "issuer_certificate_authority_value" - assert response.certificate_template == "certificate_template_value" - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -837,7 +832,7 @@ 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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -845,7 +840,6 @@ def test_get_certificate_empty_call(): client.get_certificate() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRequest() @@ -854,7 +848,7 @@ async def test_get_certificate_async( transport: str = "grpc_asyncio", request_type=service.GetCertificateRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -874,28 +868,20 @@ async def test_get_certificate_async( pem_certificate_chain=["pem_certificate_chain_value"], ) ) - 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] == service.GetCertificateRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.issuer_certificate_authority == "issuer_certificate_authority_value" - assert response.certificate_template == "certificate_template_value" - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -906,18 +892,18 @@ async def test_get_certificate_async_from_dict(): def test_get_certificate_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.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 = resources.Certificate() - client.get_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -933,12 +919,13 @@ def test_get_certificate_field_headers(): @pytest.mark.asyncio async def test_get_certificate_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCertificateRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -946,7 +933,6 @@ async def test_get_certificate_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Certificate() ) - await client.get_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -961,14 +947,13 @@ async def test_get_certificate_field_headers_async(): def test_get_certificate_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + 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 = resources.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",) @@ -977,13 +962,12 @@ def test_get_certificate_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_certificate_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -997,7 +981,7 @@ def test_get_certificate_flattened_error(): @pytest.mark.asyncio async def test_get_certificate_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1016,14 +1000,13 @@ async def test_get_certificate_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_certificate_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1038,7 +1021,7 @@ def test_list_certificates( transport: str = "grpc", request_type=service.ListCertificatesRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1053,21 +1036,16 @@ def test_list_certificates( call.return_value = service.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] == service.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"] @@ -1079,7 +1057,7 @@ 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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1089,7 +1067,6 @@ def test_list_certificates_empty_call(): client.list_certificates() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificatesRequest() @@ -1098,7 +1075,7 @@ async def test_list_certificates_async( transport: str = "grpc_asyncio", request_type=service.ListCertificatesRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1116,20 +1093,16 @@ async def test_list_certificates_async( 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] == service.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"] @@ -1140,12 +1113,13 @@ async def test_list_certificates_async_from_dict(): def test_list_certificates_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificatesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1153,7 +1127,6 @@ def test_list_certificates_field_headers(): type(client.transport.list_certificates), "__call__" ) as call: call.return_value = service.ListCertificatesResponse() - client.list_certificates(request) # Establish that the underlying gRPC stub method was called. @@ -1169,12 +1142,13 @@ def test_list_certificates_field_headers(): @pytest.mark.asyncio async def test_list_certificates_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificatesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1184,7 +1158,6 @@ async def test_list_certificates_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListCertificatesResponse() ) - await client.list_certificates(request) # Establish that the underlying gRPC stub method was called. @@ -1199,7 +1172,7 @@ async def test_list_certificates_field_headers_async(): def test_list_certificates_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1208,7 +1181,6 @@ def test_list_certificates_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = service.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",) @@ -1217,13 +1189,12 @@ def test_list_certificates_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_certificates_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1237,7 +1208,7 @@ def test_list_certificates_flattened_error(): @pytest.mark.asyncio async def test_list_certificates_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1258,14 +1229,13 @@ async def test_list_certificates_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_certificates_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1278,7 +1248,7 @@ async def test_list_certificates_flattened_error_async(): def test_list_certificates_pager(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1320,7 +1290,7 @@ def test_list_certificates_pager(): def test_list_certificates_pages(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1354,7 +1324,7 @@ def test_list_certificates_pages(): @pytest.mark.asyncio async def test_list_certificates_async_pager(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1395,7 +1365,7 @@ async def test_list_certificates_async_pager(): @pytest.mark.asyncio async def test_list_certificates_async_pages(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1434,7 +1404,7 @@ def test_revoke_certificate( transport: str = "grpc", request_type=service.RevokeCertificateRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1455,29 +1425,20 @@ def test_revoke_certificate( pem_certificate_chain=["pem_certificate_chain_value"], pem_csr="pem_csr_value", ) - response = client.revoke_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] == service.RevokeCertificateRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.issuer_certificate_authority == "issuer_certificate_authority_value" - assert response.certificate_template == "certificate_template_value" - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -1489,7 +1450,7 @@ def test_revoke_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1499,7 +1460,6 @@ def test_revoke_certificate_empty_call(): client.revoke_certificate() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.RevokeCertificateRequest() @@ -1508,7 +1468,7 @@ async def test_revoke_certificate_async( transport: str = "grpc_asyncio", request_type=service.RevokeCertificateRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1530,28 +1490,20 @@ async def test_revoke_certificate_async( pem_certificate_chain=["pem_certificate_chain_value"], ) ) - response = await client.revoke_certificate(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.RevokeCertificateRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.issuer_certificate_authority == "issuer_certificate_authority_value" - assert response.certificate_template == "certificate_template_value" - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -1562,12 +1514,13 @@ async def test_revoke_certificate_async_from_dict(): def test_revoke_certificate_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.RevokeCertificateRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1575,7 +1528,6 @@ def test_revoke_certificate_field_headers(): type(client.transport.revoke_certificate), "__call__" ) as call: call.return_value = resources.Certificate() - client.revoke_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -1591,12 +1543,13 @@ def test_revoke_certificate_field_headers(): @pytest.mark.asyncio async def test_revoke_certificate_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.RevokeCertificateRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1606,7 +1559,6 @@ async def test_revoke_certificate_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Certificate() ) - await client.revoke_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -1621,7 +1573,7 @@ async def test_revoke_certificate_field_headers_async(): def test_revoke_certificate_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1630,7 +1582,6 @@ def test_revoke_certificate_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.Certificate() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.revoke_certificate(name="name_value",) @@ -1639,13 +1590,12 @@ def test_revoke_certificate_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_revoke_certificate_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1659,7 +1609,7 @@ def test_revoke_certificate_flattened_error(): @pytest.mark.asyncio async def test_revoke_certificate_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1680,14 +1630,13 @@ async def test_revoke_certificate_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_revoke_certificate_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1702,7 +1651,7 @@ def test_update_certificate( transport: str = "grpc", request_type=service.UpdateCertificateRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1723,29 +1672,20 @@ def test_update_certificate( pem_certificate_chain=["pem_certificate_chain_value"], pem_csr="pem_csr_value", ) - 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] == service.UpdateCertificateRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.issuer_certificate_authority == "issuer_certificate_authority_value" - assert response.certificate_template == "certificate_template_value" - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -1757,7 +1697,7 @@ 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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1767,7 +1707,6 @@ def test_update_certificate_empty_call(): client.update_certificate() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRequest() @@ -1776,7 +1715,7 @@ async def test_update_certificate_async( transport: str = "grpc_asyncio", request_type=service.UpdateCertificateRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1798,28 +1737,20 @@ async def test_update_certificate_async( pem_certificate_chain=["pem_certificate_chain_value"], ) ) - 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] == service.UpdateCertificateRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.issuer_certificate_authority == "issuer_certificate_authority_value" - assert response.certificate_template == "certificate_template_value" - assert response.subject_mode == resources.SubjectRequestMode.DEFAULT - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -1830,12 +1761,13 @@ async def test_update_certificate_async_from_dict(): def test_update_certificate_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateRequest() + request.certificate.name = "certificate.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1843,7 +1775,6 @@ def test_update_certificate_field_headers(): type(client.transport.update_certificate), "__call__" ) as call: call.return_value = resources.Certificate() - client.update_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -1861,12 +1792,13 @@ def test_update_certificate_field_headers(): @pytest.mark.asyncio async def test_update_certificate_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateRequest() + request.certificate.name = "certificate.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1876,7 +1808,6 @@ async def test_update_certificate_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Certificate() ) - await client.update_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -1893,7 +1824,7 @@ async def test_update_certificate_field_headers_async(): def test_update_certificate_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1902,27 +1833,24 @@ def test_update_certificate_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.Certificate() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_certificate( certificate=resources.Certificate(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].certificate == resources.Certificate(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_certificate_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1931,14 +1859,14 @@ def test_update_certificate_flattened_error(): client.update_certificate( service.UpdateCertificateRequest(), certificate=resources.Certificate(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_certificate_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1955,23 +1883,21 @@ async def test_update_certificate_flattened_async(): # using the keyword arguments to the method. response = await client.update_certificate( certificate=resources.Certificate(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].certificate == resources.Certificate(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_certificate_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1980,7 +1906,7 @@ async def test_update_certificate_flattened_error_async(): await client.update_certificate( service.UpdateCertificateRequest(), certificate=resources.Certificate(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1988,7 +1914,7 @@ def test_activate_certificate_authority( transport: str = "grpc", request_type=service.ActivateCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2001,13 +1927,11 @@ def test_activate_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.activate_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2022,7 +1946,7 @@ def test_activate_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2032,7 +1956,6 @@ def test_activate_certificate_authority_empty_call(): client.activate_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateCertificateAuthorityRequest() @@ -2042,7 +1965,7 @@ async def test_activate_certificate_authority_async( request_type=service.ActivateCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2057,13 +1980,11 @@ async def test_activate_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.activate_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2077,12 +1998,13 @@ async def test_activate_certificate_authority_async_from_dict(): def test_activate_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ActivateCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2090,7 +2012,6 @@ def test_activate_certificate_authority_field_headers(): type(client.transport.activate_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.activate_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2106,12 +2027,13 @@ def test_activate_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_activate_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ActivateCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2121,7 +2043,6 @@ async def test_activate_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.activate_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2136,7 +2057,7 @@ async def test_activate_certificate_authority_field_headers_async(): def test_activate_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2145,7 +2066,6 @@ def test_activate_certificate_authority_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.activate_certificate_authority(name="name_value",) @@ -2154,13 +2074,12 @@ def test_activate_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_activate_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2174,7 +2093,7 @@ def test_activate_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_activate_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2195,14 +2114,13 @@ async def test_activate_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_activate_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2217,7 +2135,7 @@ def test_create_certificate_authority( transport: str = "grpc", request_type=service.CreateCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2230,13 +2148,11 @@ def test_create_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2251,7 +2167,7 @@ def test_create_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2261,7 +2177,6 @@ def test_create_certificate_authority_empty_call(): client.create_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateAuthorityRequest() @@ -2271,7 +2186,7 @@ async def test_create_certificate_authority_async( request_type=service.CreateCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2286,13 +2201,11 @@ async def test_create_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2306,12 +2219,13 @@ async def test_create_certificate_authority_async_from_dict(): def test_create_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateCertificateAuthorityRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2319,7 +2233,6 @@ def test_create_certificate_authority_field_headers(): type(client.transport.create_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2335,12 +2248,13 @@ def test_create_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_create_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateCertificateAuthorityRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2350,7 +2264,6 @@ async def test_create_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2365,7 +2278,7 @@ async def test_create_certificate_authority_field_headers_async(): def test_create_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2374,7 +2287,6 @@ def test_create_certificate_authority_flattened(): ) 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_authority( @@ -2387,19 +2299,16 @@ def test_create_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].certificate_authority == resources.CertificateAuthority( name="name_value" ) - assert args[0].certificate_authority_id == "certificate_authority_id_value" def test_create_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2416,7 +2325,7 @@ def test_create_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_create_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2441,20 +2350,17 @@ async def test_create_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].certificate_authority == resources.CertificateAuthority( name="name_value" ) - assert args[0].certificate_authority_id == "certificate_authority_id_value" @pytest.mark.asyncio async def test_create_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2472,7 +2378,7 @@ def test_disable_certificate_authority( transport: str = "grpc", request_type=service.DisableCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2485,13 +2391,11 @@ def test_disable_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.disable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2506,7 +2410,7 @@ def test_disable_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2516,7 +2420,6 @@ def test_disable_certificate_authority_empty_call(): client.disable_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableCertificateAuthorityRequest() @@ -2526,7 +2429,7 @@ async def test_disable_certificate_authority_async( request_type=service.DisableCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2541,13 +2444,11 @@ async def test_disable_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.disable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2561,12 +2462,13 @@ async def test_disable_certificate_authority_async_from_dict(): def test_disable_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DisableCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2574,7 +2476,6 @@ def test_disable_certificate_authority_field_headers(): type(client.transport.disable_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.disable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2590,12 +2491,13 @@ def test_disable_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_disable_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DisableCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2605,7 +2507,6 @@ async def test_disable_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.disable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2620,7 +2521,7 @@ async def test_disable_certificate_authority_field_headers_async(): def test_disable_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2629,7 +2530,6 @@ def test_disable_certificate_authority_flattened(): ) 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.disable_certificate_authority(name="name_value",) @@ -2638,13 +2538,12 @@ def test_disable_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_disable_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2658,7 +2557,7 @@ def test_disable_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_disable_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2679,14 +2578,13 @@ async def test_disable_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_disable_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2701,7 +2599,7 @@ def test_enable_certificate_authority( transport: str = "grpc", request_type=service.EnableCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2714,13 +2612,11 @@ def test_enable_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.enable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2735,7 +2631,7 @@ def test_enable_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2745,7 +2641,6 @@ def test_enable_certificate_authority_empty_call(): client.enable_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableCertificateAuthorityRequest() @@ -2755,7 +2650,7 @@ async def test_enable_certificate_authority_async( request_type=service.EnableCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2770,13 +2665,11 @@ async def test_enable_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.enable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2790,12 +2683,13 @@ async def test_enable_certificate_authority_async_from_dict(): def test_enable_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.EnableCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2803,7 +2697,6 @@ def test_enable_certificate_authority_field_headers(): type(client.transport.enable_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.enable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2819,12 +2712,13 @@ def test_enable_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_enable_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.EnableCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2834,7 +2728,6 @@ async def test_enable_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.enable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2849,7 +2742,7 @@ async def test_enable_certificate_authority_field_headers_async(): def test_enable_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2858,7 +2751,6 @@ def test_enable_certificate_authority_flattened(): ) 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.enable_certificate_authority(name="name_value",) @@ -2867,13 +2759,12 @@ def test_enable_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_enable_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2887,7 +2778,7 @@ def test_enable_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_enable_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2908,14 +2799,13 @@ async def test_enable_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_enable_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2930,7 +2820,7 @@ def test_fetch_certificate_authority_csr( transport: str = "grpc", request_type=service.FetchCertificateAuthorityCsrRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2945,19 +2835,15 @@ def test_fetch_certificate_authority_csr( call.return_value = service.FetchCertificateAuthorityCsrResponse( pem_csr="pem_csr_value", ) - response = client.fetch_certificate_authority_csr(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCertificateAuthorityCsrRequest() # Establish that the response is the type that we expect. - assert isinstance(response, service.FetchCertificateAuthorityCsrResponse) - assert response.pem_csr == "pem_csr_value" @@ -2969,7 +2855,7 @@ def test_fetch_certificate_authority_csr_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2979,7 +2865,6 @@ def test_fetch_certificate_authority_csr_empty_call(): client.fetch_certificate_authority_csr() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCertificateAuthorityCsrRequest() @@ -2989,7 +2874,7 @@ async def test_fetch_certificate_authority_csr_async( request_type=service.FetchCertificateAuthorityCsrRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3004,18 +2889,15 @@ async def test_fetch_certificate_authority_csr_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.FetchCertificateAuthorityCsrResponse(pem_csr="pem_csr_value",) ) - response = await client.fetch_certificate_authority_csr(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCertificateAuthorityCsrRequest() # Establish that the response is the type that we expect. assert isinstance(response, service.FetchCertificateAuthorityCsrResponse) - assert response.pem_csr == "pem_csr_value" @@ -3026,12 +2908,13 @@ async def test_fetch_certificate_authority_csr_async_from_dict(): def test_fetch_certificate_authority_csr_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.FetchCertificateAuthorityCsrRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3039,7 +2922,6 @@ def test_fetch_certificate_authority_csr_field_headers(): type(client.transport.fetch_certificate_authority_csr), "__call__" ) as call: call.return_value = service.FetchCertificateAuthorityCsrResponse() - client.fetch_certificate_authority_csr(request) # Establish that the underlying gRPC stub method was called. @@ -3055,12 +2937,13 @@ def test_fetch_certificate_authority_csr_field_headers(): @pytest.mark.asyncio async def test_fetch_certificate_authority_csr_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.FetchCertificateAuthorityCsrRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3070,7 +2953,6 @@ async def test_fetch_certificate_authority_csr_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.FetchCertificateAuthorityCsrResponse() ) - await client.fetch_certificate_authority_csr(request) # Establish that the underlying gRPC stub method was called. @@ -3085,7 +2967,7 @@ async def test_fetch_certificate_authority_csr_field_headers_async(): def test_fetch_certificate_authority_csr_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3094,7 +2976,6 @@ def test_fetch_certificate_authority_csr_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = service.FetchCertificateAuthorityCsrResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.fetch_certificate_authority_csr(name="name_value",) @@ -3103,13 +2984,12 @@ def test_fetch_certificate_authority_csr_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_fetch_certificate_authority_csr_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3123,7 +3003,7 @@ def test_fetch_certificate_authority_csr_flattened_error(): @pytest.mark.asyncio async def test_fetch_certificate_authority_csr_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3144,14 +3024,13 @@ async def test_fetch_certificate_authority_csr_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_fetch_certificate_authority_csr_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3166,7 +3045,7 @@ def test_get_certificate_authority( transport: str = "grpc", request_type=service.GetCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3186,29 +3065,20 @@ def test_get_certificate_authority( pem_ca_certificates=["pem_ca_certificates_value"], gcs_bucket="gcs_bucket_value", ) - response = client.get_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateAuthorityRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateAuthority) - assert response.name == "name_value" - assert response.type_ == resources.CertificateAuthority.Type.SELF_SIGNED - assert response.tier == resources.CaPool.Tier.ENTERPRISE - assert response.state == resources.CertificateAuthority.State.ENABLED - assert response.pem_ca_certificates == ["pem_ca_certificates_value"] - assert response.gcs_bucket == "gcs_bucket_value" @@ -3220,7 +3090,7 @@ def test_get_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3230,7 +3100,6 @@ def test_get_certificate_authority_empty_call(): client.get_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateAuthorityRequest() @@ -3239,7 +3108,7 @@ async def test_get_certificate_authority_async( transport: str = "grpc_asyncio", request_type=service.GetCertificateAuthorityRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3261,28 +3130,20 @@ async def test_get_certificate_authority_async( gcs_bucket="gcs_bucket_value", ) ) - response = await client.get_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateAuthorityRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.CertificateAuthority) - assert response.name == "name_value" - assert response.type_ == resources.CertificateAuthority.Type.SELF_SIGNED - assert response.tier == resources.CaPool.Tier.ENTERPRISE - assert response.state == resources.CertificateAuthority.State.ENABLED - assert response.pem_ca_certificates == ["pem_ca_certificates_value"] - assert response.gcs_bucket == "gcs_bucket_value" @@ -3293,12 +3154,13 @@ async def test_get_certificate_authority_async_from_dict(): def test_get_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3306,7 +3168,6 @@ def test_get_certificate_authority_field_headers(): type(client.transport.get_certificate_authority), "__call__" ) as call: call.return_value = resources.CertificateAuthority() - client.get_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -3322,12 +3183,13 @@ def test_get_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_get_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3337,7 +3199,6 @@ async def test_get_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.CertificateAuthority() ) - await client.get_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -3352,7 +3213,7 @@ async def test_get_certificate_authority_field_headers_async(): def test_get_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3361,7 +3222,6 @@ def test_get_certificate_authority_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.CertificateAuthority() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_certificate_authority(name="name_value",) @@ -3370,13 +3230,12 @@ def test_get_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3390,7 +3249,7 @@ def test_get_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_get_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3411,14 +3270,13 @@ async def test_get_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3433,7 +3291,7 @@ def test_list_certificate_authorities( transport: str = "grpc", request_type=service.ListCertificateAuthoritiesRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3448,21 +3306,16 @@ def test_list_certificate_authorities( call.return_value = service.ListCertificateAuthoritiesResponse( next_page_token="next_page_token_value", unreachable=["unreachable_value"], ) - response = client.list_certificate_authorities(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateAuthoritiesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateAuthoritiesPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -3474,7 +3327,7 @@ def test_list_certificate_authorities_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3484,7 +3337,6 @@ def test_list_certificate_authorities_empty_call(): client.list_certificate_authorities() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateAuthoritiesRequest() @@ -3494,7 +3346,7 @@ async def test_list_certificate_authorities_async( request_type=service.ListCertificateAuthoritiesRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3512,20 +3364,16 @@ async def test_list_certificate_authorities_async( unreachable=["unreachable_value"], ) ) - response = await client.list_certificate_authorities(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateAuthoritiesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListCertificateAuthoritiesAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -3536,12 +3384,13 @@ async def test_list_certificate_authorities_async_from_dict(): def test_list_certificate_authorities_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificateAuthoritiesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3549,7 +3398,6 @@ def test_list_certificate_authorities_field_headers(): type(client.transport.list_certificate_authorities), "__call__" ) as call: call.return_value = service.ListCertificateAuthoritiesResponse() - client.list_certificate_authorities(request) # Establish that the underlying gRPC stub method was called. @@ -3565,12 +3413,13 @@ def test_list_certificate_authorities_field_headers(): @pytest.mark.asyncio async def test_list_certificate_authorities_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificateAuthoritiesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3580,7 +3429,6 @@ async def test_list_certificate_authorities_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListCertificateAuthoritiesResponse() ) - await client.list_certificate_authorities(request) # Establish that the underlying gRPC stub method was called. @@ -3595,7 +3443,7 @@ async def test_list_certificate_authorities_field_headers_async(): def test_list_certificate_authorities_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3604,7 +3452,6 @@ def test_list_certificate_authorities_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListCertificateAuthoritiesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_certificate_authorities(parent="parent_value",) @@ -3613,13 +3460,12 @@ def test_list_certificate_authorities_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_certificate_authorities_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3633,7 +3479,7 @@ def test_list_certificate_authorities_flattened_error(): @pytest.mark.asyncio async def test_list_certificate_authorities_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3654,14 +3500,13 @@ async def test_list_certificate_authorities_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_certificate_authorities_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3674,7 +3519,7 @@ async def test_list_certificate_authorities_flattened_error_async(): def test_list_certificate_authorities_pager(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3722,7 +3567,7 @@ def test_list_certificate_authorities_pager(): def test_list_certificate_authorities_pages(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3762,7 +3607,7 @@ def test_list_certificate_authorities_pages(): @pytest.mark.asyncio async def test_list_certificate_authorities_async_pager(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3809,7 +3654,7 @@ async def test_list_certificate_authorities_async_pager(): @pytest.mark.asyncio async def test_list_certificate_authorities_async_pages(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3856,7 +3701,7 @@ def test_undelete_certificate_authority( transport: str = "grpc", request_type=service.UndeleteCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3869,13 +3714,11 @@ def test_undelete_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.undelete_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.UndeleteCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -3890,7 +3733,7 @@ def test_undelete_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3900,7 +3743,6 @@ def test_undelete_certificate_authority_empty_call(): client.undelete_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.UndeleteCertificateAuthorityRequest() @@ -3910,7 +3752,7 @@ async def test_undelete_certificate_authority_async( request_type=service.UndeleteCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3925,13 +3767,11 @@ async def test_undelete_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.undelete_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.UndeleteCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -3945,12 +3785,13 @@ async def test_undelete_certificate_authority_async_from_dict(): def test_undelete_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UndeleteCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3958,7 +3799,6 @@ def test_undelete_certificate_authority_field_headers(): type(client.transport.undelete_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.undelete_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -3974,12 +3814,13 @@ def test_undelete_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_undelete_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UndeleteCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3989,7 +3830,6 @@ async def test_undelete_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.undelete_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -4004,7 +3844,7 @@ async def test_undelete_certificate_authority_field_headers_async(): def test_undelete_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4013,7 +3853,6 @@ def test_undelete_certificate_authority_flattened(): ) 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.undelete_certificate_authority(name="name_value",) @@ -4022,13 +3861,12 @@ def test_undelete_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_undelete_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4042,7 +3880,7 @@ def test_undelete_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_undelete_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4063,14 +3901,13 @@ async def test_undelete_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_undelete_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4085,7 +3922,7 @@ def test_delete_certificate_authority( transport: str = "grpc", request_type=service.DeleteCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4098,13 +3935,11 @@ def test_delete_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -4119,7 +3954,7 @@ def test_delete_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4129,7 +3964,6 @@ def test_delete_certificate_authority_empty_call(): client.delete_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCertificateAuthorityRequest() @@ -4139,7 +3973,7 @@ async def test_delete_certificate_authority_async( request_type=service.DeleteCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4154,13 +3988,11 @@ async def test_delete_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -4174,12 +4006,13 @@ async def test_delete_certificate_authority_async_from_dict(): def test_delete_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DeleteCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4187,7 +4020,6 @@ def test_delete_certificate_authority_field_headers(): type(client.transport.delete_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -4203,12 +4035,13 @@ def test_delete_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_delete_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DeleteCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4218,7 +4051,6 @@ async def test_delete_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -4233,7 +4065,7 @@ async def test_delete_certificate_authority_field_headers_async(): def test_delete_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4242,7 +4074,6 @@ def test_delete_certificate_authority_flattened(): ) 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_authority(name="name_value",) @@ -4251,13 +4082,12 @@ def test_delete_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4271,7 +4101,7 @@ def test_delete_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_delete_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4292,14 +4122,13 @@ async def test_delete_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4314,7 +4143,7 @@ def test_update_certificate_authority( transport: str = "grpc", request_type=service.UpdateCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4327,13 +4156,11 @@ def test_update_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -4348,7 +4175,7 @@ def test_update_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4358,7 +4185,6 @@ def test_update_certificate_authority_empty_call(): client.update_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateAuthorityRequest() @@ -4368,7 +4194,7 @@ async def test_update_certificate_authority_async( request_type=service.UpdateCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4383,13 +4209,11 @@ async def test_update_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -4403,12 +4227,13 @@ async def test_update_certificate_authority_async_from_dict(): def test_update_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateAuthorityRequest() + request.certificate_authority.name = "certificate_authority.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4416,7 +4241,6 @@ def test_update_certificate_authority_field_headers(): type(client.transport.update_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -4435,12 +4259,13 @@ def test_update_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_update_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateAuthorityRequest() + request.certificate_authority.name = "certificate_authority.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4450,7 +4275,6 @@ async def test_update_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -4468,7 +4292,7 @@ async def test_update_certificate_authority_field_headers_async(): def test_update_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4477,29 +4301,26 @@ def test_update_certificate_authority_flattened(): ) 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_authority( certificate_authority=resources.CertificateAuthority(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].certificate_authority == resources.CertificateAuthority( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4508,14 +4329,14 @@ def test_update_certificate_authority_flattened_error(): client.update_certificate_authority( service.UpdateCertificateAuthorityRequest(), certificate_authority=resources.CertificateAuthority(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4532,25 +4353,23 @@ async def test_update_certificate_authority_flattened_async(): # using the keyword arguments to the method. response = await client.update_certificate_authority( certificate_authority=resources.CertificateAuthority(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].certificate_authority == resources.CertificateAuthority( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4559,7 +4378,7 @@ async def test_update_certificate_authority_flattened_error_async(): await client.update_certificate_authority( service.UpdateCertificateAuthorityRequest(), certificate_authority=resources.CertificateAuthority(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -4567,7 +4386,7 @@ def test_create_ca_pool( transport: str = "grpc", request_type=service.CreateCaPoolRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4578,13 +4397,11 @@ def test_create_ca_pool( with mock.patch.object(type(client.transport.create_ca_pool), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_ca_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCaPoolRequest() # Establish that the response is the type that we expect. @@ -4599,7 +4416,7 @@ def test_create_ca_pool_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4607,7 +4424,6 @@ def test_create_ca_pool_empty_call(): client.create_ca_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCaPoolRequest() @@ -4616,7 +4432,7 @@ async def test_create_ca_pool_async( transport: str = "grpc_asyncio", request_type=service.CreateCaPoolRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4629,13 +4445,11 @@ async def test_create_ca_pool_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_ca_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCaPoolRequest() # Establish that the response is the type that we expect. @@ -4649,18 +4463,18 @@ async def test_create_ca_pool_async_from_dict(): def test_create_ca_pool_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateCaPoolRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_ca_pool), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_ca_pool(request) # Establish that the underlying gRPC stub method was called. @@ -4676,12 +4490,13 @@ def test_create_ca_pool_field_headers(): @pytest.mark.asyncio async def test_create_ca_pool_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateCaPoolRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4689,7 +4504,6 @@ async def test_create_ca_pool_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_ca_pool(request) # Establish that the underlying gRPC stub method was called. @@ -4704,14 +4518,13 @@ async def test_create_ca_pool_field_headers_async(): def test_create_ca_pool_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_ca_pool), "__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_ca_pool( @@ -4724,17 +4537,14 @@ def test_create_ca_pool_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].ca_pool == resources.CaPool(name="name_value") - assert args[0].ca_pool_id == "ca_pool_id_value" def test_create_ca_pool_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4751,7 +4561,7 @@ def test_create_ca_pool_flattened_error(): @pytest.mark.asyncio async def test_create_ca_pool_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4774,18 +4584,15 @@ async def test_create_ca_pool_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].ca_pool == resources.CaPool(name="name_value") - assert args[0].ca_pool_id == "ca_pool_id_value" @pytest.mark.asyncio async def test_create_ca_pool_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4803,7 +4610,7 @@ def test_update_ca_pool( transport: str = "grpc", request_type=service.UpdateCaPoolRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4814,13 +4621,11 @@ def test_update_ca_pool( with mock.patch.object(type(client.transport.update_ca_pool), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_ca_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCaPoolRequest() # Establish that the response is the type that we expect. @@ -4835,7 +4640,7 @@ def test_update_ca_pool_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4843,7 +4648,6 @@ def test_update_ca_pool_empty_call(): client.update_ca_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCaPoolRequest() @@ -4852,7 +4656,7 @@ async def test_update_ca_pool_async( transport: str = "grpc_asyncio", request_type=service.UpdateCaPoolRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4865,13 +4669,11 @@ async def test_update_ca_pool_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_ca_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCaPoolRequest() # Establish that the response is the type that we expect. @@ -4885,18 +4687,18 @@ async def test_update_ca_pool_async_from_dict(): def test_update_ca_pool_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCaPoolRequest() + request.ca_pool.name = "ca_pool.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_ca_pool), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_ca_pool(request) # Establish that the underlying gRPC stub method was called. @@ -4914,12 +4716,13 @@ def test_update_ca_pool_field_headers(): @pytest.mark.asyncio async def test_update_ca_pool_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCaPoolRequest() + request.ca_pool.name = "ca_pool.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4927,7 +4730,6 @@ async def test_update_ca_pool_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_ca_pool(request) # Establish that the underlying gRPC stub method was called. @@ -4944,34 +4746,31 @@ async def test_update_ca_pool_field_headers_async(): def test_update_ca_pool_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_ca_pool), "__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_ca_pool( ca_pool=resources.CaPool(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].ca_pool == resources.CaPool(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_ca_pool_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4980,14 +4779,14 @@ def test_update_ca_pool_flattened_error(): client.update_ca_pool( service.UpdateCaPoolRequest(), ca_pool=resources.CaPool(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_ca_pool_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5002,23 +4801,21 @@ async def test_update_ca_pool_flattened_async(): # using the keyword arguments to the method. response = await client.update_ca_pool( ca_pool=resources.CaPool(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].ca_pool == resources.CaPool(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_ca_pool_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5027,13 +4824,13 @@ async def test_update_ca_pool_flattened_error_async(): await client.update_ca_pool( service.UpdateCaPoolRequest(), ca_pool=resources.CaPool(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) def test_get_ca_pool(transport: str = "grpc", request_type=service.GetCaPoolRequest): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5046,21 +4843,16 @@ def test_get_ca_pool(transport: str = "grpc", request_type=service.GetCaPoolRequ call.return_value = resources.CaPool( name="name_value", tier=resources.CaPool.Tier.ENTERPRISE, ) - response = client.get_ca_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCaPoolRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.CaPool) - assert response.name == "name_value" - assert response.tier == resources.CaPool.Tier.ENTERPRISE @@ -5072,7 +4864,7 @@ def test_get_ca_pool_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5080,7 +4872,6 @@ def test_get_ca_pool_empty_call(): client.get_ca_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCaPoolRequest() @@ -5089,7 +4880,7 @@ async def test_get_ca_pool_async( transport: str = "grpc_asyncio", request_type=service.GetCaPoolRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5102,20 +4893,16 @@ async def test_get_ca_pool_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.CaPool(name="name_value", tier=resources.CaPool.Tier.ENTERPRISE,) ) - response = await client.get_ca_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCaPoolRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.CaPool) - assert response.name == "name_value" - assert response.tier == resources.CaPool.Tier.ENTERPRISE @@ -5126,18 +4913,18 @@ async def test_get_ca_pool_async_from_dict(): def test_get_ca_pool_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCaPoolRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_ca_pool), "__call__") as call: call.return_value = resources.CaPool() - client.get_ca_pool(request) # Establish that the underlying gRPC stub method was called. @@ -5153,18 +4940,18 @@ def test_get_ca_pool_field_headers(): @pytest.mark.asyncio async def test_get_ca_pool_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCaPoolRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_ca_pool), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.CaPool()) - await client.get_ca_pool(request) # Establish that the underlying gRPC stub method was called. @@ -5179,14 +4966,13 @@ async def test_get_ca_pool_field_headers_async(): def test_get_ca_pool_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_ca_pool), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.CaPool() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_ca_pool(name="name_value",) @@ -5195,13 +4981,12 @@ def test_get_ca_pool_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_ca_pool_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5215,7 +5000,7 @@ def test_get_ca_pool_flattened_error(): @pytest.mark.asyncio async def test_get_ca_pool_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5232,14 +5017,13 @@ async def test_get_ca_pool_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_ca_pool_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5254,7 +5038,7 @@ def test_list_ca_pools( transport: str = "grpc", request_type=service.ListCaPoolsRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5267,21 +5051,16 @@ def test_list_ca_pools( call.return_value = service.ListCaPoolsResponse( next_page_token="next_page_token_value", unreachable=["unreachable_value"], ) - response = client.list_ca_pools(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCaPoolsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCaPoolsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -5293,7 +5072,7 @@ def test_list_ca_pools_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5301,7 +5080,6 @@ def test_list_ca_pools_empty_call(): client.list_ca_pools() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCaPoolsRequest() @@ -5310,7 +5088,7 @@ async def test_list_ca_pools_async( transport: str = "grpc_asyncio", request_type=service.ListCaPoolsRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5326,20 +5104,16 @@ async def test_list_ca_pools_async( unreachable=["unreachable_value"], ) ) - response = await client.list_ca_pools(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCaPoolsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListCaPoolsAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -5350,18 +5124,18 @@ async def test_list_ca_pools_async_from_dict(): def test_list_ca_pools_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCaPoolsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_ca_pools), "__call__") as call: call.return_value = service.ListCaPoolsResponse() - client.list_ca_pools(request) # Establish that the underlying gRPC stub method was called. @@ -5377,12 +5151,13 @@ def test_list_ca_pools_field_headers(): @pytest.mark.asyncio async def test_list_ca_pools_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCaPoolsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5390,7 +5165,6 @@ async def test_list_ca_pools_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListCaPoolsResponse() ) - await client.list_ca_pools(request) # Establish that the underlying gRPC stub method was called. @@ -5405,14 +5179,13 @@ async def test_list_ca_pools_field_headers_async(): def test_list_ca_pools_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_ca_pools), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListCaPoolsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_ca_pools(parent="parent_value",) @@ -5421,13 +5194,12 @@ def test_list_ca_pools_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_ca_pools_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5441,7 +5213,7 @@ def test_list_ca_pools_flattened_error(): @pytest.mark.asyncio async def test_list_ca_pools_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5460,14 +5232,13 @@ async def test_list_ca_pools_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_ca_pools_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5480,7 +5251,7 @@ async def test_list_ca_pools_flattened_error_async(): def test_list_ca_pools_pager(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5516,7 +5287,7 @@ def test_list_ca_pools_pager(): def test_list_ca_pools_pages(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5544,7 +5315,7 @@ def test_list_ca_pools_pages(): @pytest.mark.asyncio async def test_list_ca_pools_async_pager(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5579,7 +5350,7 @@ async def test_list_ca_pools_async_pager(): @pytest.mark.asyncio async def test_list_ca_pools_async_pages(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5612,7 +5383,7 @@ def test_delete_ca_pool( transport: str = "grpc", request_type=service.DeleteCaPoolRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5623,13 +5394,11 @@ def test_delete_ca_pool( with mock.patch.object(type(client.transport.delete_ca_pool), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_ca_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCaPoolRequest() # Establish that the response is the type that we expect. @@ -5644,7 +5413,7 @@ def test_delete_ca_pool_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5652,7 +5421,6 @@ def test_delete_ca_pool_empty_call(): client.delete_ca_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCaPoolRequest() @@ -5661,7 +5429,7 @@ async def test_delete_ca_pool_async( transport: str = "grpc_asyncio", request_type=service.DeleteCaPoolRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5674,13 +5442,11 @@ async def test_delete_ca_pool_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_ca_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCaPoolRequest() # Establish that the response is the type that we expect. @@ -5694,18 +5460,18 @@ async def test_delete_ca_pool_async_from_dict(): def test_delete_ca_pool_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DeleteCaPoolRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_ca_pool), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_ca_pool(request) # Establish that the underlying gRPC stub method was called. @@ -5721,12 +5487,13 @@ def test_delete_ca_pool_field_headers(): @pytest.mark.asyncio async def test_delete_ca_pool_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DeleteCaPoolRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5734,7 +5501,6 @@ async def test_delete_ca_pool_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_ca_pool(request) # Establish that the underlying gRPC stub method was called. @@ -5749,14 +5515,13 @@ async def test_delete_ca_pool_field_headers_async(): def test_delete_ca_pool_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_ca_pool), "__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_ca_pool(name="name_value",) @@ -5765,13 +5530,12 @@ def test_delete_ca_pool_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_ca_pool_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5785,7 +5549,7 @@ def test_delete_ca_pool_flattened_error(): @pytest.mark.asyncio async def test_delete_ca_pool_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5804,14 +5568,13 @@ async def test_delete_ca_pool_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_ca_pool_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5826,7 +5589,7 @@ def test_fetch_ca_certs( transport: str = "grpc", request_type=service.FetchCaCertsRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5837,17 +5600,14 @@ def test_fetch_ca_certs( with mock.patch.object(type(client.transport.fetch_ca_certs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.FetchCaCertsResponse() - response = client.fetch_ca_certs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCaCertsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, service.FetchCaCertsResponse) @@ -5859,7 +5619,7 @@ def test_fetch_ca_certs_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5867,7 +5627,6 @@ def test_fetch_ca_certs_empty_call(): client.fetch_ca_certs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCaCertsRequest() @@ -5876,7 +5635,7 @@ async def test_fetch_ca_certs_async( transport: str = "grpc_asyncio", request_type=service.FetchCaCertsRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5889,13 +5648,11 @@ async def test_fetch_ca_certs_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.FetchCaCertsResponse() ) - response = await client.fetch_ca_certs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCaCertsRequest() # Establish that the response is the type that we expect. @@ -5909,18 +5666,18 @@ async def test_fetch_ca_certs_async_from_dict(): def test_fetch_ca_certs_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.FetchCaCertsRequest() + request.ca_pool = "ca_pool/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.fetch_ca_certs), "__call__") as call: call.return_value = service.FetchCaCertsResponse() - client.fetch_ca_certs(request) # Establish that the underlying gRPC stub method was called. @@ -5936,12 +5693,13 @@ def test_fetch_ca_certs_field_headers(): @pytest.mark.asyncio async def test_fetch_ca_certs_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.FetchCaCertsRequest() + request.ca_pool = "ca_pool/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5949,7 +5707,6 @@ async def test_fetch_ca_certs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.FetchCaCertsResponse() ) - await client.fetch_ca_certs(request) # Establish that the underlying gRPC stub method was called. @@ -5964,14 +5721,13 @@ async def test_fetch_ca_certs_field_headers_async(): def test_fetch_ca_certs_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.fetch_ca_certs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.FetchCaCertsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.fetch_ca_certs(ca_pool="ca_pool_value",) @@ -5980,13 +5736,12 @@ def test_fetch_ca_certs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].ca_pool == "ca_pool_value" def test_fetch_ca_certs_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6000,7 +5755,7 @@ def test_fetch_ca_certs_flattened_error(): @pytest.mark.asyncio async def test_fetch_ca_certs_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6019,14 +5774,13 @@ async def test_fetch_ca_certs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].ca_pool == "ca_pool_value" @pytest.mark.asyncio async def test_fetch_ca_certs_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6041,7 +5795,7 @@ def test_get_certificate_revocation_list( transport: str = "grpc", request_type=service.GetCertificateRevocationListRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6061,29 +5815,20 @@ def test_get_certificate_revocation_list( state=resources.CertificateRevocationList.State.ACTIVE, revision_id="revision_id_value", ) - response = client.get_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRevocationListRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateRevocationList) - assert response.name == "name_value" - assert response.sequence_number == 1601 - assert response.pem_crl == "pem_crl_value" - assert response.access_url == "access_url_value" - assert response.state == resources.CertificateRevocationList.State.ACTIVE - assert response.revision_id == "revision_id_value" @@ -6095,7 +5840,7 @@ def test_get_certificate_revocation_list_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6105,7 +5850,6 @@ def test_get_certificate_revocation_list_empty_call(): client.get_certificate_revocation_list() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRevocationListRequest() @@ -6115,7 +5859,7 @@ async def test_get_certificate_revocation_list_async( request_type=service.GetCertificateRevocationListRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6137,28 +5881,20 @@ async def test_get_certificate_revocation_list_async( revision_id="revision_id_value", ) ) - response = await client.get_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRevocationListRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.CertificateRevocationList) - assert response.name == "name_value" - assert response.sequence_number == 1601 - assert response.pem_crl == "pem_crl_value" - assert response.access_url == "access_url_value" - assert response.state == resources.CertificateRevocationList.State.ACTIVE - assert response.revision_id == "revision_id_value" @@ -6169,12 +5905,13 @@ async def test_get_certificate_revocation_list_async_from_dict(): def test_get_certificate_revocation_list_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCertificateRevocationListRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6182,7 +5919,6 @@ def test_get_certificate_revocation_list_field_headers(): type(client.transport.get_certificate_revocation_list), "__call__" ) as call: call.return_value = resources.CertificateRevocationList() - client.get_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. @@ -6198,12 +5934,13 @@ def test_get_certificate_revocation_list_field_headers(): @pytest.mark.asyncio async def test_get_certificate_revocation_list_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCertificateRevocationListRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6213,7 +5950,6 @@ async def test_get_certificate_revocation_list_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.CertificateRevocationList() ) - await client.get_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. @@ -6228,7 +5964,7 @@ async def test_get_certificate_revocation_list_field_headers_async(): def test_get_certificate_revocation_list_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6237,7 +5973,6 @@ def test_get_certificate_revocation_list_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.CertificateRevocationList() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_certificate_revocation_list(name="name_value",) @@ -6246,13 +5981,12 @@ def test_get_certificate_revocation_list_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_certificate_revocation_list_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6266,7 +6000,7 @@ def test_get_certificate_revocation_list_flattened_error(): @pytest.mark.asyncio async def test_get_certificate_revocation_list_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6287,14 +6021,13 @@ async def test_get_certificate_revocation_list_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_certificate_revocation_list_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6309,7 +6042,7 @@ def test_list_certificate_revocation_lists( transport: str = "grpc", request_type=service.ListCertificateRevocationListsRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6324,21 +6057,16 @@ def test_list_certificate_revocation_lists( call.return_value = service.ListCertificateRevocationListsResponse( next_page_token="next_page_token_value", unreachable=["unreachable_value"], ) - response = client.list_certificate_revocation_lists(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateRevocationListsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateRevocationListsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -6350,7 +6078,7 @@ def test_list_certificate_revocation_lists_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6360,7 +6088,6 @@ def test_list_certificate_revocation_lists_empty_call(): client.list_certificate_revocation_lists() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateRevocationListsRequest() @@ -6370,7 +6097,7 @@ async def test_list_certificate_revocation_lists_async( request_type=service.ListCertificateRevocationListsRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6388,20 +6115,16 @@ async def test_list_certificate_revocation_lists_async( unreachable=["unreachable_value"], ) ) - response = await client.list_certificate_revocation_lists(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateRevocationListsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListCertificateRevocationListsAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -6412,12 +6135,13 @@ async def test_list_certificate_revocation_lists_async_from_dict(): def test_list_certificate_revocation_lists_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificateRevocationListsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6425,7 +6149,6 @@ def test_list_certificate_revocation_lists_field_headers(): type(client.transport.list_certificate_revocation_lists), "__call__" ) as call: call.return_value = service.ListCertificateRevocationListsResponse() - client.list_certificate_revocation_lists(request) # Establish that the underlying gRPC stub method was called. @@ -6441,12 +6164,13 @@ def test_list_certificate_revocation_lists_field_headers(): @pytest.mark.asyncio async def test_list_certificate_revocation_lists_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificateRevocationListsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6456,7 +6180,6 @@ async def test_list_certificate_revocation_lists_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListCertificateRevocationListsResponse() ) - await client.list_certificate_revocation_lists(request) # Establish that the underlying gRPC stub method was called. @@ -6471,7 +6194,7 @@ async def test_list_certificate_revocation_lists_field_headers_async(): def test_list_certificate_revocation_lists_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6480,7 +6203,6 @@ def test_list_certificate_revocation_lists_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListCertificateRevocationListsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_certificate_revocation_lists(parent="parent_value",) @@ -6489,13 +6211,12 @@ def test_list_certificate_revocation_lists_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_certificate_revocation_lists_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6509,7 +6230,7 @@ def test_list_certificate_revocation_lists_flattened_error(): @pytest.mark.asyncio async def test_list_certificate_revocation_lists_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6532,14 +6253,13 @@ async def test_list_certificate_revocation_lists_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_certificate_revocation_lists_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6552,7 +6272,7 @@ async def test_list_certificate_revocation_lists_flattened_error_async(): def test_list_certificate_revocation_lists_pager(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6600,7 +6320,7 @@ def test_list_certificate_revocation_lists_pager(): def test_list_certificate_revocation_lists_pages(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6640,7 +6360,7 @@ def test_list_certificate_revocation_lists_pages(): @pytest.mark.asyncio async def test_list_certificate_revocation_lists_async_pager(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6689,7 +6409,7 @@ async def test_list_certificate_revocation_lists_async_pager(): @pytest.mark.asyncio async def test_list_certificate_revocation_lists_async_pages(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6736,7 +6456,7 @@ def test_update_certificate_revocation_list( transport: str = "grpc", request_type=service.UpdateCertificateRevocationListRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6749,13 +6469,11 @@ def test_update_certificate_revocation_list( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRevocationListRequest() # Establish that the response is the type that we expect. @@ -6770,7 +6488,7 @@ def test_update_certificate_revocation_list_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6780,7 +6498,6 @@ def test_update_certificate_revocation_list_empty_call(): client.update_certificate_revocation_list() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRevocationListRequest() @@ -6790,7 +6507,7 @@ async def test_update_certificate_revocation_list_async( request_type=service.UpdateCertificateRevocationListRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6805,13 +6522,11 @@ async def test_update_certificate_revocation_list_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRevocationListRequest() # Establish that the response is the type that we expect. @@ -6825,12 +6540,13 @@ async def test_update_certificate_revocation_list_async_from_dict(): def test_update_certificate_revocation_list_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateRevocationListRequest() + request.certificate_revocation_list.name = "certificate_revocation_list.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6838,7 +6554,6 @@ def test_update_certificate_revocation_list_field_headers(): type(client.transport.update_certificate_revocation_list), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. @@ -6857,12 +6572,13 @@ def test_update_certificate_revocation_list_field_headers(): @pytest.mark.asyncio async def test_update_certificate_revocation_list_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateRevocationListRequest() + request.certificate_revocation_list.name = "certificate_revocation_list.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6872,7 +6588,6 @@ async def test_update_certificate_revocation_list_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. @@ -6890,7 +6605,7 @@ async def test_update_certificate_revocation_list_field_headers_async(): def test_update_certificate_revocation_list_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6899,33 +6614,30 @@ def test_update_certificate_revocation_list_flattened(): ) 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_revocation_list( certificate_revocation_list=resources.CertificateRevocationList( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[ 0 ].certificate_revocation_list == resources.CertificateRevocationList( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_certificate_revocation_list_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6936,14 +6648,14 @@ def test_update_certificate_revocation_list_flattened_error(): certificate_revocation_list=resources.CertificateRevocationList( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_certificate_revocation_list_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6962,27 +6674,25 @@ async def test_update_certificate_revocation_list_flattened_async(): certificate_revocation_list=resources.CertificateRevocationList( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[ 0 ].certificate_revocation_list == resources.CertificateRevocationList( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_certificate_revocation_list_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6993,7 +6703,7 @@ async def test_update_certificate_revocation_list_flattened_error_async(): certificate_revocation_list=resources.CertificateRevocationList( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -7001,7 +6711,7 @@ def test_create_certificate_template( transport: str = "grpc", request_type=service.CreateCertificateTemplateRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7014,13 +6724,11 @@ def test_create_certificate_template( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_certificate_template(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateTemplateRequest() # Establish that the response is the type that we expect. @@ -7035,7 +6743,7 @@ def test_create_certificate_template_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7045,7 +6753,6 @@ def test_create_certificate_template_empty_call(): client.create_certificate_template() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateTemplateRequest() @@ -7055,7 +6762,7 @@ async def test_create_certificate_template_async( request_type=service.CreateCertificateTemplateRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7070,13 +6777,11 @@ async def test_create_certificate_template_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_certificate_template(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateTemplateRequest() # Establish that the response is the type that we expect. @@ -7090,12 +6795,13 @@ async def test_create_certificate_template_async_from_dict(): def test_create_certificate_template_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateCertificateTemplateRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7103,7 +6809,6 @@ def test_create_certificate_template_field_headers(): type(client.transport.create_certificate_template), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_certificate_template(request) # Establish that the underlying gRPC stub method was called. @@ -7119,12 +6824,13 @@ def test_create_certificate_template_field_headers(): @pytest.mark.asyncio async def test_create_certificate_template_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateCertificateTemplateRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7134,7 +6840,6 @@ async def test_create_certificate_template_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_certificate_template(request) # Establish that the underlying gRPC stub method was called. @@ -7149,7 +6854,7 @@ async def test_create_certificate_template_field_headers_async(): def test_create_certificate_template_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7158,7 +6863,6 @@ def test_create_certificate_template_flattened(): ) 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_template( @@ -7171,19 +6875,16 @@ def test_create_certificate_template_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].certificate_template == resources.CertificateTemplate( name="name_value" ) - assert args[0].certificate_template_id == "certificate_template_id_value" def test_create_certificate_template_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7200,7 +6901,7 @@ def test_create_certificate_template_flattened_error(): @pytest.mark.asyncio async def test_create_certificate_template_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7225,20 +6926,17 @@ async def test_create_certificate_template_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].certificate_template == resources.CertificateTemplate( name="name_value" ) - assert args[0].certificate_template_id == "certificate_template_id_value" @pytest.mark.asyncio async def test_create_certificate_template_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7256,7 +6954,7 @@ def test_delete_certificate_template( transport: str = "grpc", request_type=service.DeleteCertificateTemplateRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7269,13 +6967,11 @@ def test_delete_certificate_template( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_certificate_template(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCertificateTemplateRequest() # Establish that the response is the type that we expect. @@ -7290,7 +6986,7 @@ def test_delete_certificate_template_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7300,7 +6996,6 @@ def test_delete_certificate_template_empty_call(): client.delete_certificate_template() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCertificateTemplateRequest() @@ -7310,7 +7005,7 @@ async def test_delete_certificate_template_async( request_type=service.DeleteCertificateTemplateRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7325,13 +7020,11 @@ async def test_delete_certificate_template_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_certificate_template(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCertificateTemplateRequest() # Establish that the response is the type that we expect. @@ -7345,12 +7038,13 @@ async def test_delete_certificate_template_async_from_dict(): def test_delete_certificate_template_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DeleteCertificateTemplateRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7358,7 +7052,6 @@ def test_delete_certificate_template_field_headers(): type(client.transport.delete_certificate_template), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_certificate_template(request) # Establish that the underlying gRPC stub method was called. @@ -7374,12 +7067,13 @@ def test_delete_certificate_template_field_headers(): @pytest.mark.asyncio async def test_delete_certificate_template_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DeleteCertificateTemplateRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7389,7 +7083,6 @@ async def test_delete_certificate_template_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_certificate_template(request) # Establish that the underlying gRPC stub method was called. @@ -7404,7 +7097,7 @@ async def test_delete_certificate_template_field_headers_async(): def test_delete_certificate_template_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7413,7 +7106,6 @@ def test_delete_certificate_template_flattened(): ) 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_template(name="name_value",) @@ -7422,13 +7114,12 @@ def test_delete_certificate_template_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_certificate_template_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7442,7 +7133,7 @@ def test_delete_certificate_template_flattened_error(): @pytest.mark.asyncio async def test_delete_certificate_template_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7463,14 +7154,13 @@ async def test_delete_certificate_template_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_certificate_template_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7485,7 +7175,7 @@ def test_get_certificate_template( transport: str = "grpc", request_type=service.GetCertificateTemplateRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7500,21 +7190,16 @@ def test_get_certificate_template( call.return_value = resources.CertificateTemplate( name="name_value", description="description_value", ) - response = client.get_certificate_template(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateTemplateRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateTemplate) - assert response.name == "name_value" - assert response.description == "description_value" @@ -7526,7 +7211,7 @@ def test_get_certificate_template_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7536,7 +7221,6 @@ def test_get_certificate_template_empty_call(): client.get_certificate_template() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateTemplateRequest() @@ -7545,7 +7229,7 @@ async def test_get_certificate_template_async( transport: str = "grpc_asyncio", request_type=service.GetCertificateTemplateRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7562,20 +7246,16 @@ async def test_get_certificate_template_async( name="name_value", description="description_value", ) ) - response = await client.get_certificate_template(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateTemplateRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.CertificateTemplate) - assert response.name == "name_value" - assert response.description == "description_value" @@ -7586,12 +7266,13 @@ async def test_get_certificate_template_async_from_dict(): def test_get_certificate_template_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCertificateTemplateRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7599,7 +7280,6 @@ def test_get_certificate_template_field_headers(): type(client.transport.get_certificate_template), "__call__" ) as call: call.return_value = resources.CertificateTemplate() - client.get_certificate_template(request) # Establish that the underlying gRPC stub method was called. @@ -7615,12 +7295,13 @@ def test_get_certificate_template_field_headers(): @pytest.mark.asyncio async def test_get_certificate_template_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCertificateTemplateRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7630,7 +7311,6 @@ async def test_get_certificate_template_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.CertificateTemplate() ) - await client.get_certificate_template(request) # Establish that the underlying gRPC stub method was called. @@ -7645,7 +7325,7 @@ async def test_get_certificate_template_field_headers_async(): def test_get_certificate_template_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7654,7 +7334,6 @@ def test_get_certificate_template_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.CertificateTemplate() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_certificate_template(name="name_value",) @@ -7663,13 +7342,12 @@ def test_get_certificate_template_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_certificate_template_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7683,7 +7361,7 @@ def test_get_certificate_template_flattened_error(): @pytest.mark.asyncio async def test_get_certificate_template_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7704,14 +7382,13 @@ async def test_get_certificate_template_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_certificate_template_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7726,7 +7403,7 @@ def test_list_certificate_templates( transport: str = "grpc", request_type=service.ListCertificateTemplatesRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7741,21 +7418,16 @@ def test_list_certificate_templates( call.return_value = service.ListCertificateTemplatesResponse( next_page_token="next_page_token_value", unreachable=["unreachable_value"], ) - response = client.list_certificate_templates(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateTemplatesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateTemplatesPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -7767,7 +7439,7 @@ def test_list_certificate_templates_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7777,7 +7449,6 @@ def test_list_certificate_templates_empty_call(): client.list_certificate_templates() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateTemplatesRequest() @@ -7787,7 +7458,7 @@ async def test_list_certificate_templates_async( request_type=service.ListCertificateTemplatesRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7805,20 +7476,16 @@ async def test_list_certificate_templates_async( unreachable=["unreachable_value"], ) ) - response = await client.list_certificate_templates(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateTemplatesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListCertificateTemplatesAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -7829,12 +7496,13 @@ async def test_list_certificate_templates_async_from_dict(): def test_list_certificate_templates_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificateTemplatesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7842,7 +7510,6 @@ def test_list_certificate_templates_field_headers(): type(client.transport.list_certificate_templates), "__call__" ) as call: call.return_value = service.ListCertificateTemplatesResponse() - client.list_certificate_templates(request) # Establish that the underlying gRPC stub method was called. @@ -7858,12 +7525,13 @@ def test_list_certificate_templates_field_headers(): @pytest.mark.asyncio async def test_list_certificate_templates_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificateTemplatesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7873,7 +7541,6 @@ async def test_list_certificate_templates_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListCertificateTemplatesResponse() ) - await client.list_certificate_templates(request) # Establish that the underlying gRPC stub method was called. @@ -7888,7 +7555,7 @@ async def test_list_certificate_templates_field_headers_async(): def test_list_certificate_templates_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7897,7 +7564,6 @@ def test_list_certificate_templates_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListCertificateTemplatesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_certificate_templates(parent="parent_value",) @@ -7906,13 +7572,12 @@ def test_list_certificate_templates_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_certificate_templates_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7926,7 +7591,7 @@ def test_list_certificate_templates_flattened_error(): @pytest.mark.asyncio async def test_list_certificate_templates_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7947,14 +7612,13 @@ async def test_list_certificate_templates_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_certificate_templates_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7967,7 +7631,7 @@ async def test_list_certificate_templates_flattened_error_async(): def test_list_certificate_templates_pager(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8015,7 +7679,7 @@ def test_list_certificate_templates_pager(): def test_list_certificate_templates_pages(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8055,7 +7719,7 @@ def test_list_certificate_templates_pages(): @pytest.mark.asyncio async def test_list_certificate_templates_async_pager(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8102,7 +7766,7 @@ async def test_list_certificate_templates_async_pager(): @pytest.mark.asyncio async def test_list_certificate_templates_async_pages(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8147,7 +7811,7 @@ def test_update_certificate_template( transport: str = "grpc", request_type=service.UpdateCertificateTemplateRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -8160,13 +7824,11 @@ def test_update_certificate_template( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_certificate_template(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateTemplateRequest() # Establish that the response is the type that we expect. @@ -8181,7 +7843,7 @@ def test_update_certificate_template_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8191,7 +7853,6 @@ def test_update_certificate_template_empty_call(): client.update_certificate_template() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateTemplateRequest() @@ -8201,7 +7862,7 @@ async def test_update_certificate_template_async( request_type=service.UpdateCertificateTemplateRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -8216,13 +7877,11 @@ async def test_update_certificate_template_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_certificate_template(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateTemplateRequest() # Establish that the response is the type that we expect. @@ -8236,12 +7895,13 @@ async def test_update_certificate_template_async_from_dict(): def test_update_certificate_template_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateTemplateRequest() + request.certificate_template.name = "certificate_template.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -8249,7 +7909,6 @@ def test_update_certificate_template_field_headers(): type(client.transport.update_certificate_template), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_certificate_template(request) # Establish that the underlying gRPC stub method was called. @@ -8268,12 +7927,13 @@ def test_update_certificate_template_field_headers(): @pytest.mark.asyncio async def test_update_certificate_template_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateTemplateRequest() + request.certificate_template.name = "certificate_template.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -8283,7 +7943,6 @@ async def test_update_certificate_template_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_certificate_template(request) # Establish that the underlying gRPC stub method was called. @@ -8301,7 +7960,7 @@ async def test_update_certificate_template_field_headers_async(): def test_update_certificate_template_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8310,29 +7969,26 @@ def test_update_certificate_template_flattened(): ) 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_template( certificate_template=resources.CertificateTemplate(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].certificate_template == resources.CertificateTemplate( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_certificate_template_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -8341,14 +7997,14 @@ def test_update_certificate_template_flattened_error(): client.update_certificate_template( service.UpdateCertificateTemplateRequest(), certificate_template=resources.CertificateTemplate(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_certificate_template_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8365,25 +8021,23 @@ async def test_update_certificate_template_flattened_async(): # using the keyword arguments to the method. response = await client.update_certificate_template( certificate_template=resources.CertificateTemplate(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].certificate_template == resources.CertificateTemplate( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_certificate_template_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -8392,23 +8046,23 @@ async def test_update_certificate_template_flattened_error_async(): await client.update_certificate_template( service.UpdateCertificateTemplateRequest(), certificate_template=resources.CertificateTemplate(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = CertificateAuthorityServiceClient( @@ -8418,7 +8072,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = CertificateAuthorityServiceClient( @@ -8429,7 +8083,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = CertificateAuthorityServiceClient(transport=transport) assert client.transport is transport @@ -8438,13 +8092,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.CertificateAuthorityServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -8459,8 +8113,8 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() @@ -8468,7 +8122,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( client.transport, transports.CertificateAuthorityServiceGrpcTransport, @@ -8477,9 +8131,9 @@ def test_transport_grpc_default(): def test_certificate_authority_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.CertificateAuthorityServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -8491,7 +8145,7 @@ def test_certificate_authority_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.CertificateAuthorityServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -8537,15 +8191,37 @@ def test_certificate_authority_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_certificate_authority_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CertificateAuthorityServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_certificate_authority_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CertificateAuthorityServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -8558,19 +8234,33 @@ def test_certificate_authority_service_base_transport_with_credentials_file(): def test_certificate_authority_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.security.privateca_v1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CertificateAuthorityServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_certificate_authority_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + CertificateAuthorityServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_certificate_authority_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) CertificateAuthorityServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -8578,20 +8268,169 @@ def test_certificate_authority_service_auth_adc(): ) -def test_certificate_authority_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.CertificateAuthorityServiceGrpcTransport, + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_certificate_authority_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.CertificateAuthorityServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + 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.CertificateAuthorityServiceGrpcTransport, + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_certificate_authority_service_transport_auth_adc_old_google_auth( + transport_class, +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), + ( + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + grpc_helpers_async, + ), + ], +) +@requires_api_core_gte_1_26_0 +def test_certificate_authority_service_transport_create_channel( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "privateca.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="privateca.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), + ( + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + grpc_helpers_async, + ), + ], +) +@requires_api_core_lt_1_26_0 +def test_certificate_authority_service_transport_create_channel_old_api_core( + 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") + + create_channel.assert_called_with( + "privateca.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), + ( + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + grpc_helpers_async, + ), + ], +) +@requires_api_core_lt_1_26_0 +def test_certificate_authority_service_transport_create_channel_user_scopes( + 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( + "privateca.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -8602,7 +8441,7 @@ def test_certificate_authority_service_transport_auth_adc(): def test_certificate_authority_service_grpc_transport_client_cert_source_for_mtls( transport_class, ): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -8641,7 +8480,7 @@ def test_certificate_authority_service_grpc_transport_client_cert_source_for_mtl def test_certificate_authority_service_host_no_port(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="privateca.googleapis.com" ), @@ -8651,7 +8490,7 @@ def test_certificate_authority_service_host_no_port(): def test_certificate_authority_service_host_with_port(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="privateca.googleapis.com:8000" ), @@ -8707,9 +8546,9 @@ def test_certificate_authority_service_transport_channel_mtls_with_client_cert_s mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -8785,7 +8624,7 @@ def test_certificate_authority_service_transport_channel_mtls_with_adc(transport def test_certificate_authority_service_grpc_lro_client(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -8798,7 +8637,7 @@ def test_certificate_authority_service_grpc_lro_client(): def test_certificate_authority_service_grpc_lro_async_client(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -8813,7 +8652,6 @@ 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, ) @@ -8839,7 +8677,6 @@ def test_certificate_path(): location = "mussel" ca_pool = "winkle" certificate = "nautilus" - expected = "projects/{project}/locations/{location}/caPools/{ca_pool}/certificates/{certificate}".format( project=project, location=location, ca_pool=ca_pool, certificate=certificate, ) @@ -8868,7 +8705,6 @@ def test_certificate_authority_path(): location = "octopus" ca_pool = "oyster" certificate_authority = "nudibranch" - expected = "projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}".format( project=project, location=location, @@ -8901,7 +8737,6 @@ def test_certificate_revocation_list_path(): ca_pool = "squid" certificate_authority = "clam" certificate_revocation_list = "whelk" - expected = "projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list}".format( project=project, location=location, @@ -8938,7 +8773,6 @@ def test_certificate_template_path(): project = "winkle" location = "nautilus" certificate_template = "scallop" - expected = "projects/{project}/locations/{location}/certificateTemplates/{certificate_template}".format( project=project, location=location, certificate_template=certificate_template, ) @@ -8963,7 +8797,6 @@ def test_parse_certificate_template_path(): def test_common_billing_account_path(): billing_account = "whelk" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -8986,7 +8819,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) actual = CertificateAuthorityServiceClient.common_folder_path(folder) assert expected == actual @@ -9005,7 +8837,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) actual = CertificateAuthorityServiceClient.common_organization_path(organization) assert expected == actual @@ -9024,7 +8855,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) actual = CertificateAuthorityServiceClient.common_project_path(project) assert expected == actual @@ -9044,7 +8874,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "scallop" location = "abalone" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -9071,7 +8900,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.CertificateAuthorityServiceTransport, "_prep_wrapped_messages" ) as prep: client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -9080,6 +8909,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = CertificateAuthorityServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/privateca_v1beta1/__init__.py b/tests/unit/gapic/privateca_v1beta1/__init__.py index 42ffdf2..4de6597 100644 --- a/tests/unit/gapic/privateca_v1beta1/__init__.py +++ b/tests/unit/gapic/privateca_v1beta1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py b/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py index 95f86bf..e0f948a 100644 --- a/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py +++ b/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 -from google.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import ( CertificateAuthorityServiceAsyncClient, @@ -47,14 +46,44 @@ from google.cloud.security.privateca_v1beta1.services.certificate_authority_service import ( transports, ) +from google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.security.privateca_v1beta1.types import resources from google.cloud.security.privateca_v1beta1.types import service from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -109,7 +138,7 @@ def test__get_default_mtls_endpoint(): [CertificateAuthorityServiceClient, CertificateAuthorityServiceAsyncClient,], ) def test_certificate_authority_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -127,7 +156,7 @@ def test_certificate_authority_service_client_from_service_account_info(client_c [CertificateAuthorityServiceClient, CertificateAuthorityServiceAsyncClient,], ) def test_certificate_authority_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -186,7 +215,7 @@ def test_certificate_authority_service_client_client_options( with mock.patch.object( CertificateAuthorityServiceClient, "get_transport_class" ) as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -494,7 +523,7 @@ def test_create_certificate( transport: str = "grpc", request_type=service.CreateCertificateRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -512,23 +541,17 @@ def test_create_certificate( pem_certificate_chain=["pem_certificate_chain_value"], pem_csr="pem_csr_value", ) - 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] == service.CreateCertificateRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -540,7 +563,7 @@ 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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -550,7 +573,6 @@ def test_create_certificate_empty_call(): client.create_certificate() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateRequest() @@ -559,7 +581,7 @@ async def test_create_certificate_async( transport: str = "grpc_asyncio", request_type=service.CreateCertificateRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -578,22 +600,17 @@ async def test_create_certificate_async( pem_certificate_chain=["pem_certificate_chain_value"], ) ) - 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] == service.CreateCertificateRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -604,12 +621,13 @@ async def test_create_certificate_async_from_dict(): def test_create_certificate_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateCertificateRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -617,7 +635,6 @@ def test_create_certificate_field_headers(): type(client.transport.create_certificate), "__call__" ) as call: call.return_value = resources.Certificate() - client.create_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -633,12 +650,13 @@ def test_create_certificate_field_headers(): @pytest.mark.asyncio async def test_create_certificate_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateCertificateRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -648,7 +666,6 @@ async def test_create_certificate_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Certificate() ) - await client.create_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -663,7 +680,7 @@ async def test_create_certificate_field_headers_async(): def test_create_certificate_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -672,7 +689,6 @@ def test_create_certificate_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.Certificate() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_certificate( @@ -685,17 +701,14 @@ def test_create_certificate_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].certificate == resources.Certificate(name="name_value") - assert args[0].certificate_id == "certificate_id_value" def test_create_certificate_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -712,7 +725,7 @@ def test_create_certificate_flattened_error(): @pytest.mark.asyncio async def test_create_certificate_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -737,18 +750,15 @@ async def test_create_certificate_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].certificate == resources.Certificate(name="name_value") - assert args[0].certificate_id == "certificate_id_value" @pytest.mark.asyncio async def test_create_certificate_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -766,7 +776,7 @@ def test_get_certificate( transport: str = "grpc", request_type=service.GetCertificateRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -782,23 +792,17 @@ def test_get_certificate( pem_certificate_chain=["pem_certificate_chain_value"], pem_csr="pem_csr_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] == service.GetCertificateRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -810,7 +814,7 @@ 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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -818,7 +822,6 @@ def test_get_certificate_empty_call(): client.get_certificate() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRequest() @@ -827,7 +830,7 @@ async def test_get_certificate_async( transport: str = "grpc_asyncio", request_type=service.GetCertificateRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -844,22 +847,17 @@ async def test_get_certificate_async( pem_certificate_chain=["pem_certificate_chain_value"], ) ) - 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] == service.GetCertificateRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -870,18 +868,18 @@ async def test_get_certificate_async_from_dict(): def test_get_certificate_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.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 = resources.Certificate() - client.get_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -897,12 +895,13 @@ def test_get_certificate_field_headers(): @pytest.mark.asyncio async def test_get_certificate_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCertificateRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -910,7 +909,6 @@ async def test_get_certificate_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Certificate() ) - await client.get_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -925,14 +923,13 @@ async def test_get_certificate_field_headers_async(): def test_get_certificate_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + 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 = resources.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",) @@ -941,13 +938,12 @@ def test_get_certificate_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_certificate_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -961,7 +957,7 @@ def test_get_certificate_flattened_error(): @pytest.mark.asyncio async def test_get_certificate_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -980,14 +976,13 @@ async def test_get_certificate_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_certificate_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1002,7 +997,7 @@ def test_list_certificates( transport: str = "grpc", request_type=service.ListCertificatesRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1017,21 +1012,16 @@ def test_list_certificates( call.return_value = service.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] == service.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"] @@ -1043,7 +1033,7 @@ 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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1053,7 +1043,6 @@ def test_list_certificates_empty_call(): client.list_certificates() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificatesRequest() @@ -1062,7 +1051,7 @@ async def test_list_certificates_async( transport: str = "grpc_asyncio", request_type=service.ListCertificatesRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1080,20 +1069,16 @@ async def test_list_certificates_async( 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] == service.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"] @@ -1104,12 +1089,13 @@ async def test_list_certificates_async_from_dict(): def test_list_certificates_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificatesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1117,7 +1103,6 @@ def test_list_certificates_field_headers(): type(client.transport.list_certificates), "__call__" ) as call: call.return_value = service.ListCertificatesResponse() - client.list_certificates(request) # Establish that the underlying gRPC stub method was called. @@ -1133,12 +1118,13 @@ def test_list_certificates_field_headers(): @pytest.mark.asyncio async def test_list_certificates_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificatesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1148,7 +1134,6 @@ async def test_list_certificates_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListCertificatesResponse() ) - await client.list_certificates(request) # Establish that the underlying gRPC stub method was called. @@ -1163,7 +1148,7 @@ async def test_list_certificates_field_headers_async(): def test_list_certificates_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1172,7 +1157,6 @@ def test_list_certificates_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = service.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",) @@ -1181,13 +1165,12 @@ def test_list_certificates_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_certificates_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1201,7 +1184,7 @@ def test_list_certificates_flattened_error(): @pytest.mark.asyncio async def test_list_certificates_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1222,14 +1205,13 @@ async def test_list_certificates_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_certificates_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1242,7 +1224,7 @@ async def test_list_certificates_flattened_error_async(): def test_list_certificates_pager(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1284,7 +1266,7 @@ def test_list_certificates_pager(): def test_list_certificates_pages(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1318,7 +1300,7 @@ def test_list_certificates_pages(): @pytest.mark.asyncio async def test_list_certificates_async_pager(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1359,7 +1341,7 @@ async def test_list_certificates_async_pager(): @pytest.mark.asyncio async def test_list_certificates_async_pages(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1398,7 +1380,7 @@ def test_revoke_certificate( transport: str = "grpc", request_type=service.RevokeCertificateRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1416,23 +1398,17 @@ def test_revoke_certificate( pem_certificate_chain=["pem_certificate_chain_value"], pem_csr="pem_csr_value", ) - response = client.revoke_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] == service.RevokeCertificateRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -1444,7 +1420,7 @@ def test_revoke_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1454,7 +1430,6 @@ def test_revoke_certificate_empty_call(): client.revoke_certificate() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.RevokeCertificateRequest() @@ -1463,7 +1438,7 @@ async def test_revoke_certificate_async( transport: str = "grpc_asyncio", request_type=service.RevokeCertificateRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1482,22 +1457,17 @@ async def test_revoke_certificate_async( pem_certificate_chain=["pem_certificate_chain_value"], ) ) - response = await client.revoke_certificate(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.RevokeCertificateRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -1508,12 +1478,13 @@ async def test_revoke_certificate_async_from_dict(): def test_revoke_certificate_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.RevokeCertificateRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1521,7 +1492,6 @@ def test_revoke_certificate_field_headers(): type(client.transport.revoke_certificate), "__call__" ) as call: call.return_value = resources.Certificate() - client.revoke_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -1537,12 +1507,13 @@ def test_revoke_certificate_field_headers(): @pytest.mark.asyncio async def test_revoke_certificate_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.RevokeCertificateRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1552,7 +1523,6 @@ async def test_revoke_certificate_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Certificate() ) - await client.revoke_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -1567,7 +1537,7 @@ async def test_revoke_certificate_field_headers_async(): def test_revoke_certificate_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1576,7 +1546,6 @@ def test_revoke_certificate_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.Certificate() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.revoke_certificate(name="name_value",) @@ -1585,13 +1554,12 @@ def test_revoke_certificate_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_revoke_certificate_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1605,7 +1573,7 @@ def test_revoke_certificate_flattened_error(): @pytest.mark.asyncio async def test_revoke_certificate_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1626,14 +1594,13 @@ async def test_revoke_certificate_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_revoke_certificate_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1648,7 +1615,7 @@ def test_update_certificate( transport: str = "grpc", request_type=service.UpdateCertificateRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1666,23 +1633,17 @@ def test_update_certificate( pem_certificate_chain=["pem_certificate_chain_value"], pem_csr="pem_csr_value", ) - 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] == service.UpdateCertificateRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -1694,7 +1655,7 @@ 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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1704,7 +1665,6 @@ def test_update_certificate_empty_call(): client.update_certificate() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRequest() @@ -1713,7 +1673,7 @@ async def test_update_certificate_async( transport: str = "grpc_asyncio", request_type=service.UpdateCertificateRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1732,22 +1692,17 @@ async def test_update_certificate_async( pem_certificate_chain=["pem_certificate_chain_value"], ) ) - 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] == service.UpdateCertificateRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Certificate) - assert response.name == "name_value" - assert response.pem_certificate == "pem_certificate_value" - assert response.pem_certificate_chain == ["pem_certificate_chain_value"] @@ -1758,12 +1713,13 @@ async def test_update_certificate_async_from_dict(): def test_update_certificate_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateRequest() + request.certificate.name = "certificate.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1771,7 +1727,6 @@ def test_update_certificate_field_headers(): type(client.transport.update_certificate), "__call__" ) as call: call.return_value = resources.Certificate() - client.update_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -1789,12 +1744,13 @@ def test_update_certificate_field_headers(): @pytest.mark.asyncio async def test_update_certificate_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateRequest() + request.certificate.name = "certificate.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1804,7 +1760,6 @@ async def test_update_certificate_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Certificate() ) - await client.update_certificate(request) # Establish that the underlying gRPC stub method was called. @@ -1821,7 +1776,7 @@ async def test_update_certificate_field_headers_async(): def test_update_certificate_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1830,27 +1785,24 @@ def test_update_certificate_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.Certificate() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_certificate( certificate=resources.Certificate(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].certificate == resources.Certificate(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_certificate_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1859,14 +1811,14 @@ def test_update_certificate_flattened_error(): client.update_certificate( service.UpdateCertificateRequest(), certificate=resources.Certificate(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_certificate_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1883,23 +1835,21 @@ async def test_update_certificate_flattened_async(): # using the keyword arguments to the method. response = await client.update_certificate( certificate=resources.Certificate(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].certificate == resources.Certificate(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_certificate_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1908,7 +1858,7 @@ async def test_update_certificate_flattened_error_async(): await client.update_certificate( service.UpdateCertificateRequest(), certificate=resources.Certificate(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1916,7 +1866,7 @@ def test_activate_certificate_authority( transport: str = "grpc", request_type=service.ActivateCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1929,13 +1879,11 @@ def test_activate_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.activate_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -1950,7 +1898,7 @@ def test_activate_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1960,7 +1908,6 @@ def test_activate_certificate_authority_empty_call(): client.activate_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateCertificateAuthorityRequest() @@ -1970,7 +1917,7 @@ async def test_activate_certificate_authority_async( request_type=service.ActivateCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1985,13 +1932,11 @@ async def test_activate_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.activate_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2005,12 +1950,13 @@ async def test_activate_certificate_authority_async_from_dict(): def test_activate_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ActivateCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2018,7 +1964,6 @@ def test_activate_certificate_authority_field_headers(): type(client.transport.activate_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.activate_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2034,12 +1979,13 @@ def test_activate_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_activate_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ActivateCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2049,7 +1995,6 @@ async def test_activate_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.activate_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2064,7 +2009,7 @@ async def test_activate_certificate_authority_field_headers_async(): def test_activate_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2073,7 +2018,6 @@ def test_activate_certificate_authority_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.activate_certificate_authority(name="name_value",) @@ -2082,13 +2026,12 @@ def test_activate_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_activate_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2102,7 +2045,7 @@ def test_activate_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_activate_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2123,14 +2066,13 @@ async def test_activate_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_activate_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2145,7 +2087,7 @@ def test_create_certificate_authority( transport: str = "grpc", request_type=service.CreateCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2158,13 +2100,11 @@ def test_create_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2179,7 +2119,7 @@ def test_create_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2189,7 +2129,6 @@ def test_create_certificate_authority_empty_call(): client.create_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateAuthorityRequest() @@ -2199,7 +2138,7 @@ async def test_create_certificate_authority_async( request_type=service.CreateCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2214,13 +2153,11 @@ async def test_create_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2234,12 +2171,13 @@ async def test_create_certificate_authority_async_from_dict(): def test_create_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateCertificateAuthorityRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2247,7 +2185,6 @@ def test_create_certificate_authority_field_headers(): type(client.transport.create_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2263,12 +2200,13 @@ def test_create_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_create_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.CreateCertificateAuthorityRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2278,7 +2216,6 @@ async def test_create_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2293,7 +2230,7 @@ async def test_create_certificate_authority_field_headers_async(): def test_create_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2302,7 +2239,6 @@ def test_create_certificate_authority_flattened(): ) 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_authority( @@ -2315,19 +2251,16 @@ def test_create_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].certificate_authority == resources.CertificateAuthority( name="name_value" ) - assert args[0].certificate_authority_id == "certificate_authority_id_value" def test_create_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2344,7 +2277,7 @@ def test_create_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_create_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2369,20 +2302,17 @@ async def test_create_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].certificate_authority == resources.CertificateAuthority( name="name_value" ) - assert args[0].certificate_authority_id == "certificate_authority_id_value" @pytest.mark.asyncio async def test_create_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2400,7 +2330,7 @@ def test_disable_certificate_authority( transport: str = "grpc", request_type=service.DisableCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2413,13 +2343,11 @@ def test_disable_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.disable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2434,7 +2362,7 @@ def test_disable_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2444,7 +2372,6 @@ def test_disable_certificate_authority_empty_call(): client.disable_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableCertificateAuthorityRequest() @@ -2454,7 +2381,7 @@ async def test_disable_certificate_authority_async( request_type=service.DisableCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2469,13 +2396,11 @@ async def test_disable_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.disable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.DisableCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2489,12 +2414,13 @@ async def test_disable_certificate_authority_async_from_dict(): def test_disable_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DisableCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2502,7 +2428,6 @@ def test_disable_certificate_authority_field_headers(): type(client.transport.disable_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.disable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2518,12 +2443,13 @@ def test_disable_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_disable_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.DisableCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2533,7 +2459,6 @@ async def test_disable_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.disable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2548,7 +2473,7 @@ async def test_disable_certificate_authority_field_headers_async(): def test_disable_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2557,7 +2482,6 @@ def test_disable_certificate_authority_flattened(): ) 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.disable_certificate_authority(name="name_value",) @@ -2566,13 +2490,12 @@ def test_disable_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_disable_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2586,7 +2509,7 @@ def test_disable_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_disable_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2607,14 +2530,13 @@ async def test_disable_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_disable_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2629,7 +2551,7 @@ def test_enable_certificate_authority( transport: str = "grpc", request_type=service.EnableCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2642,13 +2564,11 @@ def test_enable_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.enable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2663,7 +2583,7 @@ def test_enable_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2673,7 +2593,6 @@ def test_enable_certificate_authority_empty_call(): client.enable_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableCertificateAuthorityRequest() @@ -2683,7 +2602,7 @@ async def test_enable_certificate_authority_async( request_type=service.EnableCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2698,13 +2617,11 @@ async def test_enable_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.enable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.EnableCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -2718,12 +2635,13 @@ async def test_enable_certificate_authority_async_from_dict(): def test_enable_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.EnableCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2731,7 +2649,6 @@ def test_enable_certificate_authority_field_headers(): type(client.transport.enable_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.enable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2747,12 +2664,13 @@ def test_enable_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_enable_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.EnableCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2762,7 +2680,6 @@ async def test_enable_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.enable_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -2777,7 +2694,7 @@ async def test_enable_certificate_authority_field_headers_async(): def test_enable_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2786,7 +2703,6 @@ def test_enable_certificate_authority_flattened(): ) 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.enable_certificate_authority(name="name_value",) @@ -2795,13 +2711,12 @@ def test_enable_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_enable_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2815,7 +2730,7 @@ def test_enable_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_enable_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2836,14 +2751,13 @@ async def test_enable_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_enable_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2858,7 +2772,7 @@ def test_fetch_certificate_authority_csr( transport: str = "grpc", request_type=service.FetchCertificateAuthorityCsrRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2873,19 +2787,15 @@ def test_fetch_certificate_authority_csr( call.return_value = service.FetchCertificateAuthorityCsrResponse( pem_csr="pem_csr_value", ) - response = client.fetch_certificate_authority_csr(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCertificateAuthorityCsrRequest() # Establish that the response is the type that we expect. - assert isinstance(response, service.FetchCertificateAuthorityCsrResponse) - assert response.pem_csr == "pem_csr_value" @@ -2897,7 +2807,7 @@ def test_fetch_certificate_authority_csr_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2907,7 +2817,6 @@ def test_fetch_certificate_authority_csr_empty_call(): client.fetch_certificate_authority_csr() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCertificateAuthorityCsrRequest() @@ -2917,7 +2826,7 @@ async def test_fetch_certificate_authority_csr_async( request_type=service.FetchCertificateAuthorityCsrRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2932,18 +2841,15 @@ async def test_fetch_certificate_authority_csr_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.FetchCertificateAuthorityCsrResponse(pem_csr="pem_csr_value",) ) - response = await client.fetch_certificate_authority_csr(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.FetchCertificateAuthorityCsrRequest() # Establish that the response is the type that we expect. assert isinstance(response, service.FetchCertificateAuthorityCsrResponse) - assert response.pem_csr == "pem_csr_value" @@ -2954,12 +2860,13 @@ async def test_fetch_certificate_authority_csr_async_from_dict(): def test_fetch_certificate_authority_csr_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.FetchCertificateAuthorityCsrRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2967,7 +2874,6 @@ def test_fetch_certificate_authority_csr_field_headers(): type(client.transport.fetch_certificate_authority_csr), "__call__" ) as call: call.return_value = service.FetchCertificateAuthorityCsrResponse() - client.fetch_certificate_authority_csr(request) # Establish that the underlying gRPC stub method was called. @@ -2983,12 +2889,13 @@ def test_fetch_certificate_authority_csr_field_headers(): @pytest.mark.asyncio async def test_fetch_certificate_authority_csr_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.FetchCertificateAuthorityCsrRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2998,7 +2905,6 @@ async def test_fetch_certificate_authority_csr_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.FetchCertificateAuthorityCsrResponse() ) - await client.fetch_certificate_authority_csr(request) # Establish that the underlying gRPC stub method was called. @@ -3013,7 +2919,7 @@ async def test_fetch_certificate_authority_csr_field_headers_async(): def test_fetch_certificate_authority_csr_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3022,7 +2928,6 @@ def test_fetch_certificate_authority_csr_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = service.FetchCertificateAuthorityCsrResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.fetch_certificate_authority_csr(name="name_value",) @@ -3031,13 +2936,12 @@ def test_fetch_certificate_authority_csr_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_fetch_certificate_authority_csr_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3051,7 +2955,7 @@ def test_fetch_certificate_authority_csr_flattened_error(): @pytest.mark.asyncio async def test_fetch_certificate_authority_csr_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3072,14 +2976,13 @@ async def test_fetch_certificate_authority_csr_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_fetch_certificate_authority_csr_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3094,7 +2997,7 @@ def test_get_certificate_authority( transport: str = "grpc", request_type=service.GetCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3114,29 +3017,20 @@ def test_get_certificate_authority( pem_ca_certificates=["pem_ca_certificates_value"], gcs_bucket="gcs_bucket_value", ) - response = client.get_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateAuthorityRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateAuthority) - assert response.name == "name_value" - assert response.type_ == resources.CertificateAuthority.Type.SELF_SIGNED - assert response.tier == resources.CertificateAuthority.Tier.ENTERPRISE - assert response.state == resources.CertificateAuthority.State.ENABLED - assert response.pem_ca_certificates == ["pem_ca_certificates_value"] - assert response.gcs_bucket == "gcs_bucket_value" @@ -3148,7 +3042,7 @@ def test_get_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3158,7 +3052,6 @@ def test_get_certificate_authority_empty_call(): client.get_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateAuthorityRequest() @@ -3167,7 +3060,7 @@ async def test_get_certificate_authority_async( transport: str = "grpc_asyncio", request_type=service.GetCertificateAuthorityRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3189,28 +3082,20 @@ async def test_get_certificate_authority_async( gcs_bucket="gcs_bucket_value", ) ) - response = await client.get_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateAuthorityRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.CertificateAuthority) - assert response.name == "name_value" - assert response.type_ == resources.CertificateAuthority.Type.SELF_SIGNED - assert response.tier == resources.CertificateAuthority.Tier.ENTERPRISE - assert response.state == resources.CertificateAuthority.State.ENABLED - assert response.pem_ca_certificates == ["pem_ca_certificates_value"] - assert response.gcs_bucket == "gcs_bucket_value" @@ -3221,12 +3106,13 @@ async def test_get_certificate_authority_async_from_dict(): def test_get_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3234,7 +3120,6 @@ def test_get_certificate_authority_field_headers(): type(client.transport.get_certificate_authority), "__call__" ) as call: call.return_value = resources.CertificateAuthority() - client.get_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -3250,12 +3135,13 @@ def test_get_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_get_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3265,7 +3151,6 @@ async def test_get_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.CertificateAuthority() ) - await client.get_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -3280,7 +3165,7 @@ async def test_get_certificate_authority_field_headers_async(): def test_get_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3289,7 +3174,6 @@ def test_get_certificate_authority_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.CertificateAuthority() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_certificate_authority(name="name_value",) @@ -3298,13 +3182,12 @@ def test_get_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3318,7 +3201,7 @@ def test_get_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_get_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3339,14 +3222,13 @@ async def test_get_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3361,7 +3243,7 @@ def test_list_certificate_authorities( transport: str = "grpc", request_type=service.ListCertificateAuthoritiesRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3376,21 +3258,16 @@ def test_list_certificate_authorities( call.return_value = service.ListCertificateAuthoritiesResponse( next_page_token="next_page_token_value", unreachable=["unreachable_value"], ) - response = client.list_certificate_authorities(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateAuthoritiesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateAuthoritiesPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -3402,7 +3279,7 @@ def test_list_certificate_authorities_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3412,7 +3289,6 @@ def test_list_certificate_authorities_empty_call(): client.list_certificate_authorities() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateAuthoritiesRequest() @@ -3422,7 +3298,7 @@ async def test_list_certificate_authorities_async( request_type=service.ListCertificateAuthoritiesRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3440,20 +3316,16 @@ async def test_list_certificate_authorities_async( unreachable=["unreachable_value"], ) ) - response = await client.list_certificate_authorities(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateAuthoritiesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListCertificateAuthoritiesAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -3464,12 +3336,13 @@ async def test_list_certificate_authorities_async_from_dict(): def test_list_certificate_authorities_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificateAuthoritiesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3477,7 +3350,6 @@ def test_list_certificate_authorities_field_headers(): type(client.transport.list_certificate_authorities), "__call__" ) as call: call.return_value = service.ListCertificateAuthoritiesResponse() - client.list_certificate_authorities(request) # Establish that the underlying gRPC stub method was called. @@ -3493,12 +3365,13 @@ def test_list_certificate_authorities_field_headers(): @pytest.mark.asyncio async def test_list_certificate_authorities_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificateAuthoritiesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3508,7 +3381,6 @@ async def test_list_certificate_authorities_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListCertificateAuthoritiesResponse() ) - await client.list_certificate_authorities(request) # Establish that the underlying gRPC stub method was called. @@ -3523,7 +3395,7 @@ async def test_list_certificate_authorities_field_headers_async(): def test_list_certificate_authorities_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3532,7 +3404,6 @@ def test_list_certificate_authorities_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListCertificateAuthoritiesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_certificate_authorities(parent="parent_value",) @@ -3541,13 +3412,12 @@ def test_list_certificate_authorities_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_certificate_authorities_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3561,7 +3431,7 @@ def test_list_certificate_authorities_flattened_error(): @pytest.mark.asyncio async def test_list_certificate_authorities_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3582,14 +3452,13 @@ async def test_list_certificate_authorities_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_certificate_authorities_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3602,7 +3471,7 @@ async def test_list_certificate_authorities_flattened_error_async(): def test_list_certificate_authorities_pager(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3650,7 +3519,7 @@ def test_list_certificate_authorities_pager(): def test_list_certificate_authorities_pages(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3690,7 +3559,7 @@ def test_list_certificate_authorities_pages(): @pytest.mark.asyncio async def test_list_certificate_authorities_async_pager(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3737,7 +3606,7 @@ async def test_list_certificate_authorities_async_pager(): @pytest.mark.asyncio async def test_list_certificate_authorities_async_pages(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3784,7 +3653,7 @@ def test_restore_certificate_authority( transport: str = "grpc", request_type=service.RestoreCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3797,13 +3666,11 @@ def test_restore_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.restore_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.RestoreCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -3818,7 +3685,7 @@ def test_restore_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3828,7 +3695,6 @@ def test_restore_certificate_authority_empty_call(): client.restore_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.RestoreCertificateAuthorityRequest() @@ -3838,7 +3704,7 @@ async def test_restore_certificate_authority_async( request_type=service.RestoreCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3853,13 +3719,11 @@ async def test_restore_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.restore_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.RestoreCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -3873,12 +3737,13 @@ async def test_restore_certificate_authority_async_from_dict(): def test_restore_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.RestoreCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3886,7 +3751,6 @@ def test_restore_certificate_authority_field_headers(): type(client.transport.restore_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.restore_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -3902,12 +3766,13 @@ def test_restore_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_restore_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.RestoreCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3917,7 +3782,6 @@ async def test_restore_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.restore_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -3932,7 +3796,7 @@ async def test_restore_certificate_authority_field_headers_async(): def test_restore_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3941,7 +3805,6 @@ def test_restore_certificate_authority_flattened(): ) 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.restore_certificate_authority(name="name_value",) @@ -3950,13 +3813,12 @@ def test_restore_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_restore_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3970,7 +3832,7 @@ def test_restore_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_restore_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3991,14 +3853,13 @@ async def test_restore_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_restore_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4014,7 +3875,7 @@ def test_schedule_delete_certificate_authority( request_type=service.ScheduleDeleteCertificateAuthorityRequest, ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4027,13 +3888,11 @@ def test_schedule_delete_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.schedule_delete_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.ScheduleDeleteCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -4048,7 +3907,7 @@ def test_schedule_delete_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4058,7 +3917,6 @@ def test_schedule_delete_certificate_authority_empty_call(): client.schedule_delete_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ScheduleDeleteCertificateAuthorityRequest() @@ -4068,7 +3926,7 @@ async def test_schedule_delete_certificate_authority_async( request_type=service.ScheduleDeleteCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4083,13 +3941,11 @@ async def test_schedule_delete_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.schedule_delete_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.ScheduleDeleteCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -4103,12 +3959,13 @@ async def test_schedule_delete_certificate_authority_async_from_dict(): def test_schedule_delete_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ScheduleDeleteCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4116,7 +3973,6 @@ def test_schedule_delete_certificate_authority_field_headers(): type(client.transport.schedule_delete_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.schedule_delete_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -4132,12 +3988,13 @@ def test_schedule_delete_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_schedule_delete_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ScheduleDeleteCertificateAuthorityRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4147,7 +4004,6 @@ async def test_schedule_delete_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.schedule_delete_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -4162,7 +4018,7 @@ async def test_schedule_delete_certificate_authority_field_headers_async(): def test_schedule_delete_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4171,7 +4027,6 @@ def test_schedule_delete_certificate_authority_flattened(): ) 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.schedule_delete_certificate_authority(name="name_value",) @@ -4180,13 +4035,12 @@ def test_schedule_delete_certificate_authority_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_schedule_delete_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4200,7 +4054,7 @@ def test_schedule_delete_certificate_authority_flattened_error(): @pytest.mark.asyncio async def test_schedule_delete_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4223,14 +4077,13 @@ async def test_schedule_delete_certificate_authority_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_schedule_delete_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4245,7 +4098,7 @@ def test_update_certificate_authority( transport: str = "grpc", request_type=service.UpdateCertificateAuthorityRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4258,13 +4111,11 @@ def test_update_certificate_authority( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -4279,7 +4130,7 @@ def test_update_certificate_authority_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4289,7 +4140,6 @@ def test_update_certificate_authority_empty_call(): client.update_certificate_authority() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateAuthorityRequest() @@ -4299,7 +4149,7 @@ async def test_update_certificate_authority_async( request_type=service.UpdateCertificateAuthorityRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4314,13 +4164,11 @@ async def test_update_certificate_authority_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_certificate_authority(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateAuthorityRequest() # Establish that the response is the type that we expect. @@ -4334,12 +4182,13 @@ async def test_update_certificate_authority_async_from_dict(): def test_update_certificate_authority_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateAuthorityRequest() + request.certificate_authority.name = "certificate_authority.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4347,7 +4196,6 @@ def test_update_certificate_authority_field_headers(): type(client.transport.update_certificate_authority), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -4366,12 +4214,13 @@ def test_update_certificate_authority_field_headers(): @pytest.mark.asyncio async def test_update_certificate_authority_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateAuthorityRequest() + request.certificate_authority.name = "certificate_authority.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4381,7 +4230,6 @@ async def test_update_certificate_authority_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_certificate_authority(request) # Establish that the underlying gRPC stub method was called. @@ -4399,7 +4247,7 @@ async def test_update_certificate_authority_field_headers_async(): def test_update_certificate_authority_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4408,29 +4256,26 @@ def test_update_certificate_authority_flattened(): ) 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_authority( certificate_authority=resources.CertificateAuthority(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].certificate_authority == resources.CertificateAuthority( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_certificate_authority_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4439,14 +4284,14 @@ def test_update_certificate_authority_flattened_error(): client.update_certificate_authority( service.UpdateCertificateAuthorityRequest(), certificate_authority=resources.CertificateAuthority(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_certificate_authority_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4463,25 +4308,23 @@ async def test_update_certificate_authority_flattened_async(): # using the keyword arguments to the method. response = await client.update_certificate_authority( certificate_authority=resources.CertificateAuthority(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].certificate_authority == resources.CertificateAuthority( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_certificate_authority_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4490,7 +4333,7 @@ async def test_update_certificate_authority_flattened_error_async(): await client.update_certificate_authority( service.UpdateCertificateAuthorityRequest(), certificate_authority=resources.CertificateAuthority(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -4498,7 +4341,7 @@ def test_get_certificate_revocation_list( transport: str = "grpc", request_type=service.GetCertificateRevocationListRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4517,27 +4360,19 @@ def test_get_certificate_revocation_list( access_url="access_url_value", state=resources.CertificateRevocationList.State.ACTIVE, ) - response = client.get_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRevocationListRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.CertificateRevocationList) - assert response.name == "name_value" - assert response.sequence_number == 1601 - assert response.pem_crl == "pem_crl_value" - assert response.access_url == "access_url_value" - assert response.state == resources.CertificateRevocationList.State.ACTIVE @@ -4549,7 +4384,7 @@ def test_get_certificate_revocation_list_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4559,7 +4394,6 @@ def test_get_certificate_revocation_list_empty_call(): client.get_certificate_revocation_list() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRevocationListRequest() @@ -4569,7 +4403,7 @@ async def test_get_certificate_revocation_list_async( request_type=service.GetCertificateRevocationListRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4590,26 +4424,19 @@ async def test_get_certificate_revocation_list_async( state=resources.CertificateRevocationList.State.ACTIVE, ) ) - response = await client.get_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCertificateRevocationListRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.CertificateRevocationList) - assert response.name == "name_value" - assert response.sequence_number == 1601 - assert response.pem_crl == "pem_crl_value" - assert response.access_url == "access_url_value" - assert response.state == resources.CertificateRevocationList.State.ACTIVE @@ -4620,12 +4447,13 @@ async def test_get_certificate_revocation_list_async_from_dict(): def test_get_certificate_revocation_list_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCertificateRevocationListRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4633,7 +4461,6 @@ def test_get_certificate_revocation_list_field_headers(): type(client.transport.get_certificate_revocation_list), "__call__" ) as call: call.return_value = resources.CertificateRevocationList() - client.get_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. @@ -4649,12 +4476,13 @@ def test_get_certificate_revocation_list_field_headers(): @pytest.mark.asyncio async def test_get_certificate_revocation_list_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetCertificateRevocationListRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4664,7 +4492,6 @@ async def test_get_certificate_revocation_list_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.CertificateRevocationList() ) - await client.get_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. @@ -4679,7 +4506,7 @@ async def test_get_certificate_revocation_list_field_headers_async(): def test_get_certificate_revocation_list_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4688,7 +4515,6 @@ def test_get_certificate_revocation_list_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.CertificateRevocationList() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_certificate_revocation_list(name="name_value",) @@ -4697,13 +4523,12 @@ def test_get_certificate_revocation_list_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_certificate_revocation_list_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4717,7 +4542,7 @@ def test_get_certificate_revocation_list_flattened_error(): @pytest.mark.asyncio async def test_get_certificate_revocation_list_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4738,14 +4563,13 @@ async def test_get_certificate_revocation_list_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_certificate_revocation_list_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4760,7 +4584,7 @@ def test_list_certificate_revocation_lists( transport: str = "grpc", request_type=service.ListCertificateRevocationListsRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4775,21 +4599,16 @@ def test_list_certificate_revocation_lists( call.return_value = service.ListCertificateRevocationListsResponse( next_page_token="next_page_token_value", unreachable=["unreachable_value"], ) - response = client.list_certificate_revocation_lists(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateRevocationListsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCertificateRevocationListsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -4801,7 +4620,7 @@ def test_list_certificate_revocation_lists_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4811,7 +4630,6 @@ def test_list_certificate_revocation_lists_empty_call(): client.list_certificate_revocation_lists() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateRevocationListsRequest() @@ -4821,7 +4639,7 @@ async def test_list_certificate_revocation_lists_async( request_type=service.ListCertificateRevocationListsRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4839,20 +4657,16 @@ async def test_list_certificate_revocation_lists_async( unreachable=["unreachable_value"], ) ) - response = await client.list_certificate_revocation_lists(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCertificateRevocationListsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListCertificateRevocationListsAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -4863,12 +4677,13 @@ async def test_list_certificate_revocation_lists_async_from_dict(): def test_list_certificate_revocation_lists_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificateRevocationListsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4876,7 +4691,6 @@ def test_list_certificate_revocation_lists_field_headers(): type(client.transport.list_certificate_revocation_lists), "__call__" ) as call: call.return_value = service.ListCertificateRevocationListsResponse() - client.list_certificate_revocation_lists(request) # Establish that the underlying gRPC stub method was called. @@ -4892,12 +4706,13 @@ def test_list_certificate_revocation_lists_field_headers(): @pytest.mark.asyncio async def test_list_certificate_revocation_lists_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListCertificateRevocationListsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4907,7 +4722,6 @@ async def test_list_certificate_revocation_lists_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListCertificateRevocationListsResponse() ) - await client.list_certificate_revocation_lists(request) # Establish that the underlying gRPC stub method was called. @@ -4922,7 +4736,7 @@ async def test_list_certificate_revocation_lists_field_headers_async(): def test_list_certificate_revocation_lists_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4931,7 +4745,6 @@ def test_list_certificate_revocation_lists_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListCertificateRevocationListsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_certificate_revocation_lists(parent="parent_value",) @@ -4940,13 +4753,12 @@ def test_list_certificate_revocation_lists_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_certificate_revocation_lists_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4960,7 +4772,7 @@ def test_list_certificate_revocation_lists_flattened_error(): @pytest.mark.asyncio async def test_list_certificate_revocation_lists_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4983,14 +4795,13 @@ async def test_list_certificate_revocation_lists_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_certificate_revocation_lists_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5003,7 +4814,7 @@ async def test_list_certificate_revocation_lists_flattened_error_async(): def test_list_certificate_revocation_lists_pager(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5051,7 +4862,7 @@ def test_list_certificate_revocation_lists_pager(): def test_list_certificate_revocation_lists_pages(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5091,7 +4902,7 @@ def test_list_certificate_revocation_lists_pages(): @pytest.mark.asyncio async def test_list_certificate_revocation_lists_async_pager(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5140,7 +4951,7 @@ async def test_list_certificate_revocation_lists_async_pager(): @pytest.mark.asyncio async def test_list_certificate_revocation_lists_async_pages(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5187,7 +4998,7 @@ def test_update_certificate_revocation_list( transport: str = "grpc", request_type=service.UpdateCertificateRevocationListRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5200,13 +5011,11 @@ def test_update_certificate_revocation_list( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRevocationListRequest() # Establish that the response is the type that we expect. @@ -5221,7 +5030,7 @@ def test_update_certificate_revocation_list_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5231,7 +5040,6 @@ def test_update_certificate_revocation_list_empty_call(): client.update_certificate_revocation_list() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRevocationListRequest() @@ -5241,7 +5049,7 @@ async def test_update_certificate_revocation_list_async( request_type=service.UpdateCertificateRevocationListRequest, ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5256,13 +5064,11 @@ async def test_update_certificate_revocation_list_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCertificateRevocationListRequest() # Establish that the response is the type that we expect. @@ -5276,12 +5082,13 @@ async def test_update_certificate_revocation_list_async_from_dict(): def test_update_certificate_revocation_list_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateRevocationListRequest() + request.certificate_revocation_list.name = "certificate_revocation_list.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5289,7 +5096,6 @@ def test_update_certificate_revocation_list_field_headers(): type(client.transport.update_certificate_revocation_list), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. @@ -5308,12 +5114,13 @@ def test_update_certificate_revocation_list_field_headers(): @pytest.mark.asyncio async def test_update_certificate_revocation_list_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.UpdateCertificateRevocationListRequest() + request.certificate_revocation_list.name = "certificate_revocation_list.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5323,7 +5130,6 @@ async def test_update_certificate_revocation_list_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_certificate_revocation_list(request) # Establish that the underlying gRPC stub method was called. @@ -5341,7 +5147,7 @@ async def test_update_certificate_revocation_list_field_headers_async(): def test_update_certificate_revocation_list_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5350,33 +5156,30 @@ def test_update_certificate_revocation_list_flattened(): ) 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_revocation_list( certificate_revocation_list=resources.CertificateRevocationList( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[ 0 ].certificate_revocation_list == resources.CertificateRevocationList( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_certificate_revocation_list_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5387,14 +5190,14 @@ def test_update_certificate_revocation_list_flattened_error(): certificate_revocation_list=resources.CertificateRevocationList( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_certificate_revocation_list_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5413,27 +5216,25 @@ async def test_update_certificate_revocation_list_flattened_async(): certificate_revocation_list=resources.CertificateRevocationList( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[ 0 ].certificate_revocation_list == resources.CertificateRevocationList( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_certificate_revocation_list_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5444,7 +5245,7 @@ async def test_update_certificate_revocation_list_flattened_error_async(): certificate_revocation_list=resources.CertificateRevocationList( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -5452,7 +5253,7 @@ def test_get_reusable_config( transport: str = "grpc", request_type=service.GetReusableConfigRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5467,21 +5268,16 @@ def test_get_reusable_config( call.return_value = resources.ReusableConfig( name="name_value", description="description_value", ) - response = client.get_reusable_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] == service.GetReusableConfigRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.ReusableConfig) - assert response.name == "name_value" - assert response.description == "description_value" @@ -5493,7 +5289,7 @@ def test_get_reusable_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5503,7 +5299,6 @@ def test_get_reusable_config_empty_call(): client.get_reusable_config() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.GetReusableConfigRequest() @@ -5512,7 +5307,7 @@ async def test_get_reusable_config_async( transport: str = "grpc_asyncio", request_type=service.GetReusableConfigRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5529,20 +5324,16 @@ async def test_get_reusable_config_async( name="name_value", description="description_value", ) ) - response = await client.get_reusable_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.GetReusableConfigRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.ReusableConfig) - assert response.name == "name_value" - assert response.description == "description_value" @@ -5553,12 +5344,13 @@ async def test_get_reusable_config_async_from_dict(): def test_get_reusable_config_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetReusableConfigRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5566,7 +5358,6 @@ def test_get_reusable_config_field_headers(): type(client.transport.get_reusable_config), "__call__" ) as call: call.return_value = resources.ReusableConfig() - client.get_reusable_config(request) # Establish that the underlying gRPC stub method was called. @@ -5582,12 +5373,13 @@ def test_get_reusable_config_field_headers(): @pytest.mark.asyncio async def test_get_reusable_config_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.GetReusableConfigRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5597,7 +5389,6 @@ async def test_get_reusable_config_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.ReusableConfig() ) - await client.get_reusable_config(request) # Establish that the underlying gRPC stub method was called. @@ -5612,7 +5403,7 @@ async def test_get_reusable_config_field_headers_async(): def test_get_reusable_config_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5621,7 +5412,6 @@ def test_get_reusable_config_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.ReusableConfig() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_reusable_config(name="name_value",) @@ -5630,13 +5420,12 @@ def test_get_reusable_config_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_reusable_config_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5650,7 +5439,7 @@ def test_get_reusable_config_flattened_error(): @pytest.mark.asyncio async def test_get_reusable_config_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5671,14 +5460,13 @@ async def test_get_reusable_config_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_reusable_config_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5693,7 +5481,7 @@ def test_list_reusable_configs( transport: str = "grpc", request_type=service.ListReusableConfigsRequest ): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5708,21 +5496,16 @@ def test_list_reusable_configs( call.return_value = service.ListReusableConfigsResponse( next_page_token="next_page_token_value", unreachable=["unreachable_value"], ) - response = client.list_reusable_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] == service.ListReusableConfigsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListReusableConfigsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -5734,7 +5517,7 @@ def test_list_reusable_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 = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5744,7 +5527,6 @@ def test_list_reusable_configs_empty_call(): client.list_reusable_configs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == service.ListReusableConfigsRequest() @@ -5753,7 +5535,7 @@ async def test_list_reusable_configs_async( transport: str = "grpc_asyncio", request_type=service.ListReusableConfigsRequest ): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5771,20 +5553,16 @@ async def test_list_reusable_configs_async( unreachable=["unreachable_value"], ) ) - response = await client.list_reusable_configs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == service.ListReusableConfigsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListReusableConfigsAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -5795,12 +5573,13 @@ async def test_list_reusable_configs_async_from_dict(): def test_list_reusable_configs_field_headers(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListReusableConfigsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5808,7 +5587,6 @@ def test_list_reusable_configs_field_headers(): type(client.transport.list_reusable_configs), "__call__" ) as call: call.return_value = service.ListReusableConfigsResponse() - client.list_reusable_configs(request) # Establish that the underlying gRPC stub method was called. @@ -5824,12 +5602,13 @@ def test_list_reusable_configs_field_headers(): @pytest.mark.asyncio async def test_list_reusable_configs_field_headers_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = service.ListReusableConfigsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5839,7 +5618,6 @@ async def test_list_reusable_configs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListReusableConfigsResponse() ) - await client.list_reusable_configs(request) # Establish that the underlying gRPC stub method was called. @@ -5854,7 +5632,7 @@ async def test_list_reusable_configs_field_headers_async(): def test_list_reusable_configs_flattened(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5863,7 +5641,6 @@ def test_list_reusable_configs_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListReusableConfigsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_reusable_configs(parent="parent_value",) @@ -5872,13 +5649,12 @@ def test_list_reusable_configs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_reusable_configs_flattened_error(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5892,7 +5668,7 @@ def test_list_reusable_configs_flattened_error(): @pytest.mark.asyncio async def test_list_reusable_configs_flattened_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5913,14 +5689,13 @@ async def test_list_reusable_configs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_reusable_configs_flattened_error_async(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5933,7 +5708,7 @@ async def test_list_reusable_configs_flattened_error_async(): def test_list_reusable_configs_pager(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5980,7 +5755,7 @@ def test_list_reusable_configs_pager(): def test_list_reusable_configs_pages(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6019,7 +5794,7 @@ def test_list_reusable_configs_pages(): @pytest.mark.asyncio async def test_list_reusable_configs_async_pager(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6065,7 +5840,7 @@ async def test_list_reusable_configs_async_pager(): @pytest.mark.asyncio async def test_list_reusable_configs_async_pages(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6108,16 +5883,16 @@ async def test_list_reusable_configs_async_pages(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = CertificateAuthorityServiceClient( @@ -6127,7 +5902,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = CertificateAuthorityServiceClient( @@ -6138,7 +5913,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = CertificateAuthorityServiceClient(transport=transport) assert client.transport is transport @@ -6147,13 +5922,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.CertificateAuthorityServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.CertificateAuthorityServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -6168,8 +5943,8 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() @@ -6177,7 +5952,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( client.transport, transports.CertificateAuthorityServiceGrpcTransport, @@ -6186,9 +5961,9 @@ def test_transport_grpc_default(): def test_certificate_authority_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.CertificateAuthorityServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -6200,7 +5975,7 @@ def test_certificate_authority_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.CertificateAuthorityServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -6237,15 +6012,37 @@ def test_certificate_authority_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_certificate_authority_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CertificateAuthorityServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_certificate_authority_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CertificateAuthorityServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -6258,19 +6055,33 @@ def test_certificate_authority_service_base_transport_with_credentials_file(): def test_certificate_authority_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.security.privateca_v1beta1.services.certificate_authority_service.transports.CertificateAuthorityServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CertificateAuthorityServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_certificate_authority_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + CertificateAuthorityServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_certificate_authority_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) CertificateAuthorityServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -6278,20 +6089,169 @@ def test_certificate_authority_service_auth_adc(): ) -def test_certificate_authority_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.CertificateAuthorityServiceGrpcTransport, + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_certificate_authority_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.CertificateAuthorityServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + 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.CertificateAuthorityServiceGrpcTransport, + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_certificate_authority_service_transport_auth_adc_old_google_auth( + transport_class, +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), + ( + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + grpc_helpers_async, + ), + ], +) +@requires_api_core_gte_1_26_0 +def test_certificate_authority_service_transport_create_channel( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "privateca.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="privateca.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), + ( + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + grpc_helpers_async, + ), + ], +) +@requires_api_core_lt_1_26_0 +def test_certificate_authority_service_transport_create_channel_old_api_core( + 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") + + create_channel.assert_called_with( + "privateca.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CertificateAuthorityServiceGrpcTransport, grpc_helpers), + ( + transports.CertificateAuthorityServiceGrpcAsyncIOTransport, + grpc_helpers_async, + ), + ], +) +@requires_api_core_lt_1_26_0 +def test_certificate_authority_service_transport_create_channel_user_scopes( + 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( + "privateca.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -6302,7 +6262,7 @@ def test_certificate_authority_service_transport_auth_adc(): def test_certificate_authority_service_grpc_transport_client_cert_source_for_mtls( transport_class, ): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -6341,7 +6301,7 @@ def test_certificate_authority_service_grpc_transport_client_cert_source_for_mtl def test_certificate_authority_service_host_no_port(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="privateca.googleapis.com" ), @@ -6351,7 +6311,7 @@ def test_certificate_authority_service_host_no_port(): def test_certificate_authority_service_host_with_port(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="privateca.googleapis.com:8000" ), @@ -6407,9 +6367,9 @@ def test_certificate_authority_service_transport_channel_mtls_with_client_cert_s mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -6485,7 +6445,7 @@ def test_certificate_authority_service_transport_channel_mtls_with_adc(transport def test_certificate_authority_service_grpc_lro_client(): client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -6498,7 +6458,7 @@ def test_certificate_authority_service_grpc_lro_client(): def test_certificate_authority_service_grpc_lro_async_client(): client = CertificateAuthorityServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -6514,7 +6474,6 @@ def test_certificate_path(): location = "clam" certificate_authority = "whelk" certificate = "octopus" - expected = "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}/certificates/{certificate}".format( project=project, location=location, @@ -6545,7 +6504,6 @@ def test_certificate_authority_path(): project = "winkle" location = "nautilus" certificate_authority = "scallop" - expected = "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}".format( project=project, location=location, certificate_authority=certificate_authority, ) @@ -6573,7 +6531,6 @@ def test_certificate_revocation_list_path(): location = "octopus" certificate_authority = "oyster" certificate_revocation_list = "nudibranch" - expected = "projects/{project}/locations/{location}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list}".format( project=project, location=location, @@ -6608,7 +6565,6 @@ def test_reusable_config_path(): project = "scallop" location = "abalone" reusable_config = "squid" - expected = "projects/{project}/locations/{location}/reusableConfigs/{reusable_config}".format( project=project, location=location, reusable_config=reusable_config, ) @@ -6633,7 +6589,6 @@ def test_parse_reusable_config_path(): def test_common_billing_account_path(): billing_account = "oyster" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -6656,7 +6611,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder,) actual = CertificateAuthorityServiceClient.common_folder_path(folder) assert expected == actual @@ -6675,7 +6629,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "winkle" - expected = "organizations/{organization}".format(organization=organization,) actual = CertificateAuthorityServiceClient.common_organization_path(organization) assert expected == actual @@ -6694,7 +6647,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "scallop" - expected = "projects/{project}".format(project=project,) actual = CertificateAuthorityServiceClient.common_project_path(project) assert expected == actual @@ -6714,7 +6666,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "squid" location = "clam" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -6741,7 +6692,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.CertificateAuthorityServiceTransport, "_prep_wrapped_messages" ) as prep: client = CertificateAuthorityServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -6750,6 +6701,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = CertificateAuthorityServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info)