From 38b0a00a8c2fcab2287920c51a7096a1ebaf11ee Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 7 Oct 2021 19:34:21 +0000 Subject: [PATCH 1/2] feat: add context manager support in client chore: fix docstring for first attribute of protos committer: @busunkim96 PiperOrigin-RevId: 401271153 Source-Link: https://github.com/googleapis/googleapis/commit/787f8c9a731f44e74a90b9847d48659ca9462d10 Source-Link: https://github.com/googleapis/googleapis-gen/commit/81decffe9fc72396a8153e756d1d67a6eecfd620 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODFkZWNmZmU5ZmM3MjM5NmE4MTUzZTc1NmQxZDY3YTZlZWNmZDYyMCJ9 --- owl-bot-staging/v1/.coveragerc | 17 + owl-bot-staging/v1/MANIFEST.in | 2 + owl-bot-staging/v1/README.rst | 49 + .../docs/channel_v1/cloud_channel_service.rst | 10 + .../v1/docs/channel_v1/services.rst | 6 + owl-bot-staging/v1/docs/channel_v1/types.rst | 7 + owl-bot-staging/v1/docs/conf.py | 376 + owl-bot-staging/v1/docs/index.rst | 7 + .../v1/google/cloud/channel/__init__.py | 215 + .../v1/google/cloud/channel/py.typed | 2 + .../v1/google/cloud/channel_v1/__init__.py | 216 + .../cloud/channel_v1/gapic_metadata.json | 373 + .../v1/google/cloud/channel_v1/py.typed | 2 + .../cloud/channel_v1/services/__init__.py | 15 + .../cloud_channel_service/__init__.py | 22 + .../cloud_channel_service/async_client.py | 3089 ++++++ .../services/cloud_channel_service/client.py | 3355 +++++++ .../services/cloud_channel_service/pagers.py | 1365 +++ .../transports/__init__.py | 33 + .../cloud_channel_service/transports/base.py | 665 ++ .../cloud_channel_service/transports/grpc.py | 1841 ++++ .../transports/grpc_asyncio.py | 1846 ++++ .../google/cloud/channel_v1/types/__init__.py | 228 + .../channel_v1/types/channel_partner_links.py | 123 + .../google/cloud/channel_v1/types/common.py | 219 + .../cloud/channel_v1/types/customers.py | 194 + .../cloud/channel_v1/types/entitlements.py | 403 + .../google/cloud/channel_v1/types/offers.py | 503 + .../cloud/channel_v1/types/operations.py | 58 + .../google/cloud/channel_v1/types/products.py | 147 + .../google/cloud/channel_v1/types/service.py | 1991 ++++ .../channel_v1/types/subscriber_event.py | 123 + owl-bot-staging/v1/mypy.ini | 3 + owl-bot-staging/v1/noxfile.py | 132 + .../v1/scripts/fixup_channel_v1_keywords.py | 210 + owl-bot-staging/v1/setup.py | 54 + 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/channel_v1/__init__.py | 16 + .../channel_v1/test_cloud_channel_service.py | 8683 +++++++++++++++++ 41 files changed, 26648 insertions(+) create mode 100644 owl-bot-staging/v1/.coveragerc create mode 100644 owl-bot-staging/v1/MANIFEST.in create mode 100644 owl-bot-staging/v1/README.rst create mode 100644 owl-bot-staging/v1/docs/channel_v1/cloud_channel_service.rst create mode 100644 owl-bot-staging/v1/docs/channel_v1/services.rst create mode 100644 owl-bot-staging/v1/docs/channel_v1/types.rst create mode 100644 owl-bot-staging/v1/docs/conf.py create mode 100644 owl-bot-staging/v1/docs/index.rst create mode 100644 owl-bot-staging/v1/google/cloud/channel/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/channel/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/async_client.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/client.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/pagers.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/base.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/channel_partner_links.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/common.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/customers.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/entitlements.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/offers.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/operations.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/products.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/service.py create mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/subscriber_event.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_channel_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/channel_v1/__init__.py create mode 100644 owl-bot-staging/v1/tests/unit/gapic/channel_v1/test_cloud_channel_service.py diff --git a/owl-bot-staging/v1/.coveragerc b/owl-bot-staging/v1/.coveragerc new file mode 100644 index 0000000..44d34f9 --- /dev/null +++ b/owl-bot-staging/v1/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/channel/__init__.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore pkg_resources exceptions. + # This is added at the module level as a safeguard for if someone + # generates the code and tries to run it without pip installing. This + # makes it virtually impossible to test properly. + except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v1/MANIFEST.in b/owl-bot-staging/v1/MANIFEST.in new file mode 100644 index 0000000..299d625 --- /dev/null +++ b/owl-bot-staging/v1/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/channel *.py +recursive-include google/cloud/channel_v1 *.py diff --git a/owl-bot-staging/v1/README.rst b/owl-bot-staging/v1/README.rst new file mode 100644 index 0000000..1b0de78 --- /dev/null +++ b/owl-bot-staging/v1/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Channel 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 Channel 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/channel_v1/cloud_channel_service.rst b/owl-bot-staging/v1/docs/channel_v1/cloud_channel_service.rst new file mode 100644 index 0000000..917d45e --- /dev/null +++ b/owl-bot-staging/v1/docs/channel_v1/cloud_channel_service.rst @@ -0,0 +1,10 @@ +CloudChannelService +------------------------------------- + +.. automodule:: google.cloud.channel_v1.services.cloud_channel_service + :members: + :inherited-members: + +.. automodule:: google.cloud.channel_v1.services.cloud_channel_service.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v1/docs/channel_v1/services.rst b/owl-bot-staging/v1/docs/channel_v1/services.rst new file mode 100644 index 0000000..afcb3e9 --- /dev/null +++ b/owl-bot-staging/v1/docs/channel_v1/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Channel v1 API +======================================== +.. toctree:: + :maxdepth: 2 + + cloud_channel_service diff --git a/owl-bot-staging/v1/docs/channel_v1/types.rst b/owl-bot-staging/v1/docs/channel_v1/types.rst new file mode 100644 index 0000000..1c173ec --- /dev/null +++ b/owl-bot-staging/v1/docs/channel_v1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Channel v1 API +===================================== + +.. automodule:: google.cloud.channel_v1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1/docs/conf.py b/owl-bot-staging/v1/docs/conf.py new file mode 100644 index 0000000..fa3dcab --- /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-channel 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-channel" +copyright = u"2020, Google, LLC" +author = u"Google APIs" # TODO: autogenerate this bit + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Client Libraries for Python", + "github_user": "googleapis", + "github_repo": "google-cloud-python", + "github_banner": True, + "font_family": "'Roboto', Georgia, sans", + "head_font_family": "'Roboto', Georgia, serif", + "code_font_family": "'Roboto Mono', 'Consolas', monospace", +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = "google-cloud-channel-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-channel.tex", + u"google-cloud-channel 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-channel", + u"Google Cloud Channel 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-channel", + u"google-cloud-channel Documentation", + author, + "google-cloud-channel", + "GAPIC library for Google Cloud Channel 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..d497c89 --- /dev/null +++ b/owl-bot-staging/v1/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + channel_v1/services + channel_v1/types diff --git a/owl-bot-staging/v1/google/cloud/channel/__init__.py b/owl-bot-staging/v1/google/cloud/channel/__init__.py new file mode 100644 index 0000000..b856b64 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel/__init__.py @@ -0,0 +1,215 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.channel_v1.services.cloud_channel_service.client import CloudChannelServiceClient +from google.cloud.channel_v1.services.cloud_channel_service.async_client import CloudChannelServiceAsyncClient + +from google.cloud.channel_v1.types.channel_partner_links import ChannelPartnerLink +from google.cloud.channel_v1.types.channel_partner_links import ChannelPartnerLinkState +from google.cloud.channel_v1.types.channel_partner_links import ChannelPartnerLinkView +from google.cloud.channel_v1.types.common import AdminUser +from google.cloud.channel_v1.types.common import CloudIdentityInfo +from google.cloud.channel_v1.types.common import EduData +from google.cloud.channel_v1.types.common import Value +from google.cloud.channel_v1.types.customers import ContactInfo +from google.cloud.channel_v1.types.customers import Customer +from google.cloud.channel_v1.types.entitlements import AssociationInfo +from google.cloud.channel_v1.types.entitlements import CommitmentSettings +from google.cloud.channel_v1.types.entitlements import Entitlement +from google.cloud.channel_v1.types.entitlements import Parameter +from google.cloud.channel_v1.types.entitlements import ProvisionedService +from google.cloud.channel_v1.types.entitlements import RenewalSettings +from google.cloud.channel_v1.types.entitlements import TransferableSku +from google.cloud.channel_v1.types.entitlements import TransferEligibility +from google.cloud.channel_v1.types.entitlements import TrialSettings +from google.cloud.channel_v1.types.offers import Constraints +from google.cloud.channel_v1.types.offers import CustomerConstraints +from google.cloud.channel_v1.types.offers import Offer +from google.cloud.channel_v1.types.offers import ParameterDefinition +from google.cloud.channel_v1.types.offers import Period +from google.cloud.channel_v1.types.offers import Plan +from google.cloud.channel_v1.types.offers import Price +from google.cloud.channel_v1.types.offers import PriceByResource +from google.cloud.channel_v1.types.offers import PricePhase +from google.cloud.channel_v1.types.offers import PriceTier +from google.cloud.channel_v1.types.offers import PaymentPlan +from google.cloud.channel_v1.types.offers import PaymentType +from google.cloud.channel_v1.types.offers import PeriodType +from google.cloud.channel_v1.types.offers import PromotionalOrderType +from google.cloud.channel_v1.types.offers import ResourceType +from google.cloud.channel_v1.types.operations import OperationMetadata +from google.cloud.channel_v1.types.products import MarketingInfo +from google.cloud.channel_v1.types.products import Media +from google.cloud.channel_v1.types.products import Product +from google.cloud.channel_v1.types.products import Sku +from google.cloud.channel_v1.types.products import MediaType +from google.cloud.channel_v1.types.service import ActivateEntitlementRequest +from google.cloud.channel_v1.types.service import CancelEntitlementRequest +from google.cloud.channel_v1.types.service import ChangeOfferRequest +from google.cloud.channel_v1.types.service import ChangeParametersRequest +from google.cloud.channel_v1.types.service import ChangeRenewalSettingsRequest +from google.cloud.channel_v1.types.service import CheckCloudIdentityAccountsExistRequest +from google.cloud.channel_v1.types.service import CheckCloudIdentityAccountsExistResponse +from google.cloud.channel_v1.types.service import CloudIdentityCustomerAccount +from google.cloud.channel_v1.types.service import CreateChannelPartnerLinkRequest +from google.cloud.channel_v1.types.service import CreateCustomerRequest +from google.cloud.channel_v1.types.service import CreateEntitlementRequest +from google.cloud.channel_v1.types.service import DeleteCustomerRequest +from google.cloud.channel_v1.types.service import GetChannelPartnerLinkRequest +from google.cloud.channel_v1.types.service import GetCustomerRequest +from google.cloud.channel_v1.types.service import GetEntitlementRequest +from google.cloud.channel_v1.types.service import ImportCustomerRequest +from google.cloud.channel_v1.types.service import ListChannelPartnerLinksRequest +from google.cloud.channel_v1.types.service import ListChannelPartnerLinksResponse +from google.cloud.channel_v1.types.service import ListCustomersRequest +from google.cloud.channel_v1.types.service import ListCustomersResponse +from google.cloud.channel_v1.types.service import ListEntitlementsRequest +from google.cloud.channel_v1.types.service import ListEntitlementsResponse +from google.cloud.channel_v1.types.service import ListOffersRequest +from google.cloud.channel_v1.types.service import ListOffersResponse +from google.cloud.channel_v1.types.service import ListProductsRequest +from google.cloud.channel_v1.types.service import ListProductsResponse +from google.cloud.channel_v1.types.service import ListPurchasableOffersRequest +from google.cloud.channel_v1.types.service import ListPurchasableOffersResponse +from google.cloud.channel_v1.types.service import ListPurchasableSkusRequest +from google.cloud.channel_v1.types.service import ListPurchasableSkusResponse +from google.cloud.channel_v1.types.service import ListSkusRequest +from google.cloud.channel_v1.types.service import ListSkusResponse +from google.cloud.channel_v1.types.service import ListSubscribersRequest +from google.cloud.channel_v1.types.service import ListSubscribersResponse +from google.cloud.channel_v1.types.service import ListTransferableOffersRequest +from google.cloud.channel_v1.types.service import ListTransferableOffersResponse +from google.cloud.channel_v1.types.service import ListTransferableSkusRequest +from google.cloud.channel_v1.types.service import ListTransferableSkusResponse +from google.cloud.channel_v1.types.service import LookupOfferRequest +from google.cloud.channel_v1.types.service import ProvisionCloudIdentityRequest +from google.cloud.channel_v1.types.service import PurchasableOffer +from google.cloud.channel_v1.types.service import PurchasableSku +from google.cloud.channel_v1.types.service import RegisterSubscriberRequest +from google.cloud.channel_v1.types.service import RegisterSubscriberResponse +from google.cloud.channel_v1.types.service import StartPaidServiceRequest +from google.cloud.channel_v1.types.service import SuspendEntitlementRequest +from google.cloud.channel_v1.types.service import TransferableOffer +from google.cloud.channel_v1.types.service import TransferEntitlementsRequest +from google.cloud.channel_v1.types.service import TransferEntitlementsResponse +from google.cloud.channel_v1.types.service import TransferEntitlementsToGoogleRequest +from google.cloud.channel_v1.types.service import UnregisterSubscriberRequest +from google.cloud.channel_v1.types.service import UnregisterSubscriberResponse +from google.cloud.channel_v1.types.service import UpdateChannelPartnerLinkRequest +from google.cloud.channel_v1.types.service import UpdateCustomerRequest +from google.cloud.channel_v1.types.subscriber_event import CustomerEvent +from google.cloud.channel_v1.types.subscriber_event import EntitlementEvent +from google.cloud.channel_v1.types.subscriber_event import SubscriberEvent + +__all__ = ('CloudChannelServiceClient', + 'CloudChannelServiceAsyncClient', + 'ChannelPartnerLink', + 'ChannelPartnerLinkState', + 'ChannelPartnerLinkView', + 'AdminUser', + 'CloudIdentityInfo', + 'EduData', + 'Value', + 'ContactInfo', + 'Customer', + 'AssociationInfo', + 'CommitmentSettings', + 'Entitlement', + 'Parameter', + 'ProvisionedService', + 'RenewalSettings', + 'TransferableSku', + 'TransferEligibility', + 'TrialSettings', + 'Constraints', + 'CustomerConstraints', + 'Offer', + 'ParameterDefinition', + 'Period', + 'Plan', + 'Price', + 'PriceByResource', + 'PricePhase', + 'PriceTier', + 'PaymentPlan', + 'PaymentType', + 'PeriodType', + 'PromotionalOrderType', + 'ResourceType', + 'OperationMetadata', + 'MarketingInfo', + 'Media', + 'Product', + 'Sku', + 'MediaType', + 'ActivateEntitlementRequest', + 'CancelEntitlementRequest', + 'ChangeOfferRequest', + 'ChangeParametersRequest', + 'ChangeRenewalSettingsRequest', + 'CheckCloudIdentityAccountsExistRequest', + 'CheckCloudIdentityAccountsExistResponse', + 'CloudIdentityCustomerAccount', + 'CreateChannelPartnerLinkRequest', + 'CreateCustomerRequest', + 'CreateEntitlementRequest', + 'DeleteCustomerRequest', + 'GetChannelPartnerLinkRequest', + 'GetCustomerRequest', + 'GetEntitlementRequest', + 'ImportCustomerRequest', + 'ListChannelPartnerLinksRequest', + 'ListChannelPartnerLinksResponse', + 'ListCustomersRequest', + 'ListCustomersResponse', + 'ListEntitlementsRequest', + 'ListEntitlementsResponse', + 'ListOffersRequest', + 'ListOffersResponse', + 'ListProductsRequest', + 'ListProductsResponse', + 'ListPurchasableOffersRequest', + 'ListPurchasableOffersResponse', + 'ListPurchasableSkusRequest', + 'ListPurchasableSkusResponse', + 'ListSkusRequest', + 'ListSkusResponse', + 'ListSubscribersRequest', + 'ListSubscribersResponse', + 'ListTransferableOffersRequest', + 'ListTransferableOffersResponse', + 'ListTransferableSkusRequest', + 'ListTransferableSkusResponse', + 'LookupOfferRequest', + 'ProvisionCloudIdentityRequest', + 'PurchasableOffer', + 'PurchasableSku', + 'RegisterSubscriberRequest', + 'RegisterSubscriberResponse', + 'StartPaidServiceRequest', + 'SuspendEntitlementRequest', + 'TransferableOffer', + 'TransferEntitlementsRequest', + 'TransferEntitlementsResponse', + 'TransferEntitlementsToGoogleRequest', + 'UnregisterSubscriberRequest', + 'UnregisterSubscriberResponse', + 'UpdateChannelPartnerLinkRequest', + 'UpdateCustomerRequest', + 'CustomerEvent', + 'EntitlementEvent', + 'SubscriberEvent', +) diff --git a/owl-bot-staging/v1/google/cloud/channel/py.typed b/owl-bot-staging/v1/google/cloud/channel/py.typed new file mode 100644 index 0000000..0915275 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-channel package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/__init__.py b/owl-bot-staging/v1/google/cloud/channel_v1/__init__.py new file mode 100644 index 0000000..b3091c2 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/__init__.py @@ -0,0 +1,216 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.cloud_channel_service import CloudChannelServiceClient +from .services.cloud_channel_service import CloudChannelServiceAsyncClient + +from .types.channel_partner_links import ChannelPartnerLink +from .types.channel_partner_links import ChannelPartnerLinkState +from .types.channel_partner_links import ChannelPartnerLinkView +from .types.common import AdminUser +from .types.common import CloudIdentityInfo +from .types.common import EduData +from .types.common import Value +from .types.customers import ContactInfo +from .types.customers import Customer +from .types.entitlements import AssociationInfo +from .types.entitlements import CommitmentSettings +from .types.entitlements import Entitlement +from .types.entitlements import Parameter +from .types.entitlements import ProvisionedService +from .types.entitlements import RenewalSettings +from .types.entitlements import TransferableSku +from .types.entitlements import TransferEligibility +from .types.entitlements import TrialSettings +from .types.offers import Constraints +from .types.offers import CustomerConstraints +from .types.offers import Offer +from .types.offers import ParameterDefinition +from .types.offers import Period +from .types.offers import Plan +from .types.offers import Price +from .types.offers import PriceByResource +from .types.offers import PricePhase +from .types.offers import PriceTier +from .types.offers import PaymentPlan +from .types.offers import PaymentType +from .types.offers import PeriodType +from .types.offers import PromotionalOrderType +from .types.offers import ResourceType +from .types.operations import OperationMetadata +from .types.products import MarketingInfo +from .types.products import Media +from .types.products import Product +from .types.products import Sku +from .types.products import MediaType +from .types.service import ActivateEntitlementRequest +from .types.service import CancelEntitlementRequest +from .types.service import ChangeOfferRequest +from .types.service import ChangeParametersRequest +from .types.service import ChangeRenewalSettingsRequest +from .types.service import CheckCloudIdentityAccountsExistRequest +from .types.service import CheckCloudIdentityAccountsExistResponse +from .types.service import CloudIdentityCustomerAccount +from .types.service import CreateChannelPartnerLinkRequest +from .types.service import CreateCustomerRequest +from .types.service import CreateEntitlementRequest +from .types.service import DeleteCustomerRequest +from .types.service import GetChannelPartnerLinkRequest +from .types.service import GetCustomerRequest +from .types.service import GetEntitlementRequest +from .types.service import ImportCustomerRequest +from .types.service import ListChannelPartnerLinksRequest +from .types.service import ListChannelPartnerLinksResponse +from .types.service import ListCustomersRequest +from .types.service import ListCustomersResponse +from .types.service import ListEntitlementsRequest +from .types.service import ListEntitlementsResponse +from .types.service import ListOffersRequest +from .types.service import ListOffersResponse +from .types.service import ListProductsRequest +from .types.service import ListProductsResponse +from .types.service import ListPurchasableOffersRequest +from .types.service import ListPurchasableOffersResponse +from .types.service import ListPurchasableSkusRequest +from .types.service import ListPurchasableSkusResponse +from .types.service import ListSkusRequest +from .types.service import ListSkusResponse +from .types.service import ListSubscribersRequest +from .types.service import ListSubscribersResponse +from .types.service import ListTransferableOffersRequest +from .types.service import ListTransferableOffersResponse +from .types.service import ListTransferableSkusRequest +from .types.service import ListTransferableSkusResponse +from .types.service import LookupOfferRequest +from .types.service import ProvisionCloudIdentityRequest +from .types.service import PurchasableOffer +from .types.service import PurchasableSku +from .types.service import RegisterSubscriberRequest +from .types.service import RegisterSubscriberResponse +from .types.service import StartPaidServiceRequest +from .types.service import SuspendEntitlementRequest +from .types.service import TransferableOffer +from .types.service import TransferEntitlementsRequest +from .types.service import TransferEntitlementsResponse +from .types.service import TransferEntitlementsToGoogleRequest +from .types.service import UnregisterSubscriberRequest +from .types.service import UnregisterSubscriberResponse +from .types.service import UpdateChannelPartnerLinkRequest +from .types.service import UpdateCustomerRequest +from .types.subscriber_event import CustomerEvent +from .types.subscriber_event import EntitlementEvent +from .types.subscriber_event import SubscriberEvent + +__all__ = ( + 'CloudChannelServiceAsyncClient', +'ActivateEntitlementRequest', +'AdminUser', +'AssociationInfo', +'CancelEntitlementRequest', +'ChangeOfferRequest', +'ChangeParametersRequest', +'ChangeRenewalSettingsRequest', +'ChannelPartnerLink', +'ChannelPartnerLinkState', +'ChannelPartnerLinkView', +'CheckCloudIdentityAccountsExistRequest', +'CheckCloudIdentityAccountsExistResponse', +'CloudChannelServiceClient', +'CloudIdentityCustomerAccount', +'CloudIdentityInfo', +'CommitmentSettings', +'Constraints', +'ContactInfo', +'CreateChannelPartnerLinkRequest', +'CreateCustomerRequest', +'CreateEntitlementRequest', +'Customer', +'CustomerConstraints', +'CustomerEvent', +'DeleteCustomerRequest', +'EduData', +'Entitlement', +'EntitlementEvent', +'GetChannelPartnerLinkRequest', +'GetCustomerRequest', +'GetEntitlementRequest', +'ImportCustomerRequest', +'ListChannelPartnerLinksRequest', +'ListChannelPartnerLinksResponse', +'ListCustomersRequest', +'ListCustomersResponse', +'ListEntitlementsRequest', +'ListEntitlementsResponse', +'ListOffersRequest', +'ListOffersResponse', +'ListProductsRequest', +'ListProductsResponse', +'ListPurchasableOffersRequest', +'ListPurchasableOffersResponse', +'ListPurchasableSkusRequest', +'ListPurchasableSkusResponse', +'ListSkusRequest', +'ListSkusResponse', +'ListSubscribersRequest', +'ListSubscribersResponse', +'ListTransferableOffersRequest', +'ListTransferableOffersResponse', +'ListTransferableSkusRequest', +'ListTransferableSkusResponse', +'LookupOfferRequest', +'MarketingInfo', +'Media', +'MediaType', +'Offer', +'OperationMetadata', +'Parameter', +'ParameterDefinition', +'PaymentPlan', +'PaymentType', +'Period', +'PeriodType', +'Plan', +'Price', +'PriceByResource', +'PricePhase', +'PriceTier', +'Product', +'PromotionalOrderType', +'ProvisionCloudIdentityRequest', +'ProvisionedService', +'PurchasableOffer', +'PurchasableSku', +'RegisterSubscriberRequest', +'RegisterSubscriberResponse', +'RenewalSettings', +'ResourceType', +'Sku', +'StartPaidServiceRequest', +'SubscriberEvent', +'SuspendEntitlementRequest', +'TransferEligibility', +'TransferEntitlementsRequest', +'TransferEntitlementsResponse', +'TransferEntitlementsToGoogleRequest', +'TransferableOffer', +'TransferableSku', +'TrialSettings', +'UnregisterSubscriberRequest', +'UnregisterSubscriberResponse', +'UpdateChannelPartnerLinkRequest', +'UpdateCustomerRequest', +'Value', +) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/gapic_metadata.json b/owl-bot-staging/v1/google/cloud/channel_v1/gapic_metadata.json new file mode 100644 index 0000000..9c71a5f --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/gapic_metadata.json @@ -0,0 +1,373 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.channel_v1", + "protoPackage": "google.cloud.channel.v1", + "schema": "1.0", + "services": { + "CloudChannelService": { + "clients": { + "grpc": { + "libraryClient": "CloudChannelServiceClient", + "rpcs": { + "ActivateEntitlement": { + "methods": [ + "activate_entitlement" + ] + }, + "CancelEntitlement": { + "methods": [ + "cancel_entitlement" + ] + }, + "ChangeOffer": { + "methods": [ + "change_offer" + ] + }, + "ChangeParameters": { + "methods": [ + "change_parameters" + ] + }, + "ChangeRenewalSettings": { + "methods": [ + "change_renewal_settings" + ] + }, + "CheckCloudIdentityAccountsExist": { + "methods": [ + "check_cloud_identity_accounts_exist" + ] + }, + "CreateChannelPartnerLink": { + "methods": [ + "create_channel_partner_link" + ] + }, + "CreateCustomer": { + "methods": [ + "create_customer" + ] + }, + "CreateEntitlement": { + "methods": [ + "create_entitlement" + ] + }, + "DeleteCustomer": { + "methods": [ + "delete_customer" + ] + }, + "GetChannelPartnerLink": { + "methods": [ + "get_channel_partner_link" + ] + }, + "GetCustomer": { + "methods": [ + "get_customer" + ] + }, + "GetEntitlement": { + "methods": [ + "get_entitlement" + ] + }, + "ImportCustomer": { + "methods": [ + "import_customer" + ] + }, + "ListChannelPartnerLinks": { + "methods": [ + "list_channel_partner_links" + ] + }, + "ListCustomers": { + "methods": [ + "list_customers" + ] + }, + "ListEntitlements": { + "methods": [ + "list_entitlements" + ] + }, + "ListOffers": { + "methods": [ + "list_offers" + ] + }, + "ListProducts": { + "methods": [ + "list_products" + ] + }, + "ListPurchasableOffers": { + "methods": [ + "list_purchasable_offers" + ] + }, + "ListPurchasableSkus": { + "methods": [ + "list_purchasable_skus" + ] + }, + "ListSkus": { + "methods": [ + "list_skus" + ] + }, + "ListSubscribers": { + "methods": [ + "list_subscribers" + ] + }, + "ListTransferableOffers": { + "methods": [ + "list_transferable_offers" + ] + }, + "ListTransferableSkus": { + "methods": [ + "list_transferable_skus" + ] + }, + "LookupOffer": { + "methods": [ + "lookup_offer" + ] + }, + "ProvisionCloudIdentity": { + "methods": [ + "provision_cloud_identity" + ] + }, + "RegisterSubscriber": { + "methods": [ + "register_subscriber" + ] + }, + "StartPaidService": { + "methods": [ + "start_paid_service" + ] + }, + "SuspendEntitlement": { + "methods": [ + "suspend_entitlement" + ] + }, + "TransferEntitlements": { + "methods": [ + "transfer_entitlements" + ] + }, + "TransferEntitlementsToGoogle": { + "methods": [ + "transfer_entitlements_to_google" + ] + }, + "UnregisterSubscriber": { + "methods": [ + "unregister_subscriber" + ] + }, + "UpdateChannelPartnerLink": { + "methods": [ + "update_channel_partner_link" + ] + }, + "UpdateCustomer": { + "methods": [ + "update_customer" + ] + } + } + }, + "grpc-async": { + "libraryClient": "CloudChannelServiceAsyncClient", + "rpcs": { + "ActivateEntitlement": { + "methods": [ + "activate_entitlement" + ] + }, + "CancelEntitlement": { + "methods": [ + "cancel_entitlement" + ] + }, + "ChangeOffer": { + "methods": [ + "change_offer" + ] + }, + "ChangeParameters": { + "methods": [ + "change_parameters" + ] + }, + "ChangeRenewalSettings": { + "methods": [ + "change_renewal_settings" + ] + }, + "CheckCloudIdentityAccountsExist": { + "methods": [ + "check_cloud_identity_accounts_exist" + ] + }, + "CreateChannelPartnerLink": { + "methods": [ + "create_channel_partner_link" + ] + }, + "CreateCustomer": { + "methods": [ + "create_customer" + ] + }, + "CreateEntitlement": { + "methods": [ + "create_entitlement" + ] + }, + "DeleteCustomer": { + "methods": [ + "delete_customer" + ] + }, + "GetChannelPartnerLink": { + "methods": [ + "get_channel_partner_link" + ] + }, + "GetCustomer": { + "methods": [ + "get_customer" + ] + }, + "GetEntitlement": { + "methods": [ + "get_entitlement" + ] + }, + "ImportCustomer": { + "methods": [ + "import_customer" + ] + }, + "ListChannelPartnerLinks": { + "methods": [ + "list_channel_partner_links" + ] + }, + "ListCustomers": { + "methods": [ + "list_customers" + ] + }, + "ListEntitlements": { + "methods": [ + "list_entitlements" + ] + }, + "ListOffers": { + "methods": [ + "list_offers" + ] + }, + "ListProducts": { + "methods": [ + "list_products" + ] + }, + "ListPurchasableOffers": { + "methods": [ + "list_purchasable_offers" + ] + }, + "ListPurchasableSkus": { + "methods": [ + "list_purchasable_skus" + ] + }, + "ListSkus": { + "methods": [ + "list_skus" + ] + }, + "ListSubscribers": { + "methods": [ + "list_subscribers" + ] + }, + "ListTransferableOffers": { + "methods": [ + "list_transferable_offers" + ] + }, + "ListTransferableSkus": { + "methods": [ + "list_transferable_skus" + ] + }, + "LookupOffer": { + "methods": [ + "lookup_offer" + ] + }, + "ProvisionCloudIdentity": { + "methods": [ + "provision_cloud_identity" + ] + }, + "RegisterSubscriber": { + "methods": [ + "register_subscriber" + ] + }, + "StartPaidService": { + "methods": [ + "start_paid_service" + ] + }, + "SuspendEntitlement": { + "methods": [ + "suspend_entitlement" + ] + }, + "TransferEntitlements": { + "methods": [ + "transfer_entitlements" + ] + }, + "TransferEntitlementsToGoogle": { + "methods": [ + "transfer_entitlements_to_google" + ] + }, + "UnregisterSubscriber": { + "methods": [ + "unregister_subscriber" + ] + }, + "UpdateChannelPartnerLink": { + "methods": [ + "update_channel_partner_link" + ] + }, + "UpdateCustomer": { + "methods": [ + "update_customer" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/py.typed b/owl-bot-staging/v1/google/cloud/channel_v1/py.typed new file mode 100644 index 0000000..0915275 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-channel package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/__init__.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_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/channel_v1/services/cloud_channel_service/__init__.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/__init__.py new file mode 100644 index 0000000..bc5d708 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_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 CloudChannelServiceClient +from .async_client import CloudChannelServiceAsyncClient + +__all__ = ( + 'CloudChannelServiceClient', + 'CloudChannelServiceAsyncClient', +) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/async_client.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/async_client.py new file mode 100644 index 0000000..f8e4dcd --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/async_client.py @@ -0,0 +1,3089 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.channel_v1.services.cloud_channel_service import pagers +from google.cloud.channel_v1.types import channel_partner_links +from google.cloud.channel_v1.types import common +from google.cloud.channel_v1.types import customers +from google.cloud.channel_v1.types import entitlements +from google.cloud.channel_v1.types import offers +from google.cloud.channel_v1.types import operations +from google.cloud.channel_v1.types import products +from google.cloud.channel_v1.types import service +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import postal_address_pb2 # type: ignore +from .transports.base import CloudChannelServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import CloudChannelServiceGrpcAsyncIOTransport +from .client import CloudChannelServiceClient + + +class CloudChannelServiceAsyncClient: + """CloudChannelService lets Google cloud resellers and distributors + manage their customers, channel partners, entitlements, and reports. + + Using this service: + + 1. Resellers and distributors can manage a customer entity. + 2. Distributors can register an authorized reseller in their channel + and provide them with delegated admin access. + 3. Resellers and distributors can manage customer entitlements. + + CloudChannelService exposes the following resources: + + - [Customer][google.cloud.channel.v1.Customer]s: An entity—usually + an enterprise—managed by a reseller or distributor. + + - [Entitlement][google.cloud.channel.v1.Entitlement]s: An entity + that provides a customer with the means to use a service. + Entitlements are created or updated as a result of a successful + fulfillment. + + - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s: + An entity that identifies links between distributors and their + indirect resellers in a channel. + """ + + _client: CloudChannelServiceClient + + DEFAULT_ENDPOINT = CloudChannelServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = CloudChannelServiceClient.DEFAULT_MTLS_ENDPOINT + + customer_path = staticmethod(CloudChannelServiceClient.customer_path) + parse_customer_path = staticmethod(CloudChannelServiceClient.parse_customer_path) + entitlement_path = staticmethod(CloudChannelServiceClient.entitlement_path) + parse_entitlement_path = staticmethod(CloudChannelServiceClient.parse_entitlement_path) + offer_path = staticmethod(CloudChannelServiceClient.offer_path) + parse_offer_path = staticmethod(CloudChannelServiceClient.parse_offer_path) + product_path = staticmethod(CloudChannelServiceClient.product_path) + parse_product_path = staticmethod(CloudChannelServiceClient.parse_product_path) + sku_path = staticmethod(CloudChannelServiceClient.sku_path) + parse_sku_path = staticmethod(CloudChannelServiceClient.parse_sku_path) + common_billing_account_path = staticmethod(CloudChannelServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(CloudChannelServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(CloudChannelServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(CloudChannelServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(CloudChannelServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(CloudChannelServiceClient.parse_common_organization_path) + common_project_path = staticmethod(CloudChannelServiceClient.common_project_path) + parse_common_project_path = staticmethod(CloudChannelServiceClient.parse_common_project_path) + common_location_path = staticmethod(CloudChannelServiceClient.common_location_path) + parse_common_location_path = staticmethod(CloudChannelServiceClient.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: + CloudChannelServiceAsyncClient: The constructed client. + """ + return CloudChannelServiceClient.from_service_account_info.__func__(CloudChannelServiceAsyncClient, 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: + CloudChannelServiceAsyncClient: The constructed client. + """ + return CloudChannelServiceClient.from_service_account_file.__func__(CloudChannelServiceAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> CloudChannelServiceTransport: + """Returns the transport used by the client instance. + + Returns: + CloudChannelServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(CloudChannelServiceClient).get_transport_class, type(CloudChannelServiceClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, CloudChannelServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the cloud channel 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, ~.CloudChannelServiceTransport]): 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 = CloudChannelServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def list_customers(self, + request: service.ListCustomersRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCustomersAsyncPager: + r"""List [Customer][google.cloud.channel.v1.Customer]s. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: List of + [Customer][google.cloud.channel.v1.Customer]s, or an empty list + if there are no customers. + + Args: + request (:class:`google.cloud.channel_v1.types.ListCustomersRequest`): + The request object. Request message for + [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListCustomersAsyncPager: + Response message for + [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + request = service.ListCustomersRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_customers, + 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.ListCustomersAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_customer(self, + request: service.GetCustomerRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> customers.Customer: + r"""Returns the requested + [Customer][google.cloud.channel.v1.Customer] resource. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer resource doesn't exist. Usually the + result of an invalid name parameter. + + Return value: The [Customer][google.cloud.channel.v1.Customer] + resource. + + Args: + request (:class:`google.cloud.channel_v1.types.GetCustomerRequest`): + The request object. Request message for + [CloudChannelService.GetCustomer][google.cloud.channel.v1.CloudChannelService.GetCustomer]. + name (:class:`str`): + Required. The resource name of the customer to retrieve. + Name uses the format: + accounts/{account_id}/customers/{customer_id} + + 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.channel_v1.types.Customer: + Entity representing a customer of a + reseller or distributor. + + """ + # Create or coerce a protobuf request object. + # Sanity 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.GetCustomerRequest(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_customer, + 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 check_cloud_identity_accounts_exist(self, + request: service.CheckCloudIdentityAccountsExistRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.CheckCloudIdentityAccountsExistResponse: + r"""Confirms the existence of Cloud Identity accounts based on the + domain and if the Cloud Identity accounts are owned by the + reseller. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - INVALID_VALUE: Invalid domain value in the request. + + Return value: A list of + [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] + resources for the domain (may be empty) + + Note: in the v1alpha1 version of the API, a NOT_FOUND error + returns if no + [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] + resources match the domain. + + Args: + request (:class:`google.cloud.channel_v1.types.CheckCloudIdentityAccountsExistRequest`): + The request object. Request message for + [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.CheckCloudIdentityAccountsExistResponse: + Response message for + [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist]. + + """ + # Create or coerce a protobuf request object. + request = service.CheckCloudIdentityAccountsExistRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.check_cloud_identity_accounts_exist, + 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 create_customer(self, + request: service.CreateCustomerRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> customers.Customer: + r"""Creates a new [Customer][google.cloud.channel.v1.Customer] + resource under the reseller or distributor account. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: + + - Required request parameters are missing or invalid. + - Domain field value doesn't match the primary email domain. + + Return value: The newly created + [Customer][google.cloud.channel.v1.Customer] resource. + + Args: + request (:class:`google.cloud.channel_v1.types.CreateCustomerRequest`): + The request object. Request message for + [CloudChannelService.CreateCustomer][google.cloud.channel.v1.CloudChannelService.CreateCustomer] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Customer: + Entity representing a customer of a + reseller or distributor. + + """ + # Create or coerce a protobuf request object. + request = service.CreateCustomerRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_customer, + 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 update_customer(self, + request: service.UpdateCustomerRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> customers.Customer: + r"""Updates an existing [Customer][google.cloud.channel.v1.Customer] + resource for the reseller or distributor. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] + resource found for the name in the request. + + Return value: The updated + [Customer][google.cloud.channel.v1.Customer] resource. + + Args: + request (:class:`google.cloud.channel_v1.types.UpdateCustomerRequest`): + The request object. Request message for + [CloudChannelService.UpdateCustomer][google.cloud.channel.v1.CloudChannelService.UpdateCustomer]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Customer: + Entity representing a customer of a + reseller or distributor. + + """ + # Create or coerce a protobuf request object. + request = service.UpdateCustomerRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_customer, + 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(( + ("customer.name", request.customer.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_customer(self, + request: service.DeleteCustomerRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes the given [Customer][google.cloud.channel.v1.Customer] + permanently. + + Possible error codes: + + - PERMISSION_DENIED: The account making the request does not + own this customer. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - FAILED_PRECONDITION: The customer has existing entitlements. + - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] + resource found for the name in the request. + + Args: + request (:class:`google.cloud.channel_v1.types.DeleteCustomerRequest`): + The request object. Request message for + [CloudChannelService.DeleteCustomer][google.cloud.channel.v1.CloudChannelService.DeleteCustomer]. + name (:class:`str`): + Required. The resource name of the + customer to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity 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.DeleteCustomerRequest(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_customer, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def import_customer(self, + request: service.ImportCustomerRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> customers.Customer: + r"""Imports a [Customer][google.cloud.channel.v1.Customer] from the + Cloud Identity associated with the provided Cloud Identity ID or + domain before a TransferEntitlements call. If a linked Customer + already exists and overwrite_if_exists is true, it will update + that Customer's data. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - NOT_FOUND: Cloud Identity doesn't exist or was deleted. + - INVALID_ARGUMENT: Required parameters are missing, or the + auth_token is expired or invalid. + - ALREADY_EXISTS: A customer already exists and has conflicting + critical fields. Requires an overwrite. + + Return value: The [Customer][google.cloud.channel.v1.Customer]. + + Args: + request (:class:`google.cloud.channel_v1.types.ImportCustomerRequest`): + The request object. Request message for + [CloudChannelService.ImportCustomer][google.cloud.channel.v1.CloudChannelService.ImportCustomer] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Customer: + Entity representing a customer of a + reseller or distributor. + + """ + # Create or coerce a protobuf request object. + request = service.ImportCustomerRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.import_customer, + 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 provision_cloud_identity(self, + request: service.ProvisionCloudIdentityRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a Cloud Identity for the given customer using the + customer's information, or the information provided here. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer was not found. + - ALREADY_EXISTS: The customer's primary email already exists. + Retry after changing the customer's primary contact email. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + contains an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (:class:`google.cloud.channel_v1.types.ProvisionCloudIdentityRequest`): + The request object. Request message for + [CloudChannelService.ProvisionCloudIdentity][google.cloud.channel.v1.CloudChannelService.ProvisionCloudIdentity] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Customer` Entity + representing a customer of a reseller or distributor. + + """ + # Create or coerce a protobuf request object. + request = service.ProvisionCloudIdentityRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.provision_cloud_identity, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("customer", request.customer), + )), + ) + + # 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, + customers.Customer, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_entitlements(self, + request: service.ListEntitlementsRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListEntitlementsAsyncPager: + r"""Lists [Entitlement][google.cloud.channel.v1.Entitlement]s + belonging to a customer. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: A list of the customer's + [Entitlement][google.cloud.channel.v1.Entitlement]s. + + Args: + request (:class:`google.cloud.channel_v1.types.ListEntitlementsRequest`): + The request object. Request message for + [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListEntitlementsAsyncPager: + Response message for + [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + request = service.ListEntitlementsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_entitlements, + 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.ListEntitlementsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_transferable_skus(self, + request: service.ListTransferableSkusRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListTransferableSkusAsyncPager: + r"""List [TransferableSku][google.cloud.channel.v1.TransferableSku]s + of a customer based on the Cloud Identity ID or Customer Name in + the request. + + Use this method to list the entitlements information of an + unowned customer. You should provide the customer's Cloud + Identity ID or Customer Name. + + Possible error codes: + + - PERMISSION_DENIED: + + - The customer doesn't belong to the reseller and has no + auth token. + - The supplied auth token is invalid. + - The reseller account making the request is different from + the reseller account in the query. + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: A list of the customer's + [TransferableSku][google.cloud.channel.v1.TransferableSku]. + + Args: + request (:class:`google.cloud.channel_v1.types.ListTransferableSkusRequest`): + The request object. Request message for + [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListTransferableSkusAsyncPager: + Response message for + [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + request = service.ListTransferableSkusRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_transferable_skus, + 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.ListTransferableSkusAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_transferable_offers(self, + request: service.ListTransferableOffersRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListTransferableOffersAsyncPager: + r"""List + [TransferableOffer][google.cloud.channel.v1.TransferableOffer]s + of a customer based on Cloud Identity ID or Customer Name in the + request. + + Use this method when a reseller gets the entitlement information + of an unowned customer. The reseller should provide the + customer's Cloud Identity ID or Customer Name. + + Possible error codes: + + - PERMISSION_DENIED: + + - The customer doesn't belong to the reseller and has no + auth token. + - The supplied auth token is invalid. + - The reseller account making the request is different from + the reseller account in the query. + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: List of + [TransferableOffer][google.cloud.channel.v1.TransferableOffer] + for the given customer and SKU. + + Args: + request (:class:`google.cloud.channel_v1.types.ListTransferableOffersRequest`): + The request object. Request message for + [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListTransferableOffersAsyncPager: + Response message for + [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + request = service.ListTransferableOffersRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_transferable_offers, + 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.ListTransferableOffersAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_entitlement(self, + request: service.GetEntitlementRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> entitlements.Entitlement: + r"""Returns the requested + [Entitlement][google.cloud.channel.v1.Entitlement] resource. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer entitlement was not found. + + Return value: The requested + [Entitlement][google.cloud.channel.v1.Entitlement] resource. + + Args: + request (:class:`google.cloud.channel_v1.types.GetEntitlementRequest`): + The request object. Request message for + [CloudChannelService.GetEntitlement][google.cloud.channel.v1.CloudChannelService.GetEntitlement]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement: + An entitlement is a representation of + a customer's ability to use a service. + + """ + # Create or coerce a protobuf request object. + request = service.GetEntitlementRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_entitlement, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_entitlement(self, + request: service.CreateEntitlementRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates an entitlement for a customer. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: + + - Required request parameters are missing or invalid. + - There is already a customer entitlement for a SKU from the + same product family. + + - INVALID_VALUE: Make sure the OfferId is valid. If it is, + contact Google Channel support for further troubleshooting. + - NOT_FOUND: The customer or offer resource was not found. + - ALREADY_EXISTS: + + - The SKU was already purchased for the customer. + - The customer's primary email already exists. Retry after + changing the customer's primary contact email. + + - CONDITION_NOT_MET or FAILED_PRECONDITION: + + - The domain required for purchasing a SKU has not been + verified. + - A pre-requisite SKU required to purchase an Add-On SKU is + missing. For example, Google Workspace Business Starter is + required to purchase Vault or Drive. + - (Developer accounts only) Reseller and resold domain must + meet the following naming requirements: + + - Domain names must start with goog-test. + - Domain names must include the reseller domain. + + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (:class:`google.cloud.channel_v1.types.CreateEntitlementRequest`): + The request object. Request message for + [CloudChannelService.CreateEntitlement][google.cloud.channel.v1.CloudChannelService.CreateEntitlement] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + request = service.CreateEntitlementRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_entitlement, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + async def change_parameters(self, + request: service.ChangeParametersRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Change parameters of the entitlement. + + An entitlement update is a long-running operation and it updates + the entitlement as a result of fulfillment. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. For example, the number of seats being changed is + greater than the allowed number of max seats, or decreasing + seats for a commitment based plan. + - NOT_FOUND: Entitlement resource not found. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (:class:`google.cloud.channel_v1.types.ChangeParametersRequest`): + The request object. Request message for + [CloudChannelService.ChangeParametersRequest][]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + request = service.ChangeParametersRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.change_parameters, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + async def change_renewal_settings(self, + request: service.ChangeRenewalSettingsRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the renewal settings for an existing customer + entitlement. + + An entitlement update is a long-running operation and it updates + the entitlement as a result of fulfillment. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - NOT_COMMITMENT_PLAN: Renewal Settings are only applicable for + a commitment plan. Can't enable or disable renewals for + non-commitment plans. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (:class:`google.cloud.channel_v1.types.ChangeRenewalSettingsRequest`): + The request object. Request message for + [CloudChannelService.ChangeRenewalSettings][google.cloud.channel.v1.CloudChannelService.ChangeRenewalSettings]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + request = service.ChangeRenewalSettingsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.change_renewal_settings, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + async def change_offer(self, + request: service.ChangeOfferRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the Offer for an existing customer entitlement. + + An entitlement update is a long-running operation and it updates + the entitlement as a result of fulfillment. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Offer or Entitlement resource not found. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (:class:`google.cloud.channel_v1.types.ChangeOfferRequest`): + The request object. Request message for + [CloudChannelService.ChangeOffer][google.cloud.channel.v1.CloudChannelService.ChangeOffer]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + request = service.ChangeOfferRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.change_offer, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + async def start_paid_service(self, + request: service.StartPaidServiceRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Starts paid service for a trial entitlement. + + Starts paid service for a trial entitlement immediately. This + method is only applicable if a plan is set up for a trial + entitlement but has some trial days remaining. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - FAILED_PRECONDITION/NOT_IN_TRIAL: This method only works for + entitlement on trial plans. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (:class:`google.cloud.channel_v1.types.StartPaidServiceRequest`): + The request object. Request message for + [CloudChannelService.StartPaidService][google.cloud.channel.v1.CloudChannelService.StartPaidService]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + request = service.StartPaidServiceRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.start_paid_service, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + async def suspend_entitlement(self, + request: service.SuspendEntitlementRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Suspends a previously fulfilled entitlement. + + An entitlement suspension is a long-running operation. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - NOT_ACTIVE: Entitlement is not active. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (:class:`google.cloud.channel_v1.types.SuspendEntitlementRequest`): + The request object. Request message for + [CloudChannelService.SuspendEntitlement][google.cloud.channel.v1.CloudChannelService.SuspendEntitlement]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + request = service.SuspendEntitlementRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.suspend_entitlement, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + async def cancel_entitlement(self, + request: service.CancelEntitlementRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Cancels a previously fulfilled entitlement. + + An entitlement cancellation is a long-running operation. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - FAILED_PRECONDITION: There are Google Cloud projects linked + to the Google Cloud entitlement's Cloud Billing subaccount. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - DELETION_TYPE_NOT_ALLOWED: Cancel is only allowed for Google + Workspace add-ons, or entitlements for Google Cloud's + development platform. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The response will + contain google.protobuf.Empty on success. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (:class:`google.cloud.channel_v1.types.CancelEntitlementRequest`): + The request object. Request message for + [CloudChannelService.CancelEntitlement][google.cloud.channel.v1.CloudChannelService.CancelEntitlement]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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. + request = service.CancelEntitlementRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.cancel_entitlement, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + async def activate_entitlement(self, + request: service.ActivateEntitlementRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Activates a previously suspended entitlement. Entitlements + suspended for pending ToS acceptance can't be activated using + this method. + + An entitlement activation is a long-running operation and it + updates the state of the customer entitlement. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - SUSPENSION_NOT_RESELLER_INITIATED: Can only activate + reseller-initiated suspensions and entitlements that have + accepted the TOS. + - NOT_SUSPENDED: Can only activate suspended entitlements not + in an ACTIVE state. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (:class:`google.cloud.channel_v1.types.ActivateEntitlementRequest`): + The request object. Request message for + [CloudChannelService.ActivateEntitlement][google.cloud.channel.v1.CloudChannelService.ActivateEntitlement]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + request = service.ActivateEntitlementRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.activate_entitlement, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + async def transfer_entitlements(self, + request: service.TransferEntitlementsRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Transfers customer entitlements to new reseller. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer or offer resource was not found. + - ALREADY_EXISTS: The SKU was already transferred for the + customer. + - CONDITION_NOT_MET or FAILED_PRECONDITION: + + - The SKU requires domain verification to transfer, but the + domain is not verified. + - An Add-On SKU (example, Vault or Drive) is missing the + pre-requisite SKU (example, G Suite Basic). + - (Developer accounts only) Reseller and resold domain must + meet the following naming requirements: + + - Domain names must start with goog-test. + - Domain names must include the reseller domain. + + - Specify all transferring entitlements. + + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (:class:`google.cloud.channel_v1.types.TransferEntitlementsRequest`): + The request object. Request message for + [CloudChannelService.TransferEntitlements][google.cloud.channel.v1.CloudChannelService.TransferEntitlements]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.TransferEntitlementsResponse` Response message for [CloudChannelService.TransferEntitlements][google.cloud.channel.v1.CloudChannelService.TransferEntitlements]. + This is put in the response field of + google.longrunning.Operation. + + """ + # Create or coerce a protobuf request object. + request = service.TransferEntitlementsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.transfer_entitlements, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + service.TransferEntitlementsResponse, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + async def transfer_entitlements_to_google(self, + request: service.TransferEntitlementsToGoogleRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Transfers customer entitlements from their current reseller to + Google. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer or offer resource was not found. + - ALREADY_EXISTS: The SKU was already transferred for the + customer. + - CONDITION_NOT_MET or FAILED_PRECONDITION: + + - The SKU requires domain verification to transfer, but the + domain is not verified. + - An Add-On SKU (example, Vault or Drive) is missing the + pre-requisite SKU (example, G Suite Basic). + - (Developer accounts only) Reseller and resold domain must + meet the following naming requirements: + + - Domain names must start with goog-test. + - Domain names must include the reseller domain. + + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The response will + contain google.protobuf.Empty on success. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (:class:`google.cloud.channel_v1.types.TransferEntitlementsToGoogleRequest`): + The request object. Request message for + [CloudChannelService.TransferEntitlementsToGoogle][google.cloud.channel.v1.CloudChannelService.TransferEntitlementsToGoogle]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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. + request = service.TransferEntitlementsToGoogleRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.transfer_entitlements_to_google, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_channel_partner_links(self, + request: service.ListChannelPartnerLinksRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListChannelPartnerLinksAsyncPager: + r"""List + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s + belonging to a distributor. You must be a distributor to call + this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: The list of the distributor account's + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resources. + + Args: + request (:class:`google.cloud.channel_v1.types.ListChannelPartnerLinksRequest`): + The request object. Request message for + [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListChannelPartnerLinksAsyncPager: + Response message for + [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + request = service.ListChannelPartnerLinksRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_channel_partner_links, + 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.ListChannelPartnerLinksAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_channel_partner_link(self, + request: service.GetChannelPartnerLinkRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> channel_partner_links.ChannelPartnerLink: + r"""Returns the requested + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. You must be a distributor to call this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: ChannelPartnerLink resource not found because of + an invalid channel partner link name. + + Return value: The + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. + + Args: + request (:class:`google.cloud.channel_v1.types.GetChannelPartnerLinkRequest`): + The request object. Request message for + [CloudChannelService.GetChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.GetChannelPartnerLink]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.ChannelPartnerLink: + Entity representing a link between + distributors and their indirect + resellers in an n-tier resale channel. + + """ + # Create or coerce a protobuf request object. + request = service.GetChannelPartnerLinkRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_channel_partner_link, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_channel_partner_link(self, + request: service.CreateChannelPartnerLinkRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> channel_partner_links.ChannelPartnerLink: + r"""Initiates a channel partner link between a distributor and a + reseller, or between resellers in an n-tier reseller channel. + Invited partners need to follow the invite_link_uri provided in + the response to accept. After accepting the invitation, a link + is set up between the two parties. You must be a distributor to + call this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - ALREADY_EXISTS: The ChannelPartnerLink sent in the request + already exists. + - NOT_FOUND: No Cloud Identity customer exists for provided + domain. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The new + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. + + Args: + request (:class:`google.cloud.channel_v1.types.CreateChannelPartnerLinkRequest`): + The request object. Request message for + [CloudChannelService.CreateChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.CreateChannelPartnerLink] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.ChannelPartnerLink: + Entity representing a link between + distributors and their indirect + resellers in an n-tier resale channel. + + """ + # Create or coerce a protobuf request object. + request = service.CreateChannelPartnerLinkRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_channel_partner_link, + 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 update_channel_partner_link(self, + request: service.UpdateChannelPartnerLinkRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> channel_partner_links.ChannelPartnerLink: + r"""Updates a channel partner link. Distributors call this method to + change a link's status. For example, to suspend a partner link. + You must be a distributor to call this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: + + - Required request parameters are missing or invalid. + - Link state cannot change from invited to active or + suspended. + - Cannot send reseller_cloud_identity_id, invite_url, or + name in update mask. + + - NOT_FOUND: ChannelPartnerLink resource not found. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The updated + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. + + Args: + request (:class:`google.cloud.channel_v1.types.UpdateChannelPartnerLinkRequest`): + The request object. Request message for + [CloudChannelService.UpdateChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.UpdateChannelPartnerLink] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.ChannelPartnerLink: + Entity representing a link between + distributors and their indirect + resellers in an n-tier resale channel. + + """ + # Create or coerce a protobuf request object. + request = service.UpdateChannelPartnerLinkRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_channel_partner_link, + 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 lookup_offer(self, + request: service.LookupOfferRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> offers.Offer: + r"""Returns the requested [Offer][google.cloud.channel.v1.Offer] + resource. + + Possible error codes: + + - PERMISSION_DENIED: The entitlement doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement or offer was not found. + + Return value: The [Offer][google.cloud.channel.v1.Offer] + resource. + + Args: + request (:class:`google.cloud.channel_v1.types.LookupOfferRequest`): + The request object. Request message for LookupOffer. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Offer: + Represents an offer made to resellers for purchase. + An offer is associated with a + [Sku][google.cloud.channel.v1.Sku], has a plan for + payment, a price, and defines the constraints for + buying. + + """ + # Create or coerce a protobuf request object. + request = service.LookupOfferRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.lookup_offer, + 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(( + ("entitlement", request.entitlement), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_products(self, + request: service.ListProductsRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListProductsAsyncPager: + r"""Lists the Products the reseller is authorized to sell. + + Possible error codes: + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Args: + request (:class:`google.cloud.channel_v1.types.ListProductsRequest`): + The request object. Request message for ListProducts. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListProductsAsyncPager: + Response message for ListProducts. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + request = service.ListProductsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_products, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # 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.ListProductsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_skus(self, + request: service.ListSkusRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListSkusAsyncPager: + r"""Lists the SKUs for a product the reseller is authorized to sell. + + Possible error codes: + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Args: + request (:class:`google.cloud.channel_v1.types.ListSkusRequest`): + The request object. Request message for ListSkus. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListSkusAsyncPager: + Response message for ListSkus. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + request = service.ListSkusRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_skus, + 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.ListSkusAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_offers(self, + request: service.ListOffersRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListOffersAsyncPager: + r"""Lists the Offers the reseller can sell. + + Possible error codes: + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Args: + request (:class:`google.cloud.channel_v1.types.ListOffersRequest`): + The request object. Request message for ListOffers. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListOffersAsyncPager: + Response message for ListOffers. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + request = service.ListOffersRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_offers, + 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.ListOffersAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_purchasable_skus(self, + request: service.ListPurchasableSkusRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPurchasableSkusAsyncPager: + r"""Lists the following: + + - SKUs that you can purchase for a customer + - SKUs that you can upgrade or downgrade for an entitlement. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Args: + request (:class:`google.cloud.channel_v1.types.ListPurchasableSkusRequest`): + The request object. Request message for + ListPurchasableSkus. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListPurchasableSkusAsyncPager: + Response message for + ListPurchasableSkus. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + request = service.ListPurchasableSkusRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_purchasable_skus, + 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(( + ("customer", request.customer), + )), + ) + + # 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.ListPurchasableSkusAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_purchasable_offers(self, + request: service.ListPurchasableOffersRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPurchasableOffersAsyncPager: + r"""Lists the following: + + - Offers that you can purchase for a customer. + - Offers that you can change for an entitlement. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Args: + request (:class:`google.cloud.channel_v1.types.ListPurchasableOffersRequest`): + The request object. Request message for + ListPurchasableOffers. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListPurchasableOffersAsyncPager: + Response message for + ListPurchasableOffers. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + request = service.ListPurchasableOffersRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_purchasable_offers, + 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(( + ("customer", request.customer), + )), + ) + + # 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.ListPurchasableOffersAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def register_subscriber(self, + request: service.RegisterSubscriberRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.RegisterSubscriberResponse: + r"""Registers a service account with subscriber privileges on the + Cloud Pub/Sub topic for this Channel Services account. After you + create a subscriber, you get the events through + [SubscriberEvent][google.cloud.channel.v1.SubscriberEvent] + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request + and the provided reseller account are different, or the + impersonated user is not a super admin. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The topic name with the registered service email + address. + + Args: + request (:class:`google.cloud.channel_v1.types.RegisterSubscriberRequest`): + The request object. Request Message for + RegisterSubscriber. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.RegisterSubscriberResponse: + Response Message for + RegisterSubscriber. + + """ + # Create or coerce a protobuf request object. + request = service.RegisterSubscriberRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.register_subscriber, + 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(( + ("account", request.account), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def unregister_subscriber(self, + request: service.UnregisterSubscriberRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.UnregisterSubscriberResponse: + r"""Unregisters a service account with subscriber privileges on the + Cloud Pub/Sub topic created for this Channel Services account. + If there are no service accounts left with subscriber + privileges, this deletes the topic. You can call ListSubscribers + to check for these accounts. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request + and the provided reseller account are different, or the + impersonated user is not a super admin. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The topic resource doesn't exist. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The topic name that unregistered the service email + address. Returns a success response if the service email address + wasn't registered with the topic. + + Args: + request (:class:`google.cloud.channel_v1.types.UnregisterSubscriberRequest`): + The request object. Request Message for + UnregisterSubscriber. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.UnregisterSubscriberResponse: + Response Message for + UnregisterSubscriber. + + """ + # Create or coerce a protobuf request object. + request = service.UnregisterSubscriberRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.unregister_subscriber, + 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(( + ("account", request.account), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_subscribers(self, + request: service.ListSubscribersRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListSubscribersAsyncPager: + r"""Lists service accounts with subscriber privileges on the Cloud + Pub/Sub topic created for this Channel Services account. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request + and the provided reseller account are different, or the + impersonated user is not a super admin. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The topic resource doesn't exist. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: A list of service email addresses. + + Args: + request (:class:`google.cloud.channel_v1.types.ListSubscribersRequest`): + The request object. Request Message for ListSubscribers. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListSubscribersAsyncPager: + Response Message for ListSubscribers. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + request = service.ListSubscribersRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_subscribers, + 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(( + ("account", request.account), + )), + ) + + # 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.ListSubscribersAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-channel", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "CloudChannelServiceAsyncClient", +) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/client.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/client.py new file mode 100644 index 0000000..6c4c556 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/client.py @@ -0,0 +1,3355 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 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.channel_v1.services.cloud_channel_service import pagers +from google.cloud.channel_v1.types import channel_partner_links +from google.cloud.channel_v1.types import common +from google.cloud.channel_v1.types import customers +from google.cloud.channel_v1.types import entitlements +from google.cloud.channel_v1.types import offers +from google.cloud.channel_v1.types import operations +from google.cloud.channel_v1.types import products +from google.cloud.channel_v1.types import service +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import postal_address_pb2 # type: ignore +from .transports.base import CloudChannelServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import CloudChannelServiceGrpcTransport +from .transports.grpc_asyncio import CloudChannelServiceGrpcAsyncIOTransport + + +class CloudChannelServiceClientMeta(type): + """Metaclass for the CloudChannelService 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[CloudChannelServiceTransport]] + _transport_registry["grpc"] = CloudChannelServiceGrpcTransport + _transport_registry["grpc_asyncio"] = CloudChannelServiceGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[CloudChannelServiceTransport]: + """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 CloudChannelServiceClient(metaclass=CloudChannelServiceClientMeta): + """CloudChannelService lets Google cloud resellers and distributors + manage their customers, channel partners, entitlements, and reports. + + Using this service: + + 1. Resellers and distributors can manage a customer entity. + 2. Distributors can register an authorized reseller in their channel + and provide them with delegated admin access. + 3. Resellers and distributors can manage customer entitlements. + + CloudChannelService exposes the following resources: + + - [Customer][google.cloud.channel.v1.Customer]s: An entity—usually + an enterprise—managed by a reseller or distributor. + + - [Entitlement][google.cloud.channel.v1.Entitlement]s: An entity + that provides a customer with the means to use a service. + Entitlements are created or updated as a result of a successful + fulfillment. + + - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s: + An entity that identifies links between distributors and their + indirect resellers in a channel. + """ + + @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 = "cloudchannel.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: + CloudChannelServiceClient: 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: + CloudChannelServiceClient: 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) -> CloudChannelServiceTransport: + """Returns the transport used by the client instance. + + Returns: + CloudChannelServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def customer_path(account: str,customer: str,) -> str: + """Returns a fully-qualified customer string.""" + return "accounts/{account}/customers/{customer}".format(account=account, customer=customer, ) + + @staticmethod + def parse_customer_path(path: str) -> Dict[str,str]: + """Parses a customer path into its component segments.""" + m = re.match(r"^accounts/(?P.+?)/customers/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def entitlement_path(account: str,customer: str,entitlement: str,) -> str: + """Returns a fully-qualified entitlement string.""" + return "accounts/{account}/customers/{customer}/entitlements/{entitlement}".format(account=account, customer=customer, entitlement=entitlement, ) + + @staticmethod + def parse_entitlement_path(path: str) -> Dict[str,str]: + """Parses a entitlement path into its component segments.""" + m = re.match(r"^accounts/(?P.+?)/customers/(?P.+?)/entitlements/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def offer_path(account: str,offer: str,) -> str: + """Returns a fully-qualified offer string.""" + return "accounts/{account}/offers/{offer}".format(account=account, offer=offer, ) + + @staticmethod + def parse_offer_path(path: str) -> Dict[str,str]: + """Parses a offer path into its component segments.""" + m = re.match(r"^accounts/(?P.+?)/offers/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def product_path(product: str,) -> str: + """Returns a fully-qualified product string.""" + return "products/{product}".format(product=product, ) + + @staticmethod + def parse_product_path(path: str) -> Dict[str,str]: + """Parses a product path into its component segments.""" + m = re.match(r"^products/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def sku_path(product: str,sku: str,) -> str: + """Returns a fully-qualified sku string.""" + return "products/{product}/skus/{sku}".format(product=product, sku=sku, ) + + @staticmethod + def parse_sku_path(path: str) -> Dict[str,str]: + """Parses a sku path into its component segments.""" + m = re.match(r"^products/(?P.+?)/skus/(?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, CloudChannelServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the cloud channel 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, CloudChannelServiceTransport]): 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, CloudChannelServiceTransport): + # transport is a CloudChannelServiceTransport 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, + always_use_jwt_access=True, + ) + + def list_customers(self, + request: Union[service.ListCustomersRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListCustomersPager: + r"""List [Customer][google.cloud.channel.v1.Customer]s. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: List of + [Customer][google.cloud.channel.v1.Customer]s, or an empty list + if there are no customers. + + Args: + request (Union[google.cloud.channel_v1.types.ListCustomersRequest, dict]): + The request object. Request message for + [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListCustomersPager: + Response message for + [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ListCustomersRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListCustomersRequest): + request = service.ListCustomersRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_customers] + + # 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.ListCustomersPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_customer(self, + request: Union[service.GetCustomerRequest, dict] = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> customers.Customer: + r"""Returns the requested + [Customer][google.cloud.channel.v1.Customer] resource. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer resource doesn't exist. Usually the + result of an invalid name parameter. + + Return value: The [Customer][google.cloud.channel.v1.Customer] + resource. + + Args: + request (Union[google.cloud.channel_v1.types.GetCustomerRequest, dict]): + The request object. Request message for + [CloudChannelService.GetCustomer][google.cloud.channel.v1.CloudChannelService.GetCustomer]. + name (str): + Required. The resource name of the customer to retrieve. + Name uses the format: + accounts/{account_id}/customers/{customer_id} + + 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.channel_v1.types.Customer: + Entity representing a customer of a + reseller or distributor. + + """ + # Create or coerce a protobuf request object. + # Sanity 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.GetCustomerRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetCustomerRequest): + request = service.GetCustomerRequest(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_customer] + + # Certain 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 check_cloud_identity_accounts_exist(self, + request: Union[service.CheckCloudIdentityAccountsExistRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.CheckCloudIdentityAccountsExistResponse: + r"""Confirms the existence of Cloud Identity accounts based on the + domain and if the Cloud Identity accounts are owned by the + reseller. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - INVALID_VALUE: Invalid domain value in the request. + + Return value: A list of + [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] + resources for the domain (may be empty) + + Note: in the v1alpha1 version of the API, a NOT_FOUND error + returns if no + [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] + resources match the domain. + + Args: + request (Union[google.cloud.channel_v1.types.CheckCloudIdentityAccountsExistRequest, dict]): + The request object. Request message for + [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.CheckCloudIdentityAccountsExistResponse: + Response message for + [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist]. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.CheckCloudIdentityAccountsExistRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CheckCloudIdentityAccountsExistRequest): + request = service.CheckCloudIdentityAccountsExistRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.check_cloud_identity_accounts_exist] + + # 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 create_customer(self, + request: Union[service.CreateCustomerRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> customers.Customer: + r"""Creates a new [Customer][google.cloud.channel.v1.Customer] + resource under the reseller or distributor account. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: + + - Required request parameters are missing or invalid. + - Domain field value doesn't match the primary email domain. + + Return value: The newly created + [Customer][google.cloud.channel.v1.Customer] resource. + + Args: + request (Union[google.cloud.channel_v1.types.CreateCustomerRequest, dict]): + The request object. Request message for + [CloudChannelService.CreateCustomer][google.cloud.channel.v1.CloudChannelService.CreateCustomer] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Customer: + Entity representing a customer of a + reseller or distributor. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.CreateCustomerRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateCustomerRequest): + request = service.CreateCustomerRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_customer] + + # 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 update_customer(self, + request: Union[service.UpdateCustomerRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> customers.Customer: + r"""Updates an existing [Customer][google.cloud.channel.v1.Customer] + resource for the reseller or distributor. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] + resource found for the name in the request. + + Return value: The updated + [Customer][google.cloud.channel.v1.Customer] resource. + + Args: + request (Union[google.cloud.channel_v1.types.UpdateCustomerRequest, dict]): + The request object. Request message for + [CloudChannelService.UpdateCustomer][google.cloud.channel.v1.CloudChannelService.UpdateCustomer]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Customer: + Entity representing a customer of a + reseller or distributor. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.UpdateCustomerRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateCustomerRequest): + request = service.UpdateCustomerRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_customer] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("customer.name", request.customer.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_customer(self, + request: Union[service.DeleteCustomerRequest, dict] = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes the given [Customer][google.cloud.channel.v1.Customer] + permanently. + + Possible error codes: + + - PERMISSION_DENIED: The account making the request does not + own this customer. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - FAILED_PRECONDITION: The customer has existing entitlements. + - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] + resource found for the name in the request. + + Args: + request (Union[google.cloud.channel_v1.types.DeleteCustomerRequest, dict]): + The request object. Request message for + [CloudChannelService.DeleteCustomer][google.cloud.channel.v1.CloudChannelService.DeleteCustomer]. + name (str): + Required. The resource name of the + customer to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity 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.DeleteCustomerRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.DeleteCustomerRequest): + request = service.DeleteCustomerRequest(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_customer] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def import_customer(self, + request: Union[service.ImportCustomerRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> customers.Customer: + r"""Imports a [Customer][google.cloud.channel.v1.Customer] from the + Cloud Identity associated with the provided Cloud Identity ID or + domain before a TransferEntitlements call. If a linked Customer + already exists and overwrite_if_exists is true, it will update + that Customer's data. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - NOT_FOUND: Cloud Identity doesn't exist or was deleted. + - INVALID_ARGUMENT: Required parameters are missing, or the + auth_token is expired or invalid. + - ALREADY_EXISTS: A customer already exists and has conflicting + critical fields. Requires an overwrite. + + Return value: The [Customer][google.cloud.channel.v1.Customer]. + + Args: + request (Union[google.cloud.channel_v1.types.ImportCustomerRequest, dict]): + The request object. Request message for + [CloudChannelService.ImportCustomer][google.cloud.channel.v1.CloudChannelService.ImportCustomer] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Customer: + Entity representing a customer of a + reseller or distributor. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ImportCustomerRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ImportCustomerRequest): + request = service.ImportCustomerRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.import_customer] + + # 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 provision_cloud_identity(self, + request: Union[service.ProvisionCloudIdentityRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates a Cloud Identity for the given customer using the + customer's information, or the information provided here. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer was not found. + - ALREADY_EXISTS: The customer's primary email already exists. + Retry after changing the customer's primary contact email. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + contains an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (Union[google.cloud.channel_v1.types.ProvisionCloudIdentityRequest, dict]): + The request object. Request message for + [CloudChannelService.ProvisionCloudIdentity][google.cloud.channel.v1.CloudChannelService.ProvisionCloudIdentity] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Customer` Entity + representing a customer of a reseller or distributor. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ProvisionCloudIdentityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ProvisionCloudIdentityRequest): + request = service.ProvisionCloudIdentityRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.provision_cloud_identity] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("customer", request.customer), + )), + ) + + # 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, + customers.Customer, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_entitlements(self, + request: Union[service.ListEntitlementsRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListEntitlementsPager: + r"""Lists [Entitlement][google.cloud.channel.v1.Entitlement]s + belonging to a customer. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: A list of the customer's + [Entitlement][google.cloud.channel.v1.Entitlement]s. + + Args: + request (Union[google.cloud.channel_v1.types.ListEntitlementsRequest, dict]): + The request object. Request message for + [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListEntitlementsPager: + Response message for + [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ListEntitlementsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListEntitlementsRequest): + request = service.ListEntitlementsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_entitlements] + + # 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.ListEntitlementsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_transferable_skus(self, + request: Union[service.ListTransferableSkusRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListTransferableSkusPager: + r"""List [TransferableSku][google.cloud.channel.v1.TransferableSku]s + of a customer based on the Cloud Identity ID or Customer Name in + the request. + + Use this method to list the entitlements information of an + unowned customer. You should provide the customer's Cloud + Identity ID or Customer Name. + + Possible error codes: + + - PERMISSION_DENIED: + + - The customer doesn't belong to the reseller and has no + auth token. + - The supplied auth token is invalid. + - The reseller account making the request is different from + the reseller account in the query. + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: A list of the customer's + [TransferableSku][google.cloud.channel.v1.TransferableSku]. + + Args: + request (Union[google.cloud.channel_v1.types.ListTransferableSkusRequest, dict]): + The request object. Request message for + [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListTransferableSkusPager: + Response message for + [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ListTransferableSkusRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListTransferableSkusRequest): + request = service.ListTransferableSkusRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_transferable_skus] + + # 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.ListTransferableSkusPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_transferable_offers(self, + request: Union[service.ListTransferableOffersRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListTransferableOffersPager: + r"""List + [TransferableOffer][google.cloud.channel.v1.TransferableOffer]s + of a customer based on Cloud Identity ID or Customer Name in the + request. + + Use this method when a reseller gets the entitlement information + of an unowned customer. The reseller should provide the + customer's Cloud Identity ID or Customer Name. + + Possible error codes: + + - PERMISSION_DENIED: + + - The customer doesn't belong to the reseller and has no + auth token. + - The supplied auth token is invalid. + - The reseller account making the request is different from + the reseller account in the query. + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: List of + [TransferableOffer][google.cloud.channel.v1.TransferableOffer] + for the given customer and SKU. + + Args: + request (Union[google.cloud.channel_v1.types.ListTransferableOffersRequest, dict]): + The request object. Request message for + [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListTransferableOffersPager: + Response message for + [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ListTransferableOffersRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListTransferableOffersRequest): + request = service.ListTransferableOffersRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_transferable_offers] + + # 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.ListTransferableOffersPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_entitlement(self, + request: Union[service.GetEntitlementRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> entitlements.Entitlement: + r"""Returns the requested + [Entitlement][google.cloud.channel.v1.Entitlement] resource. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer entitlement was not found. + + Return value: The requested + [Entitlement][google.cloud.channel.v1.Entitlement] resource. + + Args: + request (Union[google.cloud.channel_v1.types.GetEntitlementRequest, dict]): + The request object. Request message for + [CloudChannelService.GetEntitlement][google.cloud.channel.v1.CloudChannelService.GetEntitlement]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement: + An entitlement is a representation of + a customer's ability to use a service. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.GetEntitlementRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetEntitlementRequest): + request = service.GetEntitlementRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_entitlement] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_entitlement(self, + request: Union[service.CreateEntitlementRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates an entitlement for a customer. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: + + - Required request parameters are missing or invalid. + - There is already a customer entitlement for a SKU from the + same product family. + + - INVALID_VALUE: Make sure the OfferId is valid. If it is, + contact Google Channel support for further troubleshooting. + - NOT_FOUND: The customer or offer resource was not found. + - ALREADY_EXISTS: + + - The SKU was already purchased for the customer. + - The customer's primary email already exists. Retry after + changing the customer's primary contact email. + + - CONDITION_NOT_MET or FAILED_PRECONDITION: + + - The domain required for purchasing a SKU has not been + verified. + - A pre-requisite SKU required to purchase an Add-On SKU is + missing. For example, Google Workspace Business Starter is + required to purchase Vault or Drive. + - (Developer accounts only) Reseller and resold domain must + meet the following naming requirements: + + - Domain names must start with goog-test. + - Domain names must include the reseller domain. + + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (Union[google.cloud.channel_v1.types.CreateEntitlementRequest, dict]): + The request object. Request message for + [CloudChannelService.CreateEntitlement][google.cloud.channel.v1.CloudChannelService.CreateEntitlement] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.CreateEntitlementRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateEntitlementRequest): + request = service.CreateEntitlementRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_entitlement] + + # 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, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + def change_parameters(self, + request: Union[service.ChangeParametersRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Change parameters of the entitlement. + + An entitlement update is a long-running operation and it updates + the entitlement as a result of fulfillment. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. For example, the number of seats being changed is + greater than the allowed number of max seats, or decreasing + seats for a commitment based plan. + - NOT_FOUND: Entitlement resource not found. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (Union[google.cloud.channel_v1.types.ChangeParametersRequest, dict]): + The request object. Request message for + [CloudChannelService.ChangeParametersRequest][]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ChangeParametersRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ChangeParametersRequest): + request = service.ChangeParametersRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.change_parameters] + + # Certain 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, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + def change_renewal_settings(self, + request: Union[service.ChangeRenewalSettingsRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Updates the renewal settings for an existing customer + entitlement. + + An entitlement update is a long-running operation and it updates + the entitlement as a result of fulfillment. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - NOT_COMMITMENT_PLAN: Renewal Settings are only applicable for + a commitment plan. Can't enable or disable renewals for + non-commitment plans. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (Union[google.cloud.channel_v1.types.ChangeRenewalSettingsRequest, dict]): + The request object. Request message for + [CloudChannelService.ChangeRenewalSettings][google.cloud.channel.v1.CloudChannelService.ChangeRenewalSettings]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ChangeRenewalSettingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ChangeRenewalSettingsRequest): + request = service.ChangeRenewalSettingsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.change_renewal_settings] + + # Certain 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, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + def change_offer(self, + request: Union[service.ChangeOfferRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Updates the Offer for an existing customer entitlement. + + An entitlement update is a long-running operation and it updates + the entitlement as a result of fulfillment. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Offer or Entitlement resource not found. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (Union[google.cloud.channel_v1.types.ChangeOfferRequest, dict]): + The request object. Request message for + [CloudChannelService.ChangeOffer][google.cloud.channel.v1.CloudChannelService.ChangeOffer]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ChangeOfferRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ChangeOfferRequest): + request = service.ChangeOfferRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.change_offer] + + # Certain 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, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + def start_paid_service(self, + request: Union[service.StartPaidServiceRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Starts paid service for a trial entitlement. + + Starts paid service for a trial entitlement immediately. This + method is only applicable if a plan is set up for a trial + entitlement but has some trial days remaining. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - FAILED_PRECONDITION/NOT_IN_TRIAL: This method only works for + entitlement on trial plans. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (Union[google.cloud.channel_v1.types.StartPaidServiceRequest, dict]): + The request object. Request message for + [CloudChannelService.StartPaidService][google.cloud.channel.v1.CloudChannelService.StartPaidService]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.StartPaidServiceRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.StartPaidServiceRequest): + request = service.StartPaidServiceRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.start_paid_service] + + # Certain 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, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + def suspend_entitlement(self, + request: Union[service.SuspendEntitlementRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Suspends a previously fulfilled entitlement. + + An entitlement suspension is a long-running operation. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - NOT_ACTIVE: Entitlement is not active. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (Union[google.cloud.channel_v1.types.SuspendEntitlementRequest, dict]): + The request object. Request message for + [CloudChannelService.SuspendEntitlement][google.cloud.channel.v1.CloudChannelService.SuspendEntitlement]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.SuspendEntitlementRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.SuspendEntitlementRequest): + request = service.SuspendEntitlementRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.suspend_entitlement] + + # Certain 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, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + def cancel_entitlement(self, + request: Union[service.CancelEntitlementRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Cancels a previously fulfilled entitlement. + + An entitlement cancellation is a long-running operation. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - FAILED_PRECONDITION: There are Google Cloud projects linked + to the Google Cloud entitlement's Cloud Billing subaccount. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - DELETION_TYPE_NOT_ALLOWED: Cancel is only allowed for Google + Workspace add-ons, or entitlements for Google Cloud's + development platform. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The response will + contain google.protobuf.Empty on success. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (Union[google.cloud.channel_v1.types.CancelEntitlementRequest, dict]): + The request object. Request message for + [CloudChannelService.CancelEntitlement][google.cloud.channel.v1.CloudChannelService.CancelEntitlement]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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. + # Minor optimization to avoid making a copy if the user passes + # in a service.CancelEntitlementRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CancelEntitlementRequest): + request = service.CancelEntitlementRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.cancel_entitlement] + + # Certain 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=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + def activate_entitlement(self, + request: Union[service.ActivateEntitlementRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Activates a previously suspended entitlement. Entitlements + suspended for pending ToS acceptance can't be activated using + this method. + + An entitlement activation is a long-running operation and it + updates the state of the customer entitlement. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - SUSPENSION_NOT_RESELLER_INITIATED: Can only activate + reseller-initiated suspensions and entitlements that have + accepted the TOS. + - NOT_SUSPENDED: Can only activate suspended entitlements not + in an ACTIVE state. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (Union[google.cloud.channel_v1.types.ActivateEntitlementRequest, dict]): + The request object. Request message for + [CloudChannelService.ActivateEntitlement][google.cloud.channel.v1.CloudChannelService.ActivateEntitlement]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Entitlement` An + entitlement is a representation of a customer's ability + to use a service. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ActivateEntitlementRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ActivateEntitlementRequest): + request = service.ActivateEntitlementRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.activate_entitlement] + + # Certain 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, + entitlements.Entitlement, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + def transfer_entitlements(self, + request: Union[service.TransferEntitlementsRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Transfers customer entitlements to new reseller. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer or offer resource was not found. + - ALREADY_EXISTS: The SKU was already transferred for the + customer. + - CONDITION_NOT_MET or FAILED_PRECONDITION: + + - The SKU requires domain verification to transfer, but the + domain is not verified. + - An Add-On SKU (example, Vault or Drive) is missing the + pre-requisite SKU (example, G Suite Basic). + - (Developer accounts only) Reseller and resold domain must + meet the following naming requirements: + + - Domain names must start with goog-test. + - Domain names must include the reseller domain. + + - Specify all transferring entitlements. + + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (Union[google.cloud.channel_v1.types.TransferEntitlementsRequest, dict]): + The request object. Request message for + [CloudChannelService.TransferEntitlements][google.cloud.channel.v1.CloudChannelService.TransferEntitlements]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.TransferEntitlementsResponse` Response message for [CloudChannelService.TransferEntitlements][google.cloud.channel.v1.CloudChannelService.TransferEntitlements]. + This is put in the response field of + google.longrunning.Operation. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.TransferEntitlementsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.TransferEntitlementsRequest): + request = service.TransferEntitlementsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.transfer_entitlements] + + # 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, + service.TransferEntitlementsResponse, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + def transfer_entitlements_to_google(self, + request: Union[service.TransferEntitlementsToGoogleRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Transfers customer entitlements from their current reseller to + Google. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer or offer resource was not found. + - ALREADY_EXISTS: The SKU was already transferred for the + customer. + - CONDITION_NOT_MET or FAILED_PRECONDITION: + + - The SKU requires domain verification to transfer, but the + domain is not verified. + - An Add-On SKU (example, Vault or Drive) is missing the + pre-requisite SKU (example, G Suite Basic). + - (Developer accounts only) Reseller and resold domain must + meet the following naming requirements: + + - Domain names must start with goog-test. + - Domain names must include the reseller domain. + + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The response will + contain google.protobuf.Empty on success. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Args: + request (Union[google.cloud.channel_v1.types.TransferEntitlementsToGoogleRequest, dict]): + The request object. Request message for + [CloudChannelService.TransferEntitlementsToGoogle][google.cloud.channel.v1.CloudChannelService.TransferEntitlementsToGoogle]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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. + # Minor optimization to avoid making a copy if the user passes + # in a service.TransferEntitlementsToGoogleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.TransferEntitlementsToGoogleRequest): + request = service.TransferEntitlementsToGoogleRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.transfer_entitlements_to_google] + + # 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, + empty_pb2.Empty, + metadata_type=operations.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_channel_partner_links(self, + request: Union[service.ListChannelPartnerLinksRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListChannelPartnerLinksPager: + r"""List + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s + belonging to a distributor. You must be a distributor to call + this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: The list of the distributor account's + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resources. + + Args: + request (Union[google.cloud.channel_v1.types.ListChannelPartnerLinksRequest, dict]): + The request object. Request message for + [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListChannelPartnerLinksPager: + Response message for + [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ListChannelPartnerLinksRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListChannelPartnerLinksRequest): + request = service.ListChannelPartnerLinksRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_channel_partner_links] + + # 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.ListChannelPartnerLinksPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_channel_partner_link(self, + request: Union[service.GetChannelPartnerLinkRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> channel_partner_links.ChannelPartnerLink: + r"""Returns the requested + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. You must be a distributor to call this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: ChannelPartnerLink resource not found because of + an invalid channel partner link name. + + Return value: The + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. + + Args: + request (Union[google.cloud.channel_v1.types.GetChannelPartnerLinkRequest, dict]): + The request object. Request message for + [CloudChannelService.GetChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.GetChannelPartnerLink]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.ChannelPartnerLink: + Entity representing a link between + distributors and their indirect + resellers in an n-tier resale channel. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.GetChannelPartnerLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.GetChannelPartnerLinkRequest): + request = service.GetChannelPartnerLinkRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_channel_partner_link] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_channel_partner_link(self, + request: Union[service.CreateChannelPartnerLinkRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> channel_partner_links.ChannelPartnerLink: + r"""Initiates a channel partner link between a distributor and a + reseller, or between resellers in an n-tier reseller channel. + Invited partners need to follow the invite_link_uri provided in + the response to accept. After accepting the invitation, a link + is set up between the two parties. You must be a distributor to + call this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - ALREADY_EXISTS: The ChannelPartnerLink sent in the request + already exists. + - NOT_FOUND: No Cloud Identity customer exists for provided + domain. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The new + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. + + Args: + request (Union[google.cloud.channel_v1.types.CreateChannelPartnerLinkRequest, dict]): + The request object. Request message for + [CloudChannelService.CreateChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.CreateChannelPartnerLink] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.ChannelPartnerLink: + Entity representing a link between + distributors and their indirect + resellers in an n-tier resale channel. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.CreateChannelPartnerLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.CreateChannelPartnerLinkRequest): + request = service.CreateChannelPartnerLinkRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_channel_partner_link] + + # 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 update_channel_partner_link(self, + request: Union[service.UpdateChannelPartnerLinkRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> channel_partner_links.ChannelPartnerLink: + r"""Updates a channel partner link. Distributors call this method to + change a link's status. For example, to suspend a partner link. + You must be a distributor to call this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: + + - Required request parameters are missing or invalid. + - Link state cannot change from invited to active or + suspended. + - Cannot send reseller_cloud_identity_id, invite_url, or + name in update mask. + + - NOT_FOUND: ChannelPartnerLink resource not found. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The updated + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. + + Args: + request (Union[google.cloud.channel_v1.types.UpdateChannelPartnerLinkRequest, dict]): + The request object. Request message for + [CloudChannelService.UpdateChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.UpdateChannelPartnerLink] + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.ChannelPartnerLink: + Entity representing a link between + distributors and their indirect + resellers in an n-tier resale channel. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.UpdateChannelPartnerLinkRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateChannelPartnerLinkRequest): + request = service.UpdateChannelPartnerLinkRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_channel_partner_link] + + # Certain 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 lookup_offer(self, + request: Union[service.LookupOfferRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> offers.Offer: + r"""Returns the requested [Offer][google.cloud.channel.v1.Offer] + resource. + + Possible error codes: + + - PERMISSION_DENIED: The entitlement doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement or offer was not found. + + Return value: The [Offer][google.cloud.channel.v1.Offer] + resource. + + Args: + request (Union[google.cloud.channel_v1.types.LookupOfferRequest, dict]): + The request object. Request message for LookupOffer. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.Offer: + Represents an offer made to resellers for purchase. + An offer is associated with a + [Sku][google.cloud.channel.v1.Sku], has a plan for + payment, a price, and defines the constraints for + buying. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.LookupOfferRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.LookupOfferRequest): + request = service.LookupOfferRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.lookup_offer] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("entitlement", request.entitlement), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_products(self, + request: Union[service.ListProductsRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListProductsPager: + r"""Lists the Products the reseller is authorized to sell. + + Possible error codes: + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Args: + request (Union[google.cloud.channel_v1.types.ListProductsRequest, dict]): + The request object. Request message for ListProducts. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListProductsPager: + Response message for ListProducts. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ListProductsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListProductsRequest): + request = service.ListProductsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_products] + + # 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.ListProductsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_skus(self, + request: Union[service.ListSkusRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListSkusPager: + r"""Lists the SKUs for a product the reseller is authorized to sell. + + Possible error codes: + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Args: + request (Union[google.cloud.channel_v1.types.ListSkusRequest, dict]): + The request object. Request message for ListSkus. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListSkusPager: + Response message for ListSkus. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ListSkusRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListSkusRequest): + request = service.ListSkusRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_skus] + + # 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.ListSkusPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_offers(self, + request: Union[service.ListOffersRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListOffersPager: + r"""Lists the Offers the reseller can sell. + + Possible error codes: + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Args: + request (Union[google.cloud.channel_v1.types.ListOffersRequest, dict]): + The request object. Request message for ListOffers. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListOffersPager: + Response message for ListOffers. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ListOffersRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListOffersRequest): + request = service.ListOffersRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_offers] + + # 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.ListOffersPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_purchasable_skus(self, + request: Union[service.ListPurchasableSkusRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPurchasableSkusPager: + r"""Lists the following: + + - SKUs that you can purchase for a customer + - SKUs that you can upgrade or downgrade for an entitlement. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Args: + request (Union[google.cloud.channel_v1.types.ListPurchasableSkusRequest, dict]): + The request object. Request message for + ListPurchasableSkus. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListPurchasableSkusPager: + Response message for + ListPurchasableSkus. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ListPurchasableSkusRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListPurchasableSkusRequest): + request = service.ListPurchasableSkusRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_purchasable_skus] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("customer", request.customer), + )), + ) + + # 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.ListPurchasableSkusPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_purchasable_offers(self, + request: Union[service.ListPurchasableOffersRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPurchasableOffersPager: + r"""Lists the following: + + - Offers that you can purchase for a customer. + - Offers that you can change for an entitlement. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Args: + request (Union[google.cloud.channel_v1.types.ListPurchasableOffersRequest, dict]): + The request object. Request message for + ListPurchasableOffers. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListPurchasableOffersPager: + Response message for + ListPurchasableOffers. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ListPurchasableOffersRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListPurchasableOffersRequest): + request = service.ListPurchasableOffersRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_purchasable_offers] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("customer", request.customer), + )), + ) + + # 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.ListPurchasableOffersPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def register_subscriber(self, + request: Union[service.RegisterSubscriberRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.RegisterSubscriberResponse: + r"""Registers a service account with subscriber privileges on the + Cloud Pub/Sub topic for this Channel Services account. After you + create a subscriber, you get the events through + [SubscriberEvent][google.cloud.channel.v1.SubscriberEvent] + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request + and the provided reseller account are different, or the + impersonated user is not a super admin. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The topic name with the registered service email + address. + + Args: + request (Union[google.cloud.channel_v1.types.RegisterSubscriberRequest, dict]): + The request object. Request Message for + RegisterSubscriber. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.RegisterSubscriberResponse: + Response Message for + RegisterSubscriber. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.RegisterSubscriberRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.RegisterSubscriberRequest): + request = service.RegisterSubscriberRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.register_subscriber] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("account", request.account), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def unregister_subscriber(self, + request: Union[service.UnregisterSubscriberRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.UnregisterSubscriberResponse: + r"""Unregisters a service account with subscriber privileges on the + Cloud Pub/Sub topic created for this Channel Services account. + If there are no service accounts left with subscriber + privileges, this deletes the topic. You can call ListSubscribers + to check for these accounts. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request + and the provided reseller account are different, or the + impersonated user is not a super admin. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The topic resource doesn't exist. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The topic name that unregistered the service email + address. Returns a success response if the service email address + wasn't registered with the topic. + + Args: + request (Union[google.cloud.channel_v1.types.UnregisterSubscriberRequest, dict]): + The request object. Request Message for + UnregisterSubscriber. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.types.UnregisterSubscriberResponse: + Response Message for + UnregisterSubscriber. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.UnregisterSubscriberRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UnregisterSubscriberRequest): + request = service.UnregisterSubscriberRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.unregister_subscriber] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("account", request.account), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_subscribers(self, + request: Union[service.ListSubscribersRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListSubscribersPager: + r"""Lists service accounts with subscriber privileges on the Cloud + Pub/Sub topic created for this Channel Services account. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request + and the provided reseller account are different, or the + impersonated user is not a super admin. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The topic resource doesn't exist. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: A list of service email addresses. + + Args: + request (Union[google.cloud.channel_v1.types.ListSubscribersRequest, dict]): + The request object. Request Message for ListSubscribers. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.channel_v1.services.cloud_channel_service.pagers.ListSubscribersPager: + Response Message for ListSubscribers. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.ListSubscribersRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.ListSubscribersRequest): + request = service.ListSubscribersRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_subscribers] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("account", request.account), + )), + ) + + # 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.ListSubscribersPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-channel", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "CloudChannelServiceClient", +) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/pagers.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/pagers.py new file mode 100644 index 0000000..3aebc96 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/pagers.py @@ -0,0 +1,1365 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator + +from google.cloud.channel_v1.types import channel_partner_links +from google.cloud.channel_v1.types import customers +from google.cloud.channel_v1.types import entitlements +from google.cloud.channel_v1.types import offers +from google.cloud.channel_v1.types import products +from google.cloud.channel_v1.types import service + + +class ListCustomersPager: + """A pager for iterating through ``list_customers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListCustomersResponse` object, and + provides an ``__iter__`` method to iterate through its + ``customers`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCustomers`` requests and continue to iterate + through the ``customers`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListCustomersResponse` + 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.ListCustomersResponse], + request: service.ListCustomersRequest, + response: service.ListCustomersResponse, + *, + 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.channel_v1.types.ListCustomersRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListCustomersResponse): + 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.ListCustomersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[service.ListCustomersResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[customers.Customer]: + for page in self.pages: + yield from page.customers + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCustomersAsyncPager: + """A pager for iterating through ``list_customers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListCustomersResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``customers`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCustomers`` requests and continue to iterate + through the ``customers`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListCustomersResponse` + 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.ListCustomersResponse]], + request: service.ListCustomersRequest, + response: service.ListCustomersResponse, + *, + 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.channel_v1.types.ListCustomersRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListCustomersResponse): + 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.ListCustomersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[service.ListCustomersResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[customers.Customer]: + async def async_generator(): + async for page in self.pages: + for response in page.customers: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListEntitlementsPager: + """A pager for iterating through ``list_entitlements`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListEntitlementsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``entitlements`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListEntitlements`` requests and continue to iterate + through the ``entitlements`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListEntitlementsResponse` + 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.ListEntitlementsResponse], + request: service.ListEntitlementsRequest, + response: service.ListEntitlementsResponse, + *, + 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.channel_v1.types.ListEntitlementsRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListEntitlementsResponse): + 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.ListEntitlementsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[service.ListEntitlementsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[entitlements.Entitlement]: + for page in self.pages: + yield from page.entitlements + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListEntitlementsAsyncPager: + """A pager for iterating through ``list_entitlements`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListEntitlementsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``entitlements`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListEntitlements`` requests and continue to iterate + through the ``entitlements`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListEntitlementsResponse` + 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.ListEntitlementsResponse]], + request: service.ListEntitlementsRequest, + response: service.ListEntitlementsResponse, + *, + 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.channel_v1.types.ListEntitlementsRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListEntitlementsResponse): + 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.ListEntitlementsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[service.ListEntitlementsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[entitlements.Entitlement]: + async def async_generator(): + async for page in self.pages: + for response in page.entitlements: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListTransferableSkusPager: + """A pager for iterating through ``list_transferable_skus`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListTransferableSkusResponse` object, and + provides an ``__iter__`` method to iterate through its + ``transferable_skus`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListTransferableSkus`` requests and continue to iterate + through the ``transferable_skus`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListTransferableSkusResponse` + 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.ListTransferableSkusResponse], + request: service.ListTransferableSkusRequest, + response: service.ListTransferableSkusResponse, + *, + 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.channel_v1.types.ListTransferableSkusRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListTransferableSkusResponse): + 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.ListTransferableSkusRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[service.ListTransferableSkusResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[entitlements.TransferableSku]: + for page in self.pages: + yield from page.transferable_skus + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListTransferableSkusAsyncPager: + """A pager for iterating through ``list_transferable_skus`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListTransferableSkusResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``transferable_skus`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListTransferableSkus`` requests and continue to iterate + through the ``transferable_skus`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListTransferableSkusResponse` + 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.ListTransferableSkusResponse]], + request: service.ListTransferableSkusRequest, + response: service.ListTransferableSkusResponse, + *, + 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.channel_v1.types.ListTransferableSkusRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListTransferableSkusResponse): + 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.ListTransferableSkusRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[service.ListTransferableSkusResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[entitlements.TransferableSku]: + async def async_generator(): + async for page in self.pages: + for response in page.transferable_skus: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListTransferableOffersPager: + """A pager for iterating through ``list_transferable_offers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListTransferableOffersResponse` object, and + provides an ``__iter__`` method to iterate through its + ``transferable_offers`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListTransferableOffers`` requests and continue to iterate + through the ``transferable_offers`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListTransferableOffersResponse` + 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.ListTransferableOffersResponse], + request: service.ListTransferableOffersRequest, + response: service.ListTransferableOffersResponse, + *, + 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.channel_v1.types.ListTransferableOffersRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListTransferableOffersResponse): + 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.ListTransferableOffersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[service.ListTransferableOffersResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[service.TransferableOffer]: + for page in self.pages: + yield from page.transferable_offers + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListTransferableOffersAsyncPager: + """A pager for iterating through ``list_transferable_offers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListTransferableOffersResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``transferable_offers`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListTransferableOffers`` requests and continue to iterate + through the ``transferable_offers`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListTransferableOffersResponse` + 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.ListTransferableOffersResponse]], + request: service.ListTransferableOffersRequest, + response: service.ListTransferableOffersResponse, + *, + 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.channel_v1.types.ListTransferableOffersRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListTransferableOffersResponse): + 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.ListTransferableOffersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[service.ListTransferableOffersResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[service.TransferableOffer]: + async def async_generator(): + async for page in self.pages: + for response in page.transferable_offers: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListChannelPartnerLinksPager: + """A pager for iterating through ``list_channel_partner_links`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListChannelPartnerLinksResponse` object, and + provides an ``__iter__`` method to iterate through its + ``channel_partner_links`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListChannelPartnerLinks`` requests and continue to iterate + through the ``channel_partner_links`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListChannelPartnerLinksResponse` + 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.ListChannelPartnerLinksResponse], + request: service.ListChannelPartnerLinksRequest, + response: service.ListChannelPartnerLinksResponse, + *, + 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.channel_v1.types.ListChannelPartnerLinksRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListChannelPartnerLinksResponse): + 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.ListChannelPartnerLinksRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[service.ListChannelPartnerLinksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[channel_partner_links.ChannelPartnerLink]: + for page in self.pages: + yield from page.channel_partner_links + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListChannelPartnerLinksAsyncPager: + """A pager for iterating through ``list_channel_partner_links`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListChannelPartnerLinksResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``channel_partner_links`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListChannelPartnerLinks`` requests and continue to iterate + through the ``channel_partner_links`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListChannelPartnerLinksResponse` + 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.ListChannelPartnerLinksResponse]], + request: service.ListChannelPartnerLinksRequest, + response: service.ListChannelPartnerLinksResponse, + *, + 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.channel_v1.types.ListChannelPartnerLinksRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListChannelPartnerLinksResponse): + 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.ListChannelPartnerLinksRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[service.ListChannelPartnerLinksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[channel_partner_links.ChannelPartnerLink]: + async def async_generator(): + async for page in self.pages: + for response in page.channel_partner_links: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListProductsPager: + """A pager for iterating through ``list_products`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListProductsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``products`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListProducts`` requests and continue to iterate + through the ``products`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListProductsResponse` + 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.ListProductsResponse], + request: service.ListProductsRequest, + response: service.ListProductsResponse, + *, + 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.channel_v1.types.ListProductsRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListProductsResponse): + 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.ListProductsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[service.ListProductsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[products.Product]: + for page in self.pages: + yield from page.products + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListProductsAsyncPager: + """A pager for iterating through ``list_products`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListProductsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``products`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListProducts`` requests and continue to iterate + through the ``products`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListProductsResponse` + 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.ListProductsResponse]], + request: service.ListProductsRequest, + response: service.ListProductsResponse, + *, + 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.channel_v1.types.ListProductsRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListProductsResponse): + 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.ListProductsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[service.ListProductsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[products.Product]: + async def async_generator(): + async for page in self.pages: + for response in page.products: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListSkusPager: + """A pager for iterating through ``list_skus`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListSkusResponse` object, and + provides an ``__iter__`` method to iterate through its + ``skus`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListSkus`` requests and continue to iterate + through the ``skus`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListSkusResponse` + 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.ListSkusResponse], + request: service.ListSkusRequest, + response: service.ListSkusResponse, + *, + 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.channel_v1.types.ListSkusRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListSkusResponse): + 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.ListSkusRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[service.ListSkusResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[products.Sku]: + for page in self.pages: + yield from page.skus + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListSkusAsyncPager: + """A pager for iterating through ``list_skus`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListSkusResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``skus`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListSkus`` requests and continue to iterate + through the ``skus`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListSkusResponse` + 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.ListSkusResponse]], + request: service.ListSkusRequest, + response: service.ListSkusResponse, + *, + 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.channel_v1.types.ListSkusRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListSkusResponse): + 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.ListSkusRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[service.ListSkusResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[products.Sku]: + async def async_generator(): + async for page in self.pages: + for response in page.skus: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListOffersPager: + """A pager for iterating through ``list_offers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListOffersResponse` object, and + provides an ``__iter__`` method to iterate through its + ``offers`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListOffers`` requests and continue to iterate + through the ``offers`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListOffersResponse` + 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.ListOffersResponse], + request: service.ListOffersRequest, + response: service.ListOffersResponse, + *, + 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.channel_v1.types.ListOffersRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListOffersResponse): + 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.ListOffersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[service.ListOffersResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[offers.Offer]: + for page in self.pages: + yield from page.offers + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListOffersAsyncPager: + """A pager for iterating through ``list_offers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListOffersResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``offers`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListOffers`` requests and continue to iterate + through the ``offers`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListOffersResponse` + 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.ListOffersResponse]], + request: service.ListOffersRequest, + response: service.ListOffersResponse, + *, + 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.channel_v1.types.ListOffersRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListOffersResponse): + 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.ListOffersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[service.ListOffersResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[offers.Offer]: + async def async_generator(): + async for page in self.pages: + for response in page.offers: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListPurchasableSkusPager: + """A pager for iterating through ``list_purchasable_skus`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListPurchasableSkusResponse` object, and + provides an ``__iter__`` method to iterate through its + ``purchasable_skus`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListPurchasableSkus`` requests and continue to iterate + through the ``purchasable_skus`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListPurchasableSkusResponse` + 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.ListPurchasableSkusResponse], + request: service.ListPurchasableSkusRequest, + response: service.ListPurchasableSkusResponse, + *, + 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.channel_v1.types.ListPurchasableSkusRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListPurchasableSkusResponse): + 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.ListPurchasableSkusRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[service.ListPurchasableSkusResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[service.PurchasableSku]: + for page in self.pages: + yield from page.purchasable_skus + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListPurchasableSkusAsyncPager: + """A pager for iterating through ``list_purchasable_skus`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListPurchasableSkusResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``purchasable_skus`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListPurchasableSkus`` requests and continue to iterate + through the ``purchasable_skus`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListPurchasableSkusResponse` + 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.ListPurchasableSkusResponse]], + request: service.ListPurchasableSkusRequest, + response: service.ListPurchasableSkusResponse, + *, + 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.channel_v1.types.ListPurchasableSkusRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListPurchasableSkusResponse): + 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.ListPurchasableSkusRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[service.ListPurchasableSkusResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[service.PurchasableSku]: + async def async_generator(): + async for page in self.pages: + for response in page.purchasable_skus: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListPurchasableOffersPager: + """A pager for iterating through ``list_purchasable_offers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListPurchasableOffersResponse` object, and + provides an ``__iter__`` method to iterate through its + ``purchasable_offers`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListPurchasableOffers`` requests and continue to iterate + through the ``purchasable_offers`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListPurchasableOffersResponse` + 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.ListPurchasableOffersResponse], + request: service.ListPurchasableOffersRequest, + response: service.ListPurchasableOffersResponse, + *, + 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.channel_v1.types.ListPurchasableOffersRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListPurchasableOffersResponse): + 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.ListPurchasableOffersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[service.ListPurchasableOffersResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[service.PurchasableOffer]: + for page in self.pages: + yield from page.purchasable_offers + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListPurchasableOffersAsyncPager: + """A pager for iterating through ``list_purchasable_offers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListPurchasableOffersResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``purchasable_offers`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListPurchasableOffers`` requests and continue to iterate + through the ``purchasable_offers`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListPurchasableOffersResponse` + 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.ListPurchasableOffersResponse]], + request: service.ListPurchasableOffersRequest, + response: service.ListPurchasableOffersResponse, + *, + 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.channel_v1.types.ListPurchasableOffersRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListPurchasableOffersResponse): + 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.ListPurchasableOffersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[service.ListPurchasableOffersResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[service.PurchasableOffer]: + async def async_generator(): + async for page in self.pages: + for response in page.purchasable_offers: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListSubscribersPager: + """A pager for iterating through ``list_subscribers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListSubscribersResponse` object, and + provides an ``__iter__`` method to iterate through its + ``service_accounts`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListSubscribers`` requests and continue to iterate + through the ``service_accounts`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListSubscribersResponse` + 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.ListSubscribersResponse], + request: service.ListSubscribersRequest, + response: service.ListSubscribersResponse, + *, + 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.channel_v1.types.ListSubscribersRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListSubscribersResponse): + 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.ListSubscribersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[service.ListSubscribersResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[str]: + for page in self.pages: + yield from page.service_accounts + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListSubscribersAsyncPager: + """A pager for iterating through ``list_subscribers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.channel_v1.types.ListSubscribersResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``service_accounts`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListSubscribers`` requests and continue to iterate + through the ``service_accounts`` field on the + corresponding responses. + + All the usual :class:`google.cloud.channel_v1.types.ListSubscribersResponse` + 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.ListSubscribersResponse]], + request: service.ListSubscribersRequest, + response: service.ListSubscribersResponse, + *, + 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.channel_v1.types.ListSubscribersRequest): + The initial request object. + response (google.cloud.channel_v1.types.ListSubscribersResponse): + 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.ListSubscribersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[service.ListSubscribersResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[str]: + async def async_generator(): + async for page in self.pages: + for response in page.service_accounts: + 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/channel_v1/services/cloud_channel_service/transports/__init__.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/__init__.py new file mode 100644 index 0000000..7fd5b80 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_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 CloudChannelServiceTransport +from .grpc import CloudChannelServiceGrpcTransport +from .grpc_asyncio import CloudChannelServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[CloudChannelServiceTransport]] +_transport_registry['grpc'] = CloudChannelServiceGrpcTransport +_transport_registry['grpc_asyncio'] = CloudChannelServiceGrpcAsyncIOTransport + +__all__ = ( + 'CloudChannelServiceTransport', + 'CloudChannelServiceGrpcTransport', + 'CloudChannelServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/base.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/base.py new file mode 100644 index 0000000..a1dd62c --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/base.py @@ -0,0 +1,665 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version +import pkg_resources + +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.channel_v1.types import channel_partner_links +from google.cloud.channel_v1.types import customers +from google.cloud.channel_v1.types import entitlements +from google.cloud.channel_v1.types import offers +from google.cloud.channel_v1.types import service +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + 'google-cloud-channel', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + + +class CloudChannelServiceTransport(abc.ABC): + """Abstract transport class for CloudChannelService.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/apps.order', + ) + + DEFAULT_HOST: str = 'cloudchannel.googleapis.com' + def __init__( + self, *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ':' not in host: + host += ':443' + self._host = host + + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + + # Save the scopes. + self._scopes = scopes + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + + if credentials_file is not None: + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, + **scopes_kwargs, + quota_project_id=quota_project_id + ) + + elif credentials is None: + credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + + # If the credentials are service account credentials, then always try to use self signed JWT. + if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + credentials = credentials.with_always_use_jwt_access(True) + + # Save the credentials. + self._credentials = credentials + + # TODO(busunkim): This method is in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-auth is increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.list_customers: gapic_v1.method.wrap_method( + self.list_customers, + default_timeout=None, + client_info=client_info, + ), + self.get_customer: gapic_v1.method.wrap_method( + self.get_customer, + default_timeout=None, + client_info=client_info, + ), + self.check_cloud_identity_accounts_exist: gapic_v1.method.wrap_method( + self.check_cloud_identity_accounts_exist, + default_timeout=None, + client_info=client_info, + ), + self.create_customer: gapic_v1.method.wrap_method( + self.create_customer, + default_timeout=None, + client_info=client_info, + ), + self.update_customer: gapic_v1.method.wrap_method( + self.update_customer, + default_timeout=None, + client_info=client_info, + ), + self.delete_customer: gapic_v1.method.wrap_method( + self.delete_customer, + default_timeout=None, + client_info=client_info, + ), + self.import_customer: gapic_v1.method.wrap_method( + self.import_customer, + default_timeout=None, + client_info=client_info, + ), + self.provision_cloud_identity: gapic_v1.method.wrap_method( + self.provision_cloud_identity, + default_timeout=60.0, + client_info=client_info, + ), + self.list_entitlements: gapic_v1.method.wrap_method( + self.list_entitlements, + default_timeout=None, + client_info=client_info, + ), + self.list_transferable_skus: gapic_v1.method.wrap_method( + self.list_transferable_skus, + default_timeout=None, + client_info=client_info, + ), + self.list_transferable_offers: gapic_v1.method.wrap_method( + self.list_transferable_offers, + default_timeout=None, + client_info=client_info, + ), + self.get_entitlement: gapic_v1.method.wrap_method( + self.get_entitlement, + default_timeout=None, + client_info=client_info, + ), + self.create_entitlement: gapic_v1.method.wrap_method( + self.create_entitlement, + default_timeout=60.0, + client_info=client_info, + ), + self.change_parameters: gapic_v1.method.wrap_method( + self.change_parameters, + default_timeout=60.0, + client_info=client_info, + ), + self.change_renewal_settings: gapic_v1.method.wrap_method( + self.change_renewal_settings, + default_timeout=60.0, + client_info=client_info, + ), + self.change_offer: gapic_v1.method.wrap_method( + self.change_offer, + default_timeout=60.0, + client_info=client_info, + ), + self.start_paid_service: gapic_v1.method.wrap_method( + self.start_paid_service, + default_timeout=60.0, + client_info=client_info, + ), + self.suspend_entitlement: gapic_v1.method.wrap_method( + self.suspend_entitlement, + default_timeout=60.0, + client_info=client_info, + ), + self.cancel_entitlement: gapic_v1.method.wrap_method( + self.cancel_entitlement, + default_timeout=60.0, + client_info=client_info, + ), + self.activate_entitlement: gapic_v1.method.wrap_method( + self.activate_entitlement, + default_timeout=60.0, + client_info=client_info, + ), + self.transfer_entitlements: gapic_v1.method.wrap_method( + self.transfer_entitlements, + default_timeout=60.0, + client_info=client_info, + ), + self.transfer_entitlements_to_google: gapic_v1.method.wrap_method( + self.transfer_entitlements_to_google, + default_timeout=60.0, + client_info=client_info, + ), + self.list_channel_partner_links: gapic_v1.method.wrap_method( + self.list_channel_partner_links, + default_timeout=None, + client_info=client_info, + ), + self.get_channel_partner_link: gapic_v1.method.wrap_method( + self.get_channel_partner_link, + default_timeout=None, + client_info=client_info, + ), + self.create_channel_partner_link: gapic_v1.method.wrap_method( + self.create_channel_partner_link, + default_timeout=None, + client_info=client_info, + ), + self.update_channel_partner_link: gapic_v1.method.wrap_method( + self.update_channel_partner_link, + default_timeout=None, + client_info=client_info, + ), + self.lookup_offer: gapic_v1.method.wrap_method( + self.lookup_offer, + default_timeout=None, + client_info=client_info, + ), + self.list_products: gapic_v1.method.wrap_method( + self.list_products, + default_timeout=None, + client_info=client_info, + ), + self.list_skus: gapic_v1.method.wrap_method( + self.list_skus, + default_timeout=None, + client_info=client_info, + ), + self.list_offers: gapic_v1.method.wrap_method( + self.list_offers, + default_timeout=None, + client_info=client_info, + ), + self.list_purchasable_skus: gapic_v1.method.wrap_method( + self.list_purchasable_skus, + default_timeout=None, + client_info=client_info, + ), + self.list_purchasable_offers: gapic_v1.method.wrap_method( + self.list_purchasable_offers, + default_timeout=None, + client_info=client_info, + ), + self.register_subscriber: gapic_v1.method.wrap_method( + self.register_subscriber, + default_timeout=None, + client_info=client_info, + ), + self.unregister_subscriber: gapic_v1.method.wrap_method( + self.unregister_subscriber, + default_timeout=None, + client_info=client_info, + ), + self.list_subscribers: gapic_v1.method.wrap_method( + self.list_subscribers, + default_timeout=None, + client_info=client_info, + ), + } + + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def list_customers(self) -> Callable[ + [service.ListCustomersRequest], + Union[ + service.ListCustomersResponse, + Awaitable[service.ListCustomersResponse] + ]]: + raise NotImplementedError() + + @property + def get_customer(self) -> Callable[ + [service.GetCustomerRequest], + Union[ + customers.Customer, + Awaitable[customers.Customer] + ]]: + raise NotImplementedError() + + @property + def check_cloud_identity_accounts_exist(self) -> Callable[ + [service.CheckCloudIdentityAccountsExistRequest], + Union[ + service.CheckCloudIdentityAccountsExistResponse, + Awaitable[service.CheckCloudIdentityAccountsExistResponse] + ]]: + raise NotImplementedError() + + @property + def create_customer(self) -> Callable[ + [service.CreateCustomerRequest], + Union[ + customers.Customer, + Awaitable[customers.Customer] + ]]: + raise NotImplementedError() + + @property + def update_customer(self) -> Callable[ + [service.UpdateCustomerRequest], + Union[ + customers.Customer, + Awaitable[customers.Customer] + ]]: + raise NotImplementedError() + + @property + def delete_customer(self) -> Callable[ + [service.DeleteCustomerRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def import_customer(self) -> Callable[ + [service.ImportCustomerRequest], + Union[ + customers.Customer, + Awaitable[customers.Customer] + ]]: + raise NotImplementedError() + + @property + def provision_cloud_identity(self) -> Callable[ + [service.ProvisionCloudIdentityRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_entitlements(self) -> Callable[ + [service.ListEntitlementsRequest], + Union[ + service.ListEntitlementsResponse, + Awaitable[service.ListEntitlementsResponse] + ]]: + raise NotImplementedError() + + @property + def list_transferable_skus(self) -> Callable[ + [service.ListTransferableSkusRequest], + Union[ + service.ListTransferableSkusResponse, + Awaitable[service.ListTransferableSkusResponse] + ]]: + raise NotImplementedError() + + @property + def list_transferable_offers(self) -> Callable[ + [service.ListTransferableOffersRequest], + Union[ + service.ListTransferableOffersResponse, + Awaitable[service.ListTransferableOffersResponse] + ]]: + raise NotImplementedError() + + @property + def get_entitlement(self) -> Callable[ + [service.GetEntitlementRequest], + Union[ + entitlements.Entitlement, + Awaitable[entitlements.Entitlement] + ]]: + raise NotImplementedError() + + @property + def create_entitlement(self) -> Callable[ + [service.CreateEntitlementRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def change_parameters(self) -> Callable[ + [service.ChangeParametersRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def change_renewal_settings(self) -> Callable[ + [service.ChangeRenewalSettingsRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def change_offer(self) -> Callable[ + [service.ChangeOfferRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def start_paid_service(self) -> Callable[ + [service.StartPaidServiceRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def suspend_entitlement(self) -> Callable[ + [service.SuspendEntitlementRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def cancel_entitlement(self) -> Callable[ + [service.CancelEntitlementRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def activate_entitlement(self) -> Callable[ + [service.ActivateEntitlementRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def transfer_entitlements(self) -> Callable[ + [service.TransferEntitlementsRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def transfer_entitlements_to_google(self) -> Callable[ + [service.TransferEntitlementsToGoogleRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_channel_partner_links(self) -> Callable[ + [service.ListChannelPartnerLinksRequest], + Union[ + service.ListChannelPartnerLinksResponse, + Awaitable[service.ListChannelPartnerLinksResponse] + ]]: + raise NotImplementedError() + + @property + def get_channel_partner_link(self) -> Callable[ + [service.GetChannelPartnerLinkRequest], + Union[ + channel_partner_links.ChannelPartnerLink, + Awaitable[channel_partner_links.ChannelPartnerLink] + ]]: + raise NotImplementedError() + + @property + def create_channel_partner_link(self) -> Callable[ + [service.CreateChannelPartnerLinkRequest], + Union[ + channel_partner_links.ChannelPartnerLink, + Awaitable[channel_partner_links.ChannelPartnerLink] + ]]: + raise NotImplementedError() + + @property + def update_channel_partner_link(self) -> Callable[ + [service.UpdateChannelPartnerLinkRequest], + Union[ + channel_partner_links.ChannelPartnerLink, + Awaitable[channel_partner_links.ChannelPartnerLink] + ]]: + raise NotImplementedError() + + @property + def lookup_offer(self) -> Callable[ + [service.LookupOfferRequest], + Union[ + offers.Offer, + Awaitable[offers.Offer] + ]]: + raise NotImplementedError() + + @property + def list_products(self) -> Callable[ + [service.ListProductsRequest], + Union[ + service.ListProductsResponse, + Awaitable[service.ListProductsResponse] + ]]: + raise NotImplementedError() + + @property + def list_skus(self) -> Callable[ + [service.ListSkusRequest], + Union[ + service.ListSkusResponse, + Awaitable[service.ListSkusResponse] + ]]: + raise NotImplementedError() + + @property + def list_offers(self) -> Callable[ + [service.ListOffersRequest], + Union[ + service.ListOffersResponse, + Awaitable[service.ListOffersResponse] + ]]: + raise NotImplementedError() + + @property + def list_purchasable_skus(self) -> Callable[ + [service.ListPurchasableSkusRequest], + Union[ + service.ListPurchasableSkusResponse, + Awaitable[service.ListPurchasableSkusResponse] + ]]: + raise NotImplementedError() + + @property + def list_purchasable_offers(self) -> Callable[ + [service.ListPurchasableOffersRequest], + Union[ + service.ListPurchasableOffersResponse, + Awaitable[service.ListPurchasableOffersResponse] + ]]: + raise NotImplementedError() + + @property + def register_subscriber(self) -> Callable[ + [service.RegisterSubscriberRequest], + Union[ + service.RegisterSubscriberResponse, + Awaitable[service.RegisterSubscriberResponse] + ]]: + raise NotImplementedError() + + @property + def unregister_subscriber(self) -> Callable[ + [service.UnregisterSubscriberRequest], + Union[ + service.UnregisterSubscriberResponse, + Awaitable[service.UnregisterSubscriberResponse] + ]]: + raise NotImplementedError() + + @property + def list_subscribers(self) -> Callable[ + [service.ListSubscribersRequest], + Union[ + service.ListSubscribersResponse, + Awaitable[service.ListSubscribersResponse] + ]]: + raise NotImplementedError() + + +__all__ = ( + 'CloudChannelServiceTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc.py new file mode 100644 index 0000000..6c9c7e8 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc.py @@ -0,0 +1,1841 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.channel_v1.types import channel_partner_links +from google.cloud.channel_v1.types import customers +from google.cloud.channel_v1.types import entitlements +from google.cloud.channel_v1.types import offers +from google.cloud.channel_v1.types import service +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from .base import CloudChannelServiceTransport, DEFAULT_CLIENT_INFO + + +class CloudChannelServiceGrpcTransport(CloudChannelServiceTransport): + """gRPC backend transport for CloudChannelService. + + CloudChannelService lets Google cloud resellers and distributors + manage their customers, channel partners, entitlements, and reports. + + Using this service: + + 1. Resellers and distributors can manage a customer entity. + 2. Distributors can register an authorized reseller in their channel + and provide them with delegated admin access. + 3. Resellers and distributors can manage customer entitlements. + + CloudChannelService exposes the following resources: + + - [Customer][google.cloud.channel.v1.Customer]s: An entity—usually + an enterprise—managed by a reseller or distributor. + + - [Entitlement][google.cloud.channel.v1.Entitlement]s: An entity + that provides a customer with the means to use a service. + Entitlements are created or updated as a result of a successful + fulfillment. + + - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s: + An entity that identifies links between distributors and their + indirect resellers in a channel. + + 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 = 'cloudchannel.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, + always_use_jwt_access: Optional[bool] = False, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or application default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for the grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure a mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + ) + + 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 = 'cloudchannel.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_customers(self) -> Callable[ + [service.ListCustomersRequest], + service.ListCustomersResponse]: + r"""Return a callable for the list customers method over gRPC. + + List [Customer][google.cloud.channel.v1.Customer]s. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: List of + [Customer][google.cloud.channel.v1.Customer]s, or an empty list + if there are no customers. + + Returns: + Callable[[~.ListCustomersRequest], + ~.ListCustomersResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_customers' not in self._stubs: + self._stubs['list_customers'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListCustomers', + request_serializer=service.ListCustomersRequest.serialize, + response_deserializer=service.ListCustomersResponse.deserialize, + ) + return self._stubs['list_customers'] + + @property + def get_customer(self) -> Callable[ + [service.GetCustomerRequest], + customers.Customer]: + r"""Return a callable for the get customer method over gRPC. + + Returns the requested + [Customer][google.cloud.channel.v1.Customer] resource. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer resource doesn't exist. Usually the + result of an invalid name parameter. + + Return value: The [Customer][google.cloud.channel.v1.Customer] + resource. + + Returns: + Callable[[~.GetCustomerRequest], + ~.Customer]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_customer' not in self._stubs: + self._stubs['get_customer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/GetCustomer', + request_serializer=service.GetCustomerRequest.serialize, + response_deserializer=customers.Customer.deserialize, + ) + return self._stubs['get_customer'] + + @property + def check_cloud_identity_accounts_exist(self) -> Callable[ + [service.CheckCloudIdentityAccountsExistRequest], + service.CheckCloudIdentityAccountsExistResponse]: + r"""Return a callable for the check cloud identity accounts + exist method over gRPC. + + Confirms the existence of Cloud Identity accounts based on the + domain and if the Cloud Identity accounts are owned by the + reseller. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - INVALID_VALUE: Invalid domain value in the request. + + Return value: A list of + [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] + resources for the domain (may be empty) + + Note: in the v1alpha1 version of the API, a NOT_FOUND error + returns if no + [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] + resources match the domain. + + Returns: + Callable[[~.CheckCloudIdentityAccountsExistRequest], + ~.CheckCloudIdentityAccountsExistResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'check_cloud_identity_accounts_exist' not in self._stubs: + self._stubs['check_cloud_identity_accounts_exist'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/CheckCloudIdentityAccountsExist', + request_serializer=service.CheckCloudIdentityAccountsExistRequest.serialize, + response_deserializer=service.CheckCloudIdentityAccountsExistResponse.deserialize, + ) + return self._stubs['check_cloud_identity_accounts_exist'] + + @property + def create_customer(self) -> Callable[ + [service.CreateCustomerRequest], + customers.Customer]: + r"""Return a callable for the create customer method over gRPC. + + Creates a new [Customer][google.cloud.channel.v1.Customer] + resource under the reseller or distributor account. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: + + - Required request parameters are missing or invalid. + - Domain field value doesn't match the primary email domain. + + Return value: The newly created + [Customer][google.cloud.channel.v1.Customer] resource. + + Returns: + Callable[[~.CreateCustomerRequest], + ~.Customer]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_customer' not in self._stubs: + self._stubs['create_customer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/CreateCustomer', + request_serializer=service.CreateCustomerRequest.serialize, + response_deserializer=customers.Customer.deserialize, + ) + return self._stubs['create_customer'] + + @property + def update_customer(self) -> Callable[ + [service.UpdateCustomerRequest], + customers.Customer]: + r"""Return a callable for the update customer method over gRPC. + + Updates an existing [Customer][google.cloud.channel.v1.Customer] + resource for the reseller or distributor. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] + resource found for the name in the request. + + Return value: The updated + [Customer][google.cloud.channel.v1.Customer] resource. + + Returns: + Callable[[~.UpdateCustomerRequest], + ~.Customer]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_customer' not in self._stubs: + self._stubs['update_customer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/UpdateCustomer', + request_serializer=service.UpdateCustomerRequest.serialize, + response_deserializer=customers.Customer.deserialize, + ) + return self._stubs['update_customer'] + + @property + def delete_customer(self) -> Callable[ + [service.DeleteCustomerRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete customer method over gRPC. + + Deletes the given [Customer][google.cloud.channel.v1.Customer] + permanently. + + Possible error codes: + + - PERMISSION_DENIED: The account making the request does not + own this customer. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - FAILED_PRECONDITION: The customer has existing entitlements. + - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] + resource found for the name in the request. + + Returns: + Callable[[~.DeleteCustomerRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_customer' not in self._stubs: + self._stubs['delete_customer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/DeleteCustomer', + request_serializer=service.DeleteCustomerRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_customer'] + + @property + def import_customer(self) -> Callable[ + [service.ImportCustomerRequest], + customers.Customer]: + r"""Return a callable for the import customer method over gRPC. + + Imports a [Customer][google.cloud.channel.v1.Customer] from the + Cloud Identity associated with the provided Cloud Identity ID or + domain before a TransferEntitlements call. If a linked Customer + already exists and overwrite_if_exists is true, it will update + that Customer's data. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - NOT_FOUND: Cloud Identity doesn't exist or was deleted. + - INVALID_ARGUMENT: Required parameters are missing, or the + auth_token is expired or invalid. + - ALREADY_EXISTS: A customer already exists and has conflicting + critical fields. Requires an overwrite. + + Return value: The [Customer][google.cloud.channel.v1.Customer]. + + Returns: + Callable[[~.ImportCustomerRequest], + ~.Customer]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'import_customer' not in self._stubs: + self._stubs['import_customer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ImportCustomer', + request_serializer=service.ImportCustomerRequest.serialize, + response_deserializer=customers.Customer.deserialize, + ) + return self._stubs['import_customer'] + + @property + def provision_cloud_identity(self) -> Callable[ + [service.ProvisionCloudIdentityRequest], + operations_pb2.Operation]: + r"""Return a callable for the provision cloud identity method over gRPC. + + Creates a Cloud Identity for the given customer using the + customer's information, or the information provided here. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer was not found. + - ALREADY_EXISTS: The customer's primary email already exists. + Retry after changing the customer's primary contact email. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + contains an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.ProvisionCloudIdentityRequest], + ~.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 'provision_cloud_identity' not in self._stubs: + self._stubs['provision_cloud_identity'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ProvisionCloudIdentity', + request_serializer=service.ProvisionCloudIdentityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['provision_cloud_identity'] + + @property + def list_entitlements(self) -> Callable[ + [service.ListEntitlementsRequest], + service.ListEntitlementsResponse]: + r"""Return a callable for the list entitlements method over gRPC. + + Lists [Entitlement][google.cloud.channel.v1.Entitlement]s + belonging to a customer. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: A list of the customer's + [Entitlement][google.cloud.channel.v1.Entitlement]s. + + Returns: + Callable[[~.ListEntitlementsRequest], + ~.ListEntitlementsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_entitlements' not in self._stubs: + self._stubs['list_entitlements'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListEntitlements', + request_serializer=service.ListEntitlementsRequest.serialize, + response_deserializer=service.ListEntitlementsResponse.deserialize, + ) + return self._stubs['list_entitlements'] + + @property + def list_transferable_skus(self) -> Callable[ + [service.ListTransferableSkusRequest], + service.ListTransferableSkusResponse]: + r"""Return a callable for the list transferable skus method over gRPC. + + List [TransferableSku][google.cloud.channel.v1.TransferableSku]s + of a customer based on the Cloud Identity ID or Customer Name in + the request. + + Use this method to list the entitlements information of an + unowned customer. You should provide the customer's Cloud + Identity ID or Customer Name. + + Possible error codes: + + - PERMISSION_DENIED: + + - The customer doesn't belong to the reseller and has no + auth token. + - The supplied auth token is invalid. + - The reseller account making the request is different from + the reseller account in the query. + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: A list of the customer's + [TransferableSku][google.cloud.channel.v1.TransferableSku]. + + Returns: + Callable[[~.ListTransferableSkusRequest], + ~.ListTransferableSkusResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_transferable_skus' not in self._stubs: + self._stubs['list_transferable_skus'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListTransferableSkus', + request_serializer=service.ListTransferableSkusRequest.serialize, + response_deserializer=service.ListTransferableSkusResponse.deserialize, + ) + return self._stubs['list_transferable_skus'] + + @property + def list_transferable_offers(self) -> Callable[ + [service.ListTransferableOffersRequest], + service.ListTransferableOffersResponse]: + r"""Return a callable for the list transferable offers method over gRPC. + + List + [TransferableOffer][google.cloud.channel.v1.TransferableOffer]s + of a customer based on Cloud Identity ID or Customer Name in the + request. + + Use this method when a reseller gets the entitlement information + of an unowned customer. The reseller should provide the + customer's Cloud Identity ID or Customer Name. + + Possible error codes: + + - PERMISSION_DENIED: + + - The customer doesn't belong to the reseller and has no + auth token. + - The supplied auth token is invalid. + - The reseller account making the request is different from + the reseller account in the query. + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: List of + [TransferableOffer][google.cloud.channel.v1.TransferableOffer] + for the given customer and SKU. + + Returns: + Callable[[~.ListTransferableOffersRequest], + ~.ListTransferableOffersResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_transferable_offers' not in self._stubs: + self._stubs['list_transferable_offers'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListTransferableOffers', + request_serializer=service.ListTransferableOffersRequest.serialize, + response_deserializer=service.ListTransferableOffersResponse.deserialize, + ) + return self._stubs['list_transferable_offers'] + + @property + def get_entitlement(self) -> Callable[ + [service.GetEntitlementRequest], + entitlements.Entitlement]: + r"""Return a callable for the get entitlement method over gRPC. + + Returns the requested + [Entitlement][google.cloud.channel.v1.Entitlement] resource. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer entitlement was not found. + + Return value: The requested + [Entitlement][google.cloud.channel.v1.Entitlement] resource. + + Returns: + Callable[[~.GetEntitlementRequest], + ~.Entitlement]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_entitlement' not in self._stubs: + self._stubs['get_entitlement'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/GetEntitlement', + request_serializer=service.GetEntitlementRequest.serialize, + response_deserializer=entitlements.Entitlement.deserialize, + ) + return self._stubs['get_entitlement'] + + @property + def create_entitlement(self) -> Callable[ + [service.CreateEntitlementRequest], + operations_pb2.Operation]: + r"""Return a callable for the create entitlement method over gRPC. + + Creates an entitlement for a customer. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: + + - Required request parameters are missing or invalid. + - There is already a customer entitlement for a SKU from the + same product family. + + - INVALID_VALUE: Make sure the OfferId is valid. If it is, + contact Google Channel support for further troubleshooting. + - NOT_FOUND: The customer or offer resource was not found. + - ALREADY_EXISTS: + + - The SKU was already purchased for the customer. + - The customer's primary email already exists. Retry after + changing the customer's primary contact email. + + - CONDITION_NOT_MET or FAILED_PRECONDITION: + + - The domain required for purchasing a SKU has not been + verified. + - A pre-requisite SKU required to purchase an Add-On SKU is + missing. For example, Google Workspace Business Starter is + required to purchase Vault or Drive. + - (Developer accounts only) Reseller and resold domain must + meet the following naming requirements: + + - Domain names must start with goog-test. + - Domain names must include the reseller domain. + + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.CreateEntitlementRequest], + ~.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_entitlement' not in self._stubs: + self._stubs['create_entitlement'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/CreateEntitlement', + request_serializer=service.CreateEntitlementRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_entitlement'] + + @property + def change_parameters(self) -> Callable[ + [service.ChangeParametersRequest], + operations_pb2.Operation]: + r"""Return a callable for the change parameters method over gRPC. + + Change parameters of the entitlement. + + An entitlement update is a long-running operation and it updates + the entitlement as a result of fulfillment. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. For example, the number of seats being changed is + greater than the allowed number of max seats, or decreasing + seats for a commitment based plan. + - NOT_FOUND: Entitlement resource not found. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.ChangeParametersRequest], + ~.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 'change_parameters' not in self._stubs: + self._stubs['change_parameters'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ChangeParameters', + request_serializer=service.ChangeParametersRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['change_parameters'] + + @property + def change_renewal_settings(self) -> Callable[ + [service.ChangeRenewalSettingsRequest], + operations_pb2.Operation]: + r"""Return a callable for the change renewal settings method over gRPC. + + Updates the renewal settings for an existing customer + entitlement. + + An entitlement update is a long-running operation and it updates + the entitlement as a result of fulfillment. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - NOT_COMMITMENT_PLAN: Renewal Settings are only applicable for + a commitment plan. Can't enable or disable renewals for + non-commitment plans. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.ChangeRenewalSettingsRequest], + ~.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 'change_renewal_settings' not in self._stubs: + self._stubs['change_renewal_settings'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ChangeRenewalSettings', + request_serializer=service.ChangeRenewalSettingsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['change_renewal_settings'] + + @property + def change_offer(self) -> Callable[ + [service.ChangeOfferRequest], + operations_pb2.Operation]: + r"""Return a callable for the change offer method over gRPC. + + Updates the Offer for an existing customer entitlement. + + An entitlement update is a long-running operation and it updates + the entitlement as a result of fulfillment. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Offer or Entitlement resource not found. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.ChangeOfferRequest], + ~.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 'change_offer' not in self._stubs: + self._stubs['change_offer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ChangeOffer', + request_serializer=service.ChangeOfferRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['change_offer'] + + @property + def start_paid_service(self) -> Callable[ + [service.StartPaidServiceRequest], + operations_pb2.Operation]: + r"""Return a callable for the start paid service method over gRPC. + + Starts paid service for a trial entitlement. + + Starts paid service for a trial entitlement immediately. This + method is only applicable if a plan is set up for a trial + entitlement but has some trial days remaining. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - FAILED_PRECONDITION/NOT_IN_TRIAL: This method only works for + entitlement on trial plans. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.StartPaidServiceRequest], + ~.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 'start_paid_service' not in self._stubs: + self._stubs['start_paid_service'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/StartPaidService', + request_serializer=service.StartPaidServiceRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['start_paid_service'] + + @property + def suspend_entitlement(self) -> Callable[ + [service.SuspendEntitlementRequest], + operations_pb2.Operation]: + r"""Return a callable for the suspend entitlement method over gRPC. + + Suspends a previously fulfilled entitlement. + + An entitlement suspension is a long-running operation. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - NOT_ACTIVE: Entitlement is not active. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.SuspendEntitlementRequest], + ~.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 'suspend_entitlement' not in self._stubs: + self._stubs['suspend_entitlement'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/SuspendEntitlement', + request_serializer=service.SuspendEntitlementRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['suspend_entitlement'] + + @property + def cancel_entitlement(self) -> Callable[ + [service.CancelEntitlementRequest], + operations_pb2.Operation]: + r"""Return a callable for the cancel entitlement method over gRPC. + + Cancels a previously fulfilled entitlement. + + An entitlement cancellation is a long-running operation. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - FAILED_PRECONDITION: There are Google Cloud projects linked + to the Google Cloud entitlement's Cloud Billing subaccount. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - DELETION_TYPE_NOT_ALLOWED: Cancel is only allowed for Google + Workspace add-ons, or entitlements for Google Cloud's + development platform. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The response will + contain google.protobuf.Empty on success. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.CancelEntitlementRequest], + ~.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 'cancel_entitlement' not in self._stubs: + self._stubs['cancel_entitlement'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/CancelEntitlement', + request_serializer=service.CancelEntitlementRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['cancel_entitlement'] + + @property + def activate_entitlement(self) -> Callable[ + [service.ActivateEntitlementRequest], + operations_pb2.Operation]: + r"""Return a callable for the activate entitlement method over gRPC. + + Activates a previously suspended entitlement. Entitlements + suspended for pending ToS acceptance can't be activated using + this method. + + An entitlement activation is a long-running operation and it + updates the state of the customer entitlement. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - SUSPENSION_NOT_RESELLER_INITIATED: Can only activate + reseller-initiated suspensions and entitlements that have + accepted the TOS. + - NOT_SUSPENDED: Can only activate suspended entitlements not + in an ACTIVE state. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.ActivateEntitlementRequest], + ~.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_entitlement' not in self._stubs: + self._stubs['activate_entitlement'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ActivateEntitlement', + request_serializer=service.ActivateEntitlementRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['activate_entitlement'] + + @property + def transfer_entitlements(self) -> Callable[ + [service.TransferEntitlementsRequest], + operations_pb2.Operation]: + r"""Return a callable for the transfer entitlements method over gRPC. + + Transfers customer entitlements to new reseller. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer or offer resource was not found. + - ALREADY_EXISTS: The SKU was already transferred for the + customer. + - CONDITION_NOT_MET or FAILED_PRECONDITION: + + - The SKU requires domain verification to transfer, but the + domain is not verified. + - An Add-On SKU (example, Vault or Drive) is missing the + pre-requisite SKU (example, G Suite Basic). + - (Developer accounts only) Reseller and resold domain must + meet the following naming requirements: + + - Domain names must start with goog-test. + - Domain names must include the reseller domain. + + - Specify all transferring entitlements. + + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.TransferEntitlementsRequest], + ~.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 'transfer_entitlements' not in self._stubs: + self._stubs['transfer_entitlements'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/TransferEntitlements', + request_serializer=service.TransferEntitlementsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['transfer_entitlements'] + + @property + def transfer_entitlements_to_google(self) -> Callable[ + [service.TransferEntitlementsToGoogleRequest], + operations_pb2.Operation]: + r"""Return a callable for the transfer entitlements to + google method over gRPC. + + Transfers customer entitlements from their current reseller to + Google. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer or offer resource was not found. + - ALREADY_EXISTS: The SKU was already transferred for the + customer. + - CONDITION_NOT_MET or FAILED_PRECONDITION: + + - The SKU requires domain verification to transfer, but the + domain is not verified. + - An Add-On SKU (example, Vault or Drive) is missing the + pre-requisite SKU (example, G Suite Basic). + - (Developer accounts only) Reseller and resold domain must + meet the following naming requirements: + + - Domain names must start with goog-test. + - Domain names must include the reseller domain. + + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The response will + contain google.protobuf.Empty on success. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.TransferEntitlementsToGoogleRequest], + ~.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 'transfer_entitlements_to_google' not in self._stubs: + self._stubs['transfer_entitlements_to_google'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/TransferEntitlementsToGoogle', + request_serializer=service.TransferEntitlementsToGoogleRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['transfer_entitlements_to_google'] + + @property + def list_channel_partner_links(self) -> Callable[ + [service.ListChannelPartnerLinksRequest], + service.ListChannelPartnerLinksResponse]: + r"""Return a callable for the list channel partner links method over gRPC. + + List + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s + belonging to a distributor. You must be a distributor to call + this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: The list of the distributor account's + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resources. + + Returns: + Callable[[~.ListChannelPartnerLinksRequest], + ~.ListChannelPartnerLinksResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_channel_partner_links' not in self._stubs: + self._stubs['list_channel_partner_links'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListChannelPartnerLinks', + request_serializer=service.ListChannelPartnerLinksRequest.serialize, + response_deserializer=service.ListChannelPartnerLinksResponse.deserialize, + ) + return self._stubs['list_channel_partner_links'] + + @property + def get_channel_partner_link(self) -> Callable[ + [service.GetChannelPartnerLinkRequest], + channel_partner_links.ChannelPartnerLink]: + r"""Return a callable for the get channel partner link method over gRPC. + + Returns the requested + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. You must be a distributor to call this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: ChannelPartnerLink resource not found because of + an invalid channel partner link name. + + Return value: The + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. + + Returns: + Callable[[~.GetChannelPartnerLinkRequest], + ~.ChannelPartnerLink]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_channel_partner_link' not in self._stubs: + self._stubs['get_channel_partner_link'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/GetChannelPartnerLink', + request_serializer=service.GetChannelPartnerLinkRequest.serialize, + response_deserializer=channel_partner_links.ChannelPartnerLink.deserialize, + ) + return self._stubs['get_channel_partner_link'] + + @property + def create_channel_partner_link(self) -> Callable[ + [service.CreateChannelPartnerLinkRequest], + channel_partner_links.ChannelPartnerLink]: + r"""Return a callable for the create channel partner link method over gRPC. + + Initiates a channel partner link between a distributor and a + reseller, or between resellers in an n-tier reseller channel. + Invited partners need to follow the invite_link_uri provided in + the response to accept. After accepting the invitation, a link + is set up between the two parties. You must be a distributor to + call this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - ALREADY_EXISTS: The ChannelPartnerLink sent in the request + already exists. + - NOT_FOUND: No Cloud Identity customer exists for provided + domain. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The new + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. + + Returns: + Callable[[~.CreateChannelPartnerLinkRequest], + ~.ChannelPartnerLink]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_channel_partner_link' not in self._stubs: + self._stubs['create_channel_partner_link'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/CreateChannelPartnerLink', + request_serializer=service.CreateChannelPartnerLinkRequest.serialize, + response_deserializer=channel_partner_links.ChannelPartnerLink.deserialize, + ) + return self._stubs['create_channel_partner_link'] + + @property + def update_channel_partner_link(self) -> Callable[ + [service.UpdateChannelPartnerLinkRequest], + channel_partner_links.ChannelPartnerLink]: + r"""Return a callable for the update channel partner link method over gRPC. + + Updates a channel partner link. Distributors call this method to + change a link's status. For example, to suspend a partner link. + You must be a distributor to call this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: + + - Required request parameters are missing or invalid. + - Link state cannot change from invited to active or + suspended. + - Cannot send reseller_cloud_identity_id, invite_url, or + name in update mask. + + - NOT_FOUND: ChannelPartnerLink resource not found. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The updated + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. + + Returns: + Callable[[~.UpdateChannelPartnerLinkRequest], + ~.ChannelPartnerLink]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_channel_partner_link' not in self._stubs: + self._stubs['update_channel_partner_link'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/UpdateChannelPartnerLink', + request_serializer=service.UpdateChannelPartnerLinkRequest.serialize, + response_deserializer=channel_partner_links.ChannelPartnerLink.deserialize, + ) + return self._stubs['update_channel_partner_link'] + + @property + def lookup_offer(self) -> Callable[ + [service.LookupOfferRequest], + offers.Offer]: + r"""Return a callable for the lookup offer method over gRPC. + + Returns the requested [Offer][google.cloud.channel.v1.Offer] + resource. + + Possible error codes: + + - PERMISSION_DENIED: The entitlement doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement or offer was not found. + + Return value: The [Offer][google.cloud.channel.v1.Offer] + resource. + + Returns: + Callable[[~.LookupOfferRequest], + ~.Offer]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'lookup_offer' not in self._stubs: + self._stubs['lookup_offer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/LookupOffer', + request_serializer=service.LookupOfferRequest.serialize, + response_deserializer=offers.Offer.deserialize, + ) + return self._stubs['lookup_offer'] + + @property + def list_products(self) -> Callable[ + [service.ListProductsRequest], + service.ListProductsResponse]: + r"""Return a callable for the list products method over gRPC. + + Lists the Products the reseller is authorized to sell. + + Possible error codes: + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Returns: + Callable[[~.ListProductsRequest], + ~.ListProductsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_products' not in self._stubs: + self._stubs['list_products'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListProducts', + request_serializer=service.ListProductsRequest.serialize, + response_deserializer=service.ListProductsResponse.deserialize, + ) + return self._stubs['list_products'] + + @property + def list_skus(self) -> Callable[ + [service.ListSkusRequest], + service.ListSkusResponse]: + r"""Return a callable for the list skus method over gRPC. + + Lists the SKUs for a product the reseller is authorized to sell. + + Possible error codes: + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Returns: + Callable[[~.ListSkusRequest], + ~.ListSkusResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_skus' not in self._stubs: + self._stubs['list_skus'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListSkus', + request_serializer=service.ListSkusRequest.serialize, + response_deserializer=service.ListSkusResponse.deserialize, + ) + return self._stubs['list_skus'] + + @property + def list_offers(self) -> Callable[ + [service.ListOffersRequest], + service.ListOffersResponse]: + r"""Return a callable for the list offers method over gRPC. + + Lists the Offers the reseller can sell. + + Possible error codes: + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Returns: + Callable[[~.ListOffersRequest], + ~.ListOffersResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_offers' not in self._stubs: + self._stubs['list_offers'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListOffers', + request_serializer=service.ListOffersRequest.serialize, + response_deserializer=service.ListOffersResponse.deserialize, + ) + return self._stubs['list_offers'] + + @property + def list_purchasable_skus(self) -> Callable[ + [service.ListPurchasableSkusRequest], + service.ListPurchasableSkusResponse]: + r"""Return a callable for the list purchasable skus method over gRPC. + + Lists the following: + + - SKUs that you can purchase for a customer + - SKUs that you can upgrade or downgrade for an entitlement. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Returns: + Callable[[~.ListPurchasableSkusRequest], + ~.ListPurchasableSkusResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_purchasable_skus' not in self._stubs: + self._stubs['list_purchasable_skus'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListPurchasableSkus', + request_serializer=service.ListPurchasableSkusRequest.serialize, + response_deserializer=service.ListPurchasableSkusResponse.deserialize, + ) + return self._stubs['list_purchasable_skus'] + + @property + def list_purchasable_offers(self) -> Callable[ + [service.ListPurchasableOffersRequest], + service.ListPurchasableOffersResponse]: + r"""Return a callable for the list purchasable offers method over gRPC. + + Lists the following: + + - Offers that you can purchase for a customer. + - Offers that you can change for an entitlement. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Returns: + Callable[[~.ListPurchasableOffersRequest], + ~.ListPurchasableOffersResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_purchasable_offers' not in self._stubs: + self._stubs['list_purchasable_offers'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListPurchasableOffers', + request_serializer=service.ListPurchasableOffersRequest.serialize, + response_deserializer=service.ListPurchasableOffersResponse.deserialize, + ) + return self._stubs['list_purchasable_offers'] + + @property + def register_subscriber(self) -> Callable[ + [service.RegisterSubscriberRequest], + service.RegisterSubscriberResponse]: + r"""Return a callable for the register subscriber method over gRPC. + + Registers a service account with subscriber privileges on the + Cloud Pub/Sub topic for this Channel Services account. After you + create a subscriber, you get the events through + [SubscriberEvent][google.cloud.channel.v1.SubscriberEvent] + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request + and the provided reseller account are different, or the + impersonated user is not a super admin. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The topic name with the registered service email + address. + + Returns: + Callable[[~.RegisterSubscriberRequest], + ~.RegisterSubscriberResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'register_subscriber' not in self._stubs: + self._stubs['register_subscriber'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/RegisterSubscriber', + request_serializer=service.RegisterSubscriberRequest.serialize, + response_deserializer=service.RegisterSubscriberResponse.deserialize, + ) + return self._stubs['register_subscriber'] + + @property + def unregister_subscriber(self) -> Callable[ + [service.UnregisterSubscriberRequest], + service.UnregisterSubscriberResponse]: + r"""Return a callable for the unregister subscriber method over gRPC. + + Unregisters a service account with subscriber privileges on the + Cloud Pub/Sub topic created for this Channel Services account. + If there are no service accounts left with subscriber + privileges, this deletes the topic. You can call ListSubscribers + to check for these accounts. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request + and the provided reseller account are different, or the + impersonated user is not a super admin. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The topic resource doesn't exist. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The topic name that unregistered the service email + address. Returns a success response if the service email address + wasn't registered with the topic. + + Returns: + Callable[[~.UnregisterSubscriberRequest], + ~.UnregisterSubscriberResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'unregister_subscriber' not in self._stubs: + self._stubs['unregister_subscriber'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/UnregisterSubscriber', + request_serializer=service.UnregisterSubscriberRequest.serialize, + response_deserializer=service.UnregisterSubscriberResponse.deserialize, + ) + return self._stubs['unregister_subscriber'] + + @property + def list_subscribers(self) -> Callable[ + [service.ListSubscribersRequest], + service.ListSubscribersResponse]: + r"""Return a callable for the list subscribers method over gRPC. + + Lists service accounts with subscriber privileges on the Cloud + Pub/Sub topic created for this Channel Services account. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request + and the provided reseller account are different, or the + impersonated user is not a super admin. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The topic resource doesn't exist. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: A list of service email addresses. + + Returns: + Callable[[~.ListSubscribersRequest], + ~.ListSubscribersResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_subscribers' not in self._stubs: + self._stubs['list_subscribers'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListSubscribers', + request_serializer=service.ListSubscribersRequest.serialize, + response_deserializer=service.ListSubscribersResponse.deserialize, + ) + return self._stubs['list_subscribers'] + + def close(self): + self.grpc_channel.close() + +__all__ = ( + 'CloudChannelServiceGrpcTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc_asyncio.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc_asyncio.py new file mode 100644 index 0000000..742f943 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc_asyncio.py @@ -0,0 +1,1846 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.channel_v1.types import channel_partner_links +from google.cloud.channel_v1.types import customers +from google.cloud.channel_v1.types import entitlements +from google.cloud.channel_v1.types import offers +from google.cloud.channel_v1.types import service +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from .base import CloudChannelServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import CloudChannelServiceGrpcTransport + + +class CloudChannelServiceGrpcAsyncIOTransport(CloudChannelServiceTransport): + """gRPC AsyncIO backend transport for CloudChannelService. + + CloudChannelService lets Google cloud resellers and distributors + manage their customers, channel partners, entitlements, and reports. + + Using this service: + + 1. Resellers and distributors can manage a customer entity. + 2. Distributors can register an authorized reseller in their channel + and provide them with delegated admin access. + 3. Resellers and distributors can manage customer entitlements. + + CloudChannelService exposes the following resources: + + - [Customer][google.cloud.channel.v1.Customer]s: An entity—usually + an enterprise—managed by a reseller or distributor. + + - [Entitlement][google.cloud.channel.v1.Entitlement]s: An entity + that provides a customer with the means to use a service. + Entitlements are created or updated as a result of a successful + fulfillment. + + - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s: + An entity that identifies links between distributors and their + indirect resellers in a channel. + + 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 = 'cloudchannel.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + def __init__(self, *, + host: str = 'cloudchannel.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, + always_use_jwt_access: Optional[bool] = False, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or application default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for the grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure a mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_customers(self) -> Callable[ + [service.ListCustomersRequest], + Awaitable[service.ListCustomersResponse]]: + r"""Return a callable for the list customers method over gRPC. + + List [Customer][google.cloud.channel.v1.Customer]s. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: List of + [Customer][google.cloud.channel.v1.Customer]s, or an empty list + if there are no customers. + + Returns: + Callable[[~.ListCustomersRequest], + Awaitable[~.ListCustomersResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_customers' not in self._stubs: + self._stubs['list_customers'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListCustomers', + request_serializer=service.ListCustomersRequest.serialize, + response_deserializer=service.ListCustomersResponse.deserialize, + ) + return self._stubs['list_customers'] + + @property + def get_customer(self) -> Callable[ + [service.GetCustomerRequest], + Awaitable[customers.Customer]]: + r"""Return a callable for the get customer method over gRPC. + + Returns the requested + [Customer][google.cloud.channel.v1.Customer] resource. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer resource doesn't exist. Usually the + result of an invalid name parameter. + + Return value: The [Customer][google.cloud.channel.v1.Customer] + resource. + + Returns: + Callable[[~.GetCustomerRequest], + Awaitable[~.Customer]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_customer' not in self._stubs: + self._stubs['get_customer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/GetCustomer', + request_serializer=service.GetCustomerRequest.serialize, + response_deserializer=customers.Customer.deserialize, + ) + return self._stubs['get_customer'] + + @property + def check_cloud_identity_accounts_exist(self) -> Callable[ + [service.CheckCloudIdentityAccountsExistRequest], + Awaitable[service.CheckCloudIdentityAccountsExistResponse]]: + r"""Return a callable for the check cloud identity accounts + exist method over gRPC. + + Confirms the existence of Cloud Identity accounts based on the + domain and if the Cloud Identity accounts are owned by the + reseller. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - INVALID_VALUE: Invalid domain value in the request. + + Return value: A list of + [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] + resources for the domain (may be empty) + + Note: in the v1alpha1 version of the API, a NOT_FOUND error + returns if no + [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] + resources match the domain. + + Returns: + Callable[[~.CheckCloudIdentityAccountsExistRequest], + Awaitable[~.CheckCloudIdentityAccountsExistResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'check_cloud_identity_accounts_exist' not in self._stubs: + self._stubs['check_cloud_identity_accounts_exist'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/CheckCloudIdentityAccountsExist', + request_serializer=service.CheckCloudIdentityAccountsExistRequest.serialize, + response_deserializer=service.CheckCloudIdentityAccountsExistResponse.deserialize, + ) + return self._stubs['check_cloud_identity_accounts_exist'] + + @property + def create_customer(self) -> Callable[ + [service.CreateCustomerRequest], + Awaitable[customers.Customer]]: + r"""Return a callable for the create customer method over gRPC. + + Creates a new [Customer][google.cloud.channel.v1.Customer] + resource under the reseller or distributor account. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: + + - Required request parameters are missing or invalid. + - Domain field value doesn't match the primary email domain. + + Return value: The newly created + [Customer][google.cloud.channel.v1.Customer] resource. + + Returns: + Callable[[~.CreateCustomerRequest], + Awaitable[~.Customer]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_customer' not in self._stubs: + self._stubs['create_customer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/CreateCustomer', + request_serializer=service.CreateCustomerRequest.serialize, + response_deserializer=customers.Customer.deserialize, + ) + return self._stubs['create_customer'] + + @property + def update_customer(self) -> Callable[ + [service.UpdateCustomerRequest], + Awaitable[customers.Customer]]: + r"""Return a callable for the update customer method over gRPC. + + Updates an existing [Customer][google.cloud.channel.v1.Customer] + resource for the reseller or distributor. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] + resource found for the name in the request. + + Return value: The updated + [Customer][google.cloud.channel.v1.Customer] resource. + + Returns: + Callable[[~.UpdateCustomerRequest], + Awaitable[~.Customer]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_customer' not in self._stubs: + self._stubs['update_customer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/UpdateCustomer', + request_serializer=service.UpdateCustomerRequest.serialize, + response_deserializer=customers.Customer.deserialize, + ) + return self._stubs['update_customer'] + + @property + def delete_customer(self) -> Callable[ + [service.DeleteCustomerRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete customer method over gRPC. + + Deletes the given [Customer][google.cloud.channel.v1.Customer] + permanently. + + Possible error codes: + + - PERMISSION_DENIED: The account making the request does not + own this customer. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - FAILED_PRECONDITION: The customer has existing entitlements. + - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] + resource found for the name in the request. + + Returns: + Callable[[~.DeleteCustomerRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_customer' not in self._stubs: + self._stubs['delete_customer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/DeleteCustomer', + request_serializer=service.DeleteCustomerRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_customer'] + + @property + def import_customer(self) -> Callable[ + [service.ImportCustomerRequest], + Awaitable[customers.Customer]]: + r"""Return a callable for the import customer method over gRPC. + + Imports a [Customer][google.cloud.channel.v1.Customer] from the + Cloud Identity associated with the provided Cloud Identity ID or + domain before a TransferEntitlements call. If a linked Customer + already exists and overwrite_if_exists is true, it will update + that Customer's data. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - NOT_FOUND: Cloud Identity doesn't exist or was deleted. + - INVALID_ARGUMENT: Required parameters are missing, or the + auth_token is expired or invalid. + - ALREADY_EXISTS: A customer already exists and has conflicting + critical fields. Requires an overwrite. + + Return value: The [Customer][google.cloud.channel.v1.Customer]. + + Returns: + Callable[[~.ImportCustomerRequest], + Awaitable[~.Customer]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'import_customer' not in self._stubs: + self._stubs['import_customer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ImportCustomer', + request_serializer=service.ImportCustomerRequest.serialize, + response_deserializer=customers.Customer.deserialize, + ) + return self._stubs['import_customer'] + + @property + def provision_cloud_identity(self) -> Callable[ + [service.ProvisionCloudIdentityRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the provision cloud identity method over gRPC. + + Creates a Cloud Identity for the given customer using the + customer's information, or the information provided here. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer was not found. + - ALREADY_EXISTS: The customer's primary email already exists. + Retry after changing the customer's primary contact email. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + contains an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.ProvisionCloudIdentityRequest], + 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 'provision_cloud_identity' not in self._stubs: + self._stubs['provision_cloud_identity'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ProvisionCloudIdentity', + request_serializer=service.ProvisionCloudIdentityRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['provision_cloud_identity'] + + @property + def list_entitlements(self) -> Callable[ + [service.ListEntitlementsRequest], + Awaitable[service.ListEntitlementsResponse]]: + r"""Return a callable for the list entitlements method over gRPC. + + Lists [Entitlement][google.cloud.channel.v1.Entitlement]s + belonging to a customer. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: A list of the customer's + [Entitlement][google.cloud.channel.v1.Entitlement]s. + + Returns: + Callable[[~.ListEntitlementsRequest], + Awaitable[~.ListEntitlementsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_entitlements' not in self._stubs: + self._stubs['list_entitlements'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListEntitlements', + request_serializer=service.ListEntitlementsRequest.serialize, + response_deserializer=service.ListEntitlementsResponse.deserialize, + ) + return self._stubs['list_entitlements'] + + @property + def list_transferable_skus(self) -> Callable[ + [service.ListTransferableSkusRequest], + Awaitable[service.ListTransferableSkusResponse]]: + r"""Return a callable for the list transferable skus method over gRPC. + + List [TransferableSku][google.cloud.channel.v1.TransferableSku]s + of a customer based on the Cloud Identity ID or Customer Name in + the request. + + Use this method to list the entitlements information of an + unowned customer. You should provide the customer's Cloud + Identity ID or Customer Name. + + Possible error codes: + + - PERMISSION_DENIED: + + - The customer doesn't belong to the reseller and has no + auth token. + - The supplied auth token is invalid. + - The reseller account making the request is different from + the reseller account in the query. + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: A list of the customer's + [TransferableSku][google.cloud.channel.v1.TransferableSku]. + + Returns: + Callable[[~.ListTransferableSkusRequest], + Awaitable[~.ListTransferableSkusResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_transferable_skus' not in self._stubs: + self._stubs['list_transferable_skus'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListTransferableSkus', + request_serializer=service.ListTransferableSkusRequest.serialize, + response_deserializer=service.ListTransferableSkusResponse.deserialize, + ) + return self._stubs['list_transferable_skus'] + + @property + def list_transferable_offers(self) -> Callable[ + [service.ListTransferableOffersRequest], + Awaitable[service.ListTransferableOffersResponse]]: + r"""Return a callable for the list transferable offers method over gRPC. + + List + [TransferableOffer][google.cloud.channel.v1.TransferableOffer]s + of a customer based on Cloud Identity ID or Customer Name in the + request. + + Use this method when a reseller gets the entitlement information + of an unowned customer. The reseller should provide the + customer's Cloud Identity ID or Customer Name. + + Possible error codes: + + - PERMISSION_DENIED: + + - The customer doesn't belong to the reseller and has no + auth token. + - The supplied auth token is invalid. + - The reseller account making the request is different from + the reseller account in the query. + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: List of + [TransferableOffer][google.cloud.channel.v1.TransferableOffer] + for the given customer and SKU. + + Returns: + Callable[[~.ListTransferableOffersRequest], + Awaitable[~.ListTransferableOffersResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_transferable_offers' not in self._stubs: + self._stubs['list_transferable_offers'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListTransferableOffers', + request_serializer=service.ListTransferableOffersRequest.serialize, + response_deserializer=service.ListTransferableOffersResponse.deserialize, + ) + return self._stubs['list_transferable_offers'] + + @property + def get_entitlement(self) -> Callable[ + [service.GetEntitlementRequest], + Awaitable[entitlements.Entitlement]]: + r"""Return a callable for the get entitlement method over gRPC. + + Returns the requested + [Entitlement][google.cloud.channel.v1.Entitlement] resource. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer entitlement was not found. + + Return value: The requested + [Entitlement][google.cloud.channel.v1.Entitlement] resource. + + Returns: + Callable[[~.GetEntitlementRequest], + Awaitable[~.Entitlement]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_entitlement' not in self._stubs: + self._stubs['get_entitlement'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/GetEntitlement', + request_serializer=service.GetEntitlementRequest.serialize, + response_deserializer=entitlements.Entitlement.deserialize, + ) + return self._stubs['get_entitlement'] + + @property + def create_entitlement(self) -> Callable[ + [service.CreateEntitlementRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create entitlement method over gRPC. + + Creates an entitlement for a customer. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: + + - Required request parameters are missing or invalid. + - There is already a customer entitlement for a SKU from the + same product family. + + - INVALID_VALUE: Make sure the OfferId is valid. If it is, + contact Google Channel support for further troubleshooting. + - NOT_FOUND: The customer or offer resource was not found. + - ALREADY_EXISTS: + + - The SKU was already purchased for the customer. + - The customer's primary email already exists. Retry after + changing the customer's primary contact email. + + - CONDITION_NOT_MET or FAILED_PRECONDITION: + + - The domain required for purchasing a SKU has not been + verified. + - A pre-requisite SKU required to purchase an Add-On SKU is + missing. For example, Google Workspace Business Starter is + required to purchase Vault or Drive. + - (Developer accounts only) Reseller and resold domain must + meet the following naming requirements: + + - Domain names must start with goog-test. + - Domain names must include the reseller domain. + + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.CreateEntitlementRequest], + 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_entitlement' not in self._stubs: + self._stubs['create_entitlement'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/CreateEntitlement', + request_serializer=service.CreateEntitlementRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_entitlement'] + + @property + def change_parameters(self) -> Callable[ + [service.ChangeParametersRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the change parameters method over gRPC. + + Change parameters of the entitlement. + + An entitlement update is a long-running operation and it updates + the entitlement as a result of fulfillment. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. For example, the number of seats being changed is + greater than the allowed number of max seats, or decreasing + seats for a commitment based plan. + - NOT_FOUND: Entitlement resource not found. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.ChangeParametersRequest], + 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 'change_parameters' not in self._stubs: + self._stubs['change_parameters'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ChangeParameters', + request_serializer=service.ChangeParametersRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['change_parameters'] + + @property + def change_renewal_settings(self) -> Callable[ + [service.ChangeRenewalSettingsRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the change renewal settings method over gRPC. + + Updates the renewal settings for an existing customer + entitlement. + + An entitlement update is a long-running operation and it updates + the entitlement as a result of fulfillment. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - NOT_COMMITMENT_PLAN: Renewal Settings are only applicable for + a commitment plan. Can't enable or disable renewals for + non-commitment plans. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.ChangeRenewalSettingsRequest], + 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 'change_renewal_settings' not in self._stubs: + self._stubs['change_renewal_settings'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ChangeRenewalSettings', + request_serializer=service.ChangeRenewalSettingsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['change_renewal_settings'] + + @property + def change_offer(self) -> Callable[ + [service.ChangeOfferRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the change offer method over gRPC. + + Updates the Offer for an existing customer entitlement. + + An entitlement update is a long-running operation and it updates + the entitlement as a result of fulfillment. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Offer or Entitlement resource not found. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.ChangeOfferRequest], + 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 'change_offer' not in self._stubs: + self._stubs['change_offer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ChangeOffer', + request_serializer=service.ChangeOfferRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['change_offer'] + + @property + def start_paid_service(self) -> Callable[ + [service.StartPaidServiceRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the start paid service method over gRPC. + + Starts paid service for a trial entitlement. + + Starts paid service for a trial entitlement immediately. This + method is only applicable if a plan is set up for a trial + entitlement but has some trial days remaining. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - FAILED_PRECONDITION/NOT_IN_TRIAL: This method only works for + entitlement on trial plans. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.StartPaidServiceRequest], + 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 'start_paid_service' not in self._stubs: + self._stubs['start_paid_service'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/StartPaidService', + request_serializer=service.StartPaidServiceRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['start_paid_service'] + + @property + def suspend_entitlement(self) -> Callable[ + [service.SuspendEntitlementRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the suspend entitlement method over gRPC. + + Suspends a previously fulfilled entitlement. + + An entitlement suspension is a long-running operation. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - NOT_ACTIVE: Entitlement is not active. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.SuspendEntitlementRequest], + 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 'suspend_entitlement' not in self._stubs: + self._stubs['suspend_entitlement'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/SuspendEntitlement', + request_serializer=service.SuspendEntitlementRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['suspend_entitlement'] + + @property + def cancel_entitlement(self) -> Callable[ + [service.CancelEntitlementRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the cancel entitlement method over gRPC. + + Cancels a previously fulfilled entitlement. + + An entitlement cancellation is a long-running operation. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - FAILED_PRECONDITION: There are Google Cloud projects linked + to the Google Cloud entitlement's Cloud Billing subaccount. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - DELETION_TYPE_NOT_ALLOWED: Cancel is only allowed for Google + Workspace add-ons, or entitlements for Google Cloud's + development platform. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The response will + contain google.protobuf.Empty on success. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.CancelEntitlementRequest], + 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 'cancel_entitlement' not in self._stubs: + self._stubs['cancel_entitlement'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/CancelEntitlement', + request_serializer=service.CancelEntitlementRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['cancel_entitlement'] + + @property + def activate_entitlement(self) -> Callable[ + [service.ActivateEntitlementRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the activate entitlement method over gRPC. + + Activates a previously suspended entitlement. Entitlements + suspended for pending ToS acceptance can't be activated using + this method. + + An entitlement activation is a long-running operation and it + updates the state of the customer entitlement. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement resource not found. + - SUSPENSION_NOT_RESELLER_INITIATED: Can only activate + reseller-initiated suspensions and entitlements that have + accepted the TOS. + - NOT_SUSPENDED: Can only activate suspended entitlements not + in an ACTIVE state. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.ActivateEntitlementRequest], + 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_entitlement' not in self._stubs: + self._stubs['activate_entitlement'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ActivateEntitlement', + request_serializer=service.ActivateEntitlementRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['activate_entitlement'] + + @property + def transfer_entitlements(self) -> Callable[ + [service.TransferEntitlementsRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the transfer entitlements method over gRPC. + + Transfers customer entitlements to new reseller. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer or offer resource was not found. + - ALREADY_EXISTS: The SKU was already transferred for the + customer. + - CONDITION_NOT_MET or FAILED_PRECONDITION: + + - The SKU requires domain verification to transfer, but the + domain is not verified. + - An Add-On SKU (example, Vault or Drive) is missing the + pre-requisite SKU (example, G Suite Basic). + - (Developer accounts only) Reseller and resold domain must + meet the following naming requirements: + + - Domain names must start with goog-test. + - Domain names must include the reseller domain. + + - Specify all transferring entitlements. + + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.TransferEntitlementsRequest], + 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 'transfer_entitlements' not in self._stubs: + self._stubs['transfer_entitlements'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/TransferEntitlements', + request_serializer=service.TransferEntitlementsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['transfer_entitlements'] + + @property + def transfer_entitlements_to_google(self) -> Callable[ + [service.TransferEntitlementsToGoogleRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the transfer entitlements to + google method over gRPC. + + Transfers customer entitlements from their current reseller to + Google. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The customer or offer resource was not found. + - ALREADY_EXISTS: The SKU was already transferred for the + customer. + - CONDITION_NOT_MET or FAILED_PRECONDITION: + + - The SKU requires domain verification to transfer, but the + domain is not verified. + - An Add-On SKU (example, Vault or Drive) is missing the + pre-requisite SKU (example, G Suite Basic). + - (Developer accounts only) Reseller and resold domain must + meet the following naming requirements: + + - Domain names must start with goog-test. + - Domain names must include the reseller domain. + + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The ID of a long-running operation. + + To get the results of the operation, call the GetOperation + method of CloudChannelOperationsService. The response will + contain google.protobuf.Empty on success. The Operation metadata + will contain an instance of + [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + + Returns: + Callable[[~.TransferEntitlementsToGoogleRequest], + 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 'transfer_entitlements_to_google' not in self._stubs: + self._stubs['transfer_entitlements_to_google'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/TransferEntitlementsToGoogle', + request_serializer=service.TransferEntitlementsToGoogleRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['transfer_entitlements_to_google'] + + @property + def list_channel_partner_links(self) -> Callable[ + [service.ListChannelPartnerLinksRequest], + Awaitable[service.ListChannelPartnerLinksResponse]]: + r"""Return a callable for the list channel partner links method over gRPC. + + List + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s + belonging to a distributor. You must be a distributor to call + this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Return value: The list of the distributor account's + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resources. + + Returns: + Callable[[~.ListChannelPartnerLinksRequest], + Awaitable[~.ListChannelPartnerLinksResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_channel_partner_links' not in self._stubs: + self._stubs['list_channel_partner_links'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListChannelPartnerLinks', + request_serializer=service.ListChannelPartnerLinksRequest.serialize, + response_deserializer=service.ListChannelPartnerLinksResponse.deserialize, + ) + return self._stubs['list_channel_partner_links'] + + @property + def get_channel_partner_link(self) -> Callable[ + [service.GetChannelPartnerLinkRequest], + Awaitable[channel_partner_links.ChannelPartnerLink]]: + r"""Return a callable for the get channel partner link method over gRPC. + + Returns the requested + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. You must be a distributor to call this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: ChannelPartnerLink resource not found because of + an invalid channel partner link name. + + Return value: The + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. + + Returns: + Callable[[~.GetChannelPartnerLinkRequest], + Awaitable[~.ChannelPartnerLink]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_channel_partner_link' not in self._stubs: + self._stubs['get_channel_partner_link'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/GetChannelPartnerLink', + request_serializer=service.GetChannelPartnerLinkRequest.serialize, + response_deserializer=channel_partner_links.ChannelPartnerLink.deserialize, + ) + return self._stubs['get_channel_partner_link'] + + @property + def create_channel_partner_link(self) -> Callable[ + [service.CreateChannelPartnerLinkRequest], + Awaitable[channel_partner_links.ChannelPartnerLink]]: + r"""Return a callable for the create channel partner link method over gRPC. + + Initiates a channel partner link between a distributor and a + reseller, or between resellers in an n-tier reseller channel. + Invited partners need to follow the invite_link_uri provided in + the response to accept. After accepting the invitation, a link + is set up between the two parties. You must be a distributor to + call this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - ALREADY_EXISTS: The ChannelPartnerLink sent in the request + already exists. + - NOT_FOUND: No Cloud Identity customer exists for provided + domain. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The new + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. + + Returns: + Callable[[~.CreateChannelPartnerLinkRequest], + Awaitable[~.ChannelPartnerLink]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_channel_partner_link' not in self._stubs: + self._stubs['create_channel_partner_link'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/CreateChannelPartnerLink', + request_serializer=service.CreateChannelPartnerLinkRequest.serialize, + response_deserializer=channel_partner_links.ChannelPartnerLink.deserialize, + ) + return self._stubs['create_channel_partner_link'] + + @property + def update_channel_partner_link(self) -> Callable[ + [service.UpdateChannelPartnerLinkRequest], + Awaitable[channel_partner_links.ChannelPartnerLink]]: + r"""Return a callable for the update channel partner link method over gRPC. + + Updates a channel partner link. Distributors call this method to + change a link's status. For example, to suspend a partner link. + You must be a distributor to call this method. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request is + different from the reseller account in the API request. + - INVALID_ARGUMENT: + + - Required request parameters are missing or invalid. + - Link state cannot change from invited to active or + suspended. + - Cannot send reseller_cloud_identity_id, invite_url, or + name in update mask. + + - NOT_FOUND: ChannelPartnerLink resource not found. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The updated + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + resource. + + Returns: + Callable[[~.UpdateChannelPartnerLinkRequest], + Awaitable[~.ChannelPartnerLink]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_channel_partner_link' not in self._stubs: + self._stubs['update_channel_partner_link'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/UpdateChannelPartnerLink', + request_serializer=service.UpdateChannelPartnerLinkRequest.serialize, + response_deserializer=channel_partner_links.ChannelPartnerLink.deserialize, + ) + return self._stubs['update_channel_partner_link'] + + @property + def lookup_offer(self) -> Callable[ + [service.LookupOfferRequest], + Awaitable[offers.Offer]]: + r"""Return a callable for the lookup offer method over gRPC. + + Returns the requested [Offer][google.cloud.channel.v1.Offer] + resource. + + Possible error codes: + + - PERMISSION_DENIED: The entitlement doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: Entitlement or offer was not found. + + Return value: The [Offer][google.cloud.channel.v1.Offer] + resource. + + Returns: + Callable[[~.LookupOfferRequest], + Awaitable[~.Offer]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'lookup_offer' not in self._stubs: + self._stubs['lookup_offer'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/LookupOffer', + request_serializer=service.LookupOfferRequest.serialize, + response_deserializer=offers.Offer.deserialize, + ) + return self._stubs['lookup_offer'] + + @property + def list_products(self) -> Callable[ + [service.ListProductsRequest], + Awaitable[service.ListProductsResponse]]: + r"""Return a callable for the list products method over gRPC. + + Lists the Products the reseller is authorized to sell. + + Possible error codes: + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Returns: + Callable[[~.ListProductsRequest], + Awaitable[~.ListProductsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_products' not in self._stubs: + self._stubs['list_products'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListProducts', + request_serializer=service.ListProductsRequest.serialize, + response_deserializer=service.ListProductsResponse.deserialize, + ) + return self._stubs['list_products'] + + @property + def list_skus(self) -> Callable[ + [service.ListSkusRequest], + Awaitable[service.ListSkusResponse]]: + r"""Return a callable for the list skus method over gRPC. + + Lists the SKUs for a product the reseller is authorized to sell. + + Possible error codes: + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Returns: + Callable[[~.ListSkusRequest], + Awaitable[~.ListSkusResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_skus' not in self._stubs: + self._stubs['list_skus'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListSkus', + request_serializer=service.ListSkusRequest.serialize, + response_deserializer=service.ListSkusResponse.deserialize, + ) + return self._stubs['list_skus'] + + @property + def list_offers(self) -> Callable[ + [service.ListOffersRequest], + Awaitable[service.ListOffersResponse]]: + r"""Return a callable for the list offers method over gRPC. + + Lists the Offers the reseller can sell. + + Possible error codes: + + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Returns: + Callable[[~.ListOffersRequest], + Awaitable[~.ListOffersResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_offers' not in self._stubs: + self._stubs['list_offers'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListOffers', + request_serializer=service.ListOffersRequest.serialize, + response_deserializer=service.ListOffersResponse.deserialize, + ) + return self._stubs['list_offers'] + + @property + def list_purchasable_skus(self) -> Callable[ + [service.ListPurchasableSkusRequest], + Awaitable[service.ListPurchasableSkusResponse]]: + r"""Return a callable for the list purchasable skus method over gRPC. + + Lists the following: + + - SKUs that you can purchase for a customer + - SKUs that you can upgrade or downgrade for an entitlement. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Returns: + Callable[[~.ListPurchasableSkusRequest], + Awaitable[~.ListPurchasableSkusResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_purchasable_skus' not in self._stubs: + self._stubs['list_purchasable_skus'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListPurchasableSkus', + request_serializer=service.ListPurchasableSkusRequest.serialize, + response_deserializer=service.ListPurchasableSkusResponse.deserialize, + ) + return self._stubs['list_purchasable_skus'] + + @property + def list_purchasable_offers(self) -> Callable[ + [service.ListPurchasableOffersRequest], + Awaitable[service.ListPurchasableOffersResponse]]: + r"""Return a callable for the list purchasable offers method over gRPC. + + Lists the following: + + - Offers that you can purchase for a customer. + - Offers that you can change for an entitlement. + + Possible error codes: + + - PERMISSION_DENIED: The customer doesn't belong to the + reseller + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + + Returns: + Callable[[~.ListPurchasableOffersRequest], + Awaitable[~.ListPurchasableOffersResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_purchasable_offers' not in self._stubs: + self._stubs['list_purchasable_offers'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListPurchasableOffers', + request_serializer=service.ListPurchasableOffersRequest.serialize, + response_deserializer=service.ListPurchasableOffersResponse.deserialize, + ) + return self._stubs['list_purchasable_offers'] + + @property + def register_subscriber(self) -> Callable[ + [service.RegisterSubscriberRequest], + Awaitable[service.RegisterSubscriberResponse]]: + r"""Return a callable for the register subscriber method over gRPC. + + Registers a service account with subscriber privileges on the + Cloud Pub/Sub topic for this Channel Services account. After you + create a subscriber, you get the events through + [SubscriberEvent][google.cloud.channel.v1.SubscriberEvent] + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request + and the provided reseller account are different, or the + impersonated user is not a super admin. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The topic name with the registered service email + address. + + Returns: + Callable[[~.RegisterSubscriberRequest], + Awaitable[~.RegisterSubscriberResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'register_subscriber' not in self._stubs: + self._stubs['register_subscriber'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/RegisterSubscriber', + request_serializer=service.RegisterSubscriberRequest.serialize, + response_deserializer=service.RegisterSubscriberResponse.deserialize, + ) + return self._stubs['register_subscriber'] + + @property + def unregister_subscriber(self) -> Callable[ + [service.UnregisterSubscriberRequest], + Awaitable[service.UnregisterSubscriberResponse]]: + r"""Return a callable for the unregister subscriber method over gRPC. + + Unregisters a service account with subscriber privileges on the + Cloud Pub/Sub topic created for this Channel Services account. + If there are no service accounts left with subscriber + privileges, this deletes the topic. You can call ListSubscribers + to check for these accounts. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request + and the provided reseller account are different, or the + impersonated user is not a super admin. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The topic resource doesn't exist. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: The topic name that unregistered the service email + address. Returns a success response if the service email address + wasn't registered with the topic. + + Returns: + Callable[[~.UnregisterSubscriberRequest], + Awaitable[~.UnregisterSubscriberResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'unregister_subscriber' not in self._stubs: + self._stubs['unregister_subscriber'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/UnregisterSubscriber', + request_serializer=service.UnregisterSubscriberRequest.serialize, + response_deserializer=service.UnregisterSubscriberResponse.deserialize, + ) + return self._stubs['unregister_subscriber'] + + @property + def list_subscribers(self) -> Callable[ + [service.ListSubscribersRequest], + Awaitable[service.ListSubscribersResponse]]: + r"""Return a callable for the list subscribers method over gRPC. + + Lists service accounts with subscriber privileges on the Cloud + Pub/Sub topic created for this Channel Services account. + + Possible error codes: + + - PERMISSION_DENIED: The reseller account making the request + and the provided reseller account are different, or the + impersonated user is not a super admin. + - INVALID_ARGUMENT: Required request parameters are missing or + invalid. + - NOT_FOUND: The topic resource doesn't exist. + - INTERNAL: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + - UNKNOWN: Any non-user error related to a technical issue in + the backend. Contact Cloud Channel support. + + Return value: A list of service email addresses. + + Returns: + Callable[[~.ListSubscribersRequest], + Awaitable[~.ListSubscribersResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_subscribers' not in self._stubs: + self._stubs['list_subscribers'] = self.grpc_channel.unary_unary( + '/google.cloud.channel.v1.CloudChannelService/ListSubscribers', + request_serializer=service.ListSubscribersRequest.serialize, + response_deserializer=service.ListSubscribersResponse.deserialize, + ) + return self._stubs['list_subscribers'] + + def close(self): + return self.grpc_channel.close() + + +__all__ = ( + 'CloudChannelServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/__init__.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/__init__.py new file mode 100644 index 0000000..a3bf276 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/types/__init__.py @@ -0,0 +1,228 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 .channel_partner_links import ( + ChannelPartnerLink, + ChannelPartnerLinkState, + ChannelPartnerLinkView, +) +from .common import ( + AdminUser, + CloudIdentityInfo, + EduData, + Value, +) +from .customers import ( + ContactInfo, + Customer, +) +from .entitlements import ( + AssociationInfo, + CommitmentSettings, + Entitlement, + Parameter, + ProvisionedService, + RenewalSettings, + TransferableSku, + TransferEligibility, + TrialSettings, +) +from .offers import ( + Constraints, + CustomerConstraints, + Offer, + ParameterDefinition, + Period, + Plan, + Price, + PriceByResource, + PricePhase, + PriceTier, + PaymentPlan, + PaymentType, + PeriodType, + PromotionalOrderType, + ResourceType, +) +from .operations import ( + OperationMetadata, +) +from .products import ( + MarketingInfo, + Media, + Product, + Sku, + MediaType, +) +from .service import ( + ActivateEntitlementRequest, + CancelEntitlementRequest, + ChangeOfferRequest, + ChangeParametersRequest, + ChangeRenewalSettingsRequest, + CheckCloudIdentityAccountsExistRequest, + CheckCloudIdentityAccountsExistResponse, + CloudIdentityCustomerAccount, + CreateChannelPartnerLinkRequest, + CreateCustomerRequest, + CreateEntitlementRequest, + DeleteCustomerRequest, + GetChannelPartnerLinkRequest, + GetCustomerRequest, + GetEntitlementRequest, + ImportCustomerRequest, + ListChannelPartnerLinksRequest, + ListChannelPartnerLinksResponse, + ListCustomersRequest, + ListCustomersResponse, + ListEntitlementsRequest, + ListEntitlementsResponse, + ListOffersRequest, + ListOffersResponse, + ListProductsRequest, + ListProductsResponse, + ListPurchasableOffersRequest, + ListPurchasableOffersResponse, + ListPurchasableSkusRequest, + ListPurchasableSkusResponse, + ListSkusRequest, + ListSkusResponse, + ListSubscribersRequest, + ListSubscribersResponse, + ListTransferableOffersRequest, + ListTransferableOffersResponse, + ListTransferableSkusRequest, + ListTransferableSkusResponse, + LookupOfferRequest, + ProvisionCloudIdentityRequest, + PurchasableOffer, + PurchasableSku, + RegisterSubscriberRequest, + RegisterSubscriberResponse, + StartPaidServiceRequest, + SuspendEntitlementRequest, + TransferableOffer, + TransferEntitlementsRequest, + TransferEntitlementsResponse, + TransferEntitlementsToGoogleRequest, + UnregisterSubscriberRequest, + UnregisterSubscriberResponse, + UpdateChannelPartnerLinkRequest, + UpdateCustomerRequest, +) +from .subscriber_event import ( + CustomerEvent, + EntitlementEvent, + SubscriberEvent, +) + +__all__ = ( + 'ChannelPartnerLink', + 'ChannelPartnerLinkState', + 'ChannelPartnerLinkView', + 'AdminUser', + 'CloudIdentityInfo', + 'EduData', + 'Value', + 'ContactInfo', + 'Customer', + 'AssociationInfo', + 'CommitmentSettings', + 'Entitlement', + 'Parameter', + 'ProvisionedService', + 'RenewalSettings', + 'TransferableSku', + 'TransferEligibility', + 'TrialSettings', + 'Constraints', + 'CustomerConstraints', + 'Offer', + 'ParameterDefinition', + 'Period', + 'Plan', + 'Price', + 'PriceByResource', + 'PricePhase', + 'PriceTier', + 'PaymentPlan', + 'PaymentType', + 'PeriodType', + 'PromotionalOrderType', + 'ResourceType', + 'OperationMetadata', + 'MarketingInfo', + 'Media', + 'Product', + 'Sku', + 'MediaType', + 'ActivateEntitlementRequest', + 'CancelEntitlementRequest', + 'ChangeOfferRequest', + 'ChangeParametersRequest', + 'ChangeRenewalSettingsRequest', + 'CheckCloudIdentityAccountsExistRequest', + 'CheckCloudIdentityAccountsExistResponse', + 'CloudIdentityCustomerAccount', + 'CreateChannelPartnerLinkRequest', + 'CreateCustomerRequest', + 'CreateEntitlementRequest', + 'DeleteCustomerRequest', + 'GetChannelPartnerLinkRequest', + 'GetCustomerRequest', + 'GetEntitlementRequest', + 'ImportCustomerRequest', + 'ListChannelPartnerLinksRequest', + 'ListChannelPartnerLinksResponse', + 'ListCustomersRequest', + 'ListCustomersResponse', + 'ListEntitlementsRequest', + 'ListEntitlementsResponse', + 'ListOffersRequest', + 'ListOffersResponse', + 'ListProductsRequest', + 'ListProductsResponse', + 'ListPurchasableOffersRequest', + 'ListPurchasableOffersResponse', + 'ListPurchasableSkusRequest', + 'ListPurchasableSkusResponse', + 'ListSkusRequest', + 'ListSkusResponse', + 'ListSubscribersRequest', + 'ListSubscribersResponse', + 'ListTransferableOffersRequest', + 'ListTransferableOffersResponse', + 'ListTransferableSkusRequest', + 'ListTransferableSkusResponse', + 'LookupOfferRequest', + 'ProvisionCloudIdentityRequest', + 'PurchasableOffer', + 'PurchasableSku', + 'RegisterSubscriberRequest', + 'RegisterSubscriberResponse', + 'StartPaidServiceRequest', + 'SuspendEntitlementRequest', + 'TransferableOffer', + 'TransferEntitlementsRequest', + 'TransferEntitlementsResponse', + 'TransferEntitlementsToGoogleRequest', + 'UnregisterSubscriberRequest', + 'UnregisterSubscriberResponse', + 'UpdateChannelPartnerLinkRequest', + 'UpdateCustomerRequest', + 'CustomerEvent', + 'EntitlementEvent', + 'SubscriberEvent', +) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/channel_partner_links.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/channel_partner_links.py new file mode 100644 index 0000000..dbd464d --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/types/channel_partner_links.py @@ -0,0 +1,123 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.channel_v1.types import common +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.channel.v1', + manifest={ + 'ChannelPartnerLinkView', + 'ChannelPartnerLinkState', + 'ChannelPartnerLink', + }, +) + + +class ChannelPartnerLinkView(proto.Enum): + r"""The level of granularity the + [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + will display. + """ + UNSPECIFIED = 0 + BASIC = 1 + FULL = 2 + + +class ChannelPartnerLinkState(proto.Enum): + r"""ChannelPartnerLinkState represents state of a channel partner + link. + """ + CHANNEL_PARTNER_LINK_STATE_UNSPECIFIED = 0 + INVITED = 1 + ACTIVE = 2 + REVOKED = 3 + SUSPENDED = 4 + + +class ChannelPartnerLink(proto.Message): + r"""Entity representing a link between distributors and their + indirect resellers in an n-tier resale channel. + + Attributes: + name (str): + Output only. Resource name for the channel partner link, in + the format accounts/{account_id}/channelPartnerLinks/{id}. + reseller_cloud_identity_id (str): + Required. Cloud Identity ID of the linked + reseller. + link_state (google.cloud.channel_v1.types.ChannelPartnerLinkState): + Required. State of the channel partner link. + invite_link_uri (str): + Output only. URI of the web page where + partner accepts the link invitation. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Timestamp of when the channel + partner link is created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Timestamp of when the channel + partner link is updated. + public_id (str): + Output only. Public identifier that a + customer must use to generate a transfer token + to move to this distributor-reseller + combination. + channel_partner_cloud_identity_info (google.cloud.channel_v1.types.CloudIdentityInfo): + Output only. Cloud Identity info of the + channel partner (IR). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + reseller_cloud_identity_id = proto.Field( + proto.STRING, + number=2, + ) + link_state = proto.Field( + proto.ENUM, + number=3, + enum='ChannelPartnerLinkState', + ) + invite_link_uri = proto.Field( + proto.STRING, + number=4, + ) + create_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + public_id = proto.Field( + proto.STRING, + number=7, + ) + channel_partner_cloud_identity_info = proto.Field( + proto.MESSAGE, + number=8, + message=common.CloudIdentityInfo, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/common.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/common.py new file mode 100644 index 0000000..931c263 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/types/common.py @@ -0,0 +1,219 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 any_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.channel.v1', + manifest={ + 'EduData', + 'CloudIdentityInfo', + 'Value', + 'AdminUser', + }, +) + + +class EduData(proto.Message): + r"""Required Edu Attributes + + Attributes: + institute_type (google.cloud.channel_v1.types.EduData.InstituteType): + Designated institute type of customer. + institute_size (google.cloud.channel_v1.types.EduData.InstituteSize): + Size of the institute. + website (str): + Web address for the edu customer's + institution. + """ + class InstituteType(proto.Enum): + r"""Enum to specify the institute type.""" + INSTITUTE_TYPE_UNSPECIFIED = 0 + K12 = 1 + UNIVERSITY = 2 + + class InstituteSize(proto.Enum): + r"""Number of students and staff the institute has.""" + INSTITUTE_SIZE_UNSPECIFIED = 0 + SIZE_1_100 = 1 + SIZE_101_500 = 2 + SIZE_501_1000 = 3 + SIZE_1001_2000 = 4 + SIZE_2001_5000 = 5 + SIZE_5001_10000 = 6 + SIZE_10001_OR_MORE = 7 + + institute_type = proto.Field( + proto.ENUM, + number=1, + enum=InstituteType, + ) + institute_size = proto.Field( + proto.ENUM, + number=2, + enum=InstituteSize, + ) + website = proto.Field( + proto.STRING, + number=3, + ) + + +class CloudIdentityInfo(proto.Message): + r"""Cloud Identity information for the Cloud Channel Customer. + + Attributes: + customer_type (google.cloud.channel_v1.types.CloudIdentityInfo.CustomerType): + CustomerType indicates verification type + needed for using services. + primary_domain (str): + Output only. The primary domain name. + is_domain_verified (bool): + Output only. Whether the domain is verified. This field is + not returned for a Customer's cloud_identity_info resource. + Partners can use the domains.get() method of the Workspace + SDK's Directory API, or listen to the + PRIMARY_DOMAIN_VERIFIED Pub/Sub event in to track domain + verification of their resolve Workspace customers. + alternate_email (str): + The alternate email. + phone_number (str): + Phone number associated with the Cloud + Identity. + language_code (str): + Language code. + admin_console_uri (str): + Output only. URI of Customer's Admin console + dashboard. + edu_data (google.cloud.channel_v1.types.EduData): + Edu information about the customer. + """ + class CustomerType(proto.Enum): + r"""CustomerType of the customer""" + CUSTOMER_TYPE_UNSPECIFIED = 0 + DOMAIN = 1 + TEAM = 2 + + customer_type = proto.Field( + proto.ENUM, + number=1, + enum=CustomerType, + ) + primary_domain = proto.Field( + proto.STRING, + number=9, + ) + is_domain_verified = proto.Field( + proto.BOOL, + number=4, + ) + alternate_email = proto.Field( + proto.STRING, + number=6, + ) + phone_number = proto.Field( + proto.STRING, + number=7, + ) + language_code = proto.Field( + proto.STRING, + number=8, + ) + admin_console_uri = proto.Field( + proto.STRING, + number=10, + ) + edu_data = proto.Field( + proto.MESSAGE, + number=22, + message='EduData', + ) + + +class Value(proto.Message): + r"""Data type and value of a parameter. + + Attributes: + int64_value (int): + Represents an int64 value. + string_value (str): + Represents a string value. + double_value (float): + Represents a double value. + proto_value (google.protobuf.any_pb2.Any): + Represents an 'Any' proto value. + bool_value (bool): + Represents a boolean value. + """ + + int64_value = proto.Field( + proto.INT64, + number=1, + oneof='kind', + ) + string_value = proto.Field( + proto.STRING, + number=2, + oneof='kind', + ) + double_value = proto.Field( + proto.DOUBLE, + number=3, + oneof='kind', + ) + proto_value = proto.Field( + proto.MESSAGE, + number=4, + oneof='kind', + message=any_pb2.Any, + ) + bool_value = proto.Field( + proto.BOOL, + number=5, + oneof='kind', + ) + + +class AdminUser(proto.Message): + r"""Information needed to create an Admin User for Google + Workspace. + + Attributes: + email (str): + Primary email of the admin user. + given_name (str): + Given name of the admin user. + family_name (str): + Family name of the admin user. + """ + + email = proto.Field( + proto.STRING, + number=1, + ) + given_name = proto.Field( + proto.STRING, + number=2, + ) + family_name = proto.Field( + proto.STRING, + number=3, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/customers.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/customers.py new file mode 100644 index 0000000..7e2d7a6 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/types/customers.py @@ -0,0 +1,194 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.channel_v1.types import common +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import postal_address_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.channel.v1', + manifest={ + 'Customer', + 'ContactInfo', + }, +) + + +class Customer(proto.Message): + r"""Entity representing a customer of a reseller or distributor. + + Attributes: + name (str): + Output only. Resource name of the customer. Format: + accounts/{account_id}/customers/{customer_id} + org_display_name (str): + Required. Name of the organization that the + customer entity represents. + org_postal_address (google.type.postal_address_pb2.PostalAddress): + Required. The organization address for the + customer. To enforce US laws and embargoes, we + require a region and zip code. You must provide + valid addresses for every customer. To set the + customer's language, use the Customer-level + language code. + primary_contact_info (google.cloud.channel_v1.types.ContactInfo): + Primary contact info. + alternate_email (str): + Secondary contact email. You need to provide + an alternate email to create different domains + if a primary contact email already exists. Users + will receive a notification with credentials + when you create an admin.google.com account. + Secondary emails are also recovery email + addresses. Alternate emails are optional when + you create Team customers. + domain (str): + Required. The customer's primary domain. Must + match the primary contact email's domain. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when the customer was + created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when the customer was + updated. + cloud_identity_id (str): + Output only. The customer's Cloud Identity ID + if the customer has a Cloud Identity resource. + language_code (str): + Optional. The BCP-47 language code, such as "en-US" or + "sr-Latn". For more information, see + https://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + cloud_identity_info (google.cloud.channel_v1.types.CloudIdentityInfo): + Output only. Cloud Identity information for + the customer. Populated only if a Cloud Identity + account exists for this customer. + channel_partner_id (str): + Cloud Identity ID of the customer's channel + partner. Populated only if a channel partner + exists for this customer. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + org_display_name = proto.Field( + proto.STRING, + number=2, + ) + org_postal_address = proto.Field( + proto.MESSAGE, + number=3, + message=postal_address_pb2.PostalAddress, + ) + primary_contact_info = proto.Field( + proto.MESSAGE, + number=4, + message='ContactInfo', + ) + alternate_email = proto.Field( + proto.STRING, + number=5, + ) + domain = proto.Field( + proto.STRING, + number=6, + ) + create_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + cloud_identity_id = proto.Field( + proto.STRING, + number=9, + ) + language_code = proto.Field( + proto.STRING, + number=10, + ) + cloud_identity_info = proto.Field( + proto.MESSAGE, + number=12, + message=common.CloudIdentityInfo, + ) + channel_partner_id = proto.Field( + proto.STRING, + number=13, + ) + + +class ContactInfo(proto.Message): + r"""Contact information for a customer account. + + Attributes: + first_name (str): + The customer account contact's first name. + Optional for Team customers. + last_name (str): + The customer account contact's last name. + Optional for Team customers. + display_name (str): + Output only. The customer account contact's + display name, formatted as a combination of the + customer's first and last name. + email (str): + The customer account's contact email. + Required for entitlements that create + admin.google.com accounts, and serves as the + customer's username for those accounts. Use this + email to invite Team customers. + title (str): + Optional. The customer account contact's job + title. + phone (str): + The customer account's contact phone number. + """ + + first_name = proto.Field( + proto.STRING, + number=1, + ) + last_name = proto.Field( + proto.STRING, + number=2, + ) + display_name = proto.Field( + proto.STRING, + number=4, + ) + email = proto.Field( + proto.STRING, + number=5, + ) + title = proto.Field( + proto.STRING, + number=6, + ) + phone = proto.Field( + proto.STRING, + number=7, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/entitlements.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/entitlements.py new file mode 100644 index 0000000..bd87901 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/types/entitlements.py @@ -0,0 +1,403 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.channel_v1.types import common +from google.cloud.channel_v1.types import offers +from google.cloud.channel_v1.types import products +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.channel.v1', + manifest={ + 'Entitlement', + 'Parameter', + 'AssociationInfo', + 'ProvisionedService', + 'CommitmentSettings', + 'RenewalSettings', + 'TrialSettings', + 'TransferableSku', + 'TransferEligibility', + }, +) + + +class Entitlement(proto.Message): + r"""An entitlement is a representation of a customer's ability to + use a service. + + Attributes: + name (str): + Output only. Resource name of an entitlement in the form: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id}. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the + entitlement is created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the + entitlement is updated. + offer (str): + Required. The offer resource name for which the entitlement + is to be created. Takes the form: + accounts/{account_id}/offers/{offer_id}. + commitment_settings (google.cloud.channel_v1.types.CommitmentSettings): + Commitment settings for a commitment-based + Offer. Required for commitment based offers. + provisioning_state (google.cloud.channel_v1.types.Entitlement.ProvisioningState): + Output only. Current provisioning state of + the entitlement. + provisioned_service (google.cloud.channel_v1.types.ProvisionedService): + Output only. Service provisioning details for + the entitlement. + suspension_reasons (Sequence[google.cloud.channel_v1.types.Entitlement.SuspensionReason]): + Output only. Enumerable of all current + suspension reasons for an entitlement. + purchase_order_id (str): + Optional. This purchase order (PO) + information is for resellers to use for their + company tracking usage. If a purchaseOrderId + value is given, it appears in the API responses + and shows up in the invoice. The property + accepts up to 80 plain text characters. + trial_settings (google.cloud.channel_v1.types.TrialSettings): + Output only. Settings for trial offers. + association_info (google.cloud.channel_v1.types.AssociationInfo): + Association information to other + entitlements. + parameters (Sequence[google.cloud.channel_v1.types.Parameter]): + Extended entitlement parameters. When + creating an entitlement, valid parameters' names + and values are defined in the offer's parameter + definitions. + """ + class ProvisioningState(proto.Enum): + r"""Indicates the current provisioning state of the entitlement.""" + PROVISIONING_STATE_UNSPECIFIED = 0 + ACTIVE = 1 + SUSPENDED = 5 + + class SuspensionReason(proto.Enum): + r"""Suspension reason for an entitlement if + [provisioning_state][google.cloud.channel.v1.Entitlement.provisioning_state] + = SUSPENDED. + """ + SUSPENSION_REASON_UNSPECIFIED = 0 + RESELLER_INITIATED = 1 + TRIAL_ENDED = 2 + RENEWAL_WITH_TYPE_CANCEL = 3 + PENDING_TOS_ACCEPTANCE = 4 + OTHER = 100 + + name = proto.Field( + proto.STRING, + number=1, + ) + create_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + offer = proto.Field( + proto.STRING, + number=8, + ) + commitment_settings = proto.Field( + proto.MESSAGE, + number=12, + message='CommitmentSettings', + ) + provisioning_state = proto.Field( + proto.ENUM, + number=13, + enum=ProvisioningState, + ) + provisioned_service = proto.Field( + proto.MESSAGE, + number=16, + message='ProvisionedService', + ) + suspension_reasons = proto.RepeatedField( + proto.ENUM, + number=18, + enum=SuspensionReason, + ) + purchase_order_id = proto.Field( + proto.STRING, + number=19, + ) + trial_settings = proto.Field( + proto.MESSAGE, + number=21, + message='TrialSettings', + ) + association_info = proto.Field( + proto.MESSAGE, + number=23, + message='AssociationInfo', + ) + parameters = proto.RepeatedField( + proto.MESSAGE, + number=26, + message='Parameter', + ) + + +class Parameter(proto.Message): + r"""Definition for extended entitlement parameters. + + Attributes: + name (str): + Name of the parameter. + value (google.cloud.channel_v1.types.Value): + Value of the parameter. + editable (bool): + Output only. Specifies whether this parameter is allowed to + be changed. For example, for a Google Workspace Business + Starter entitlement in commitment plan, num_units is + editable when entitlement is active. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + value = proto.Field( + proto.MESSAGE, + number=2, + message=common.Value, + ) + editable = proto.Field( + proto.BOOL, + number=3, + ) + + +class AssociationInfo(proto.Message): + r"""Association links that an entitlement has to other + entitlements. + + Attributes: + base_entitlement (str): + The name of the base entitlement, for which + this entitlement is an add-on. + """ + + base_entitlement = proto.Field( + proto.STRING, + number=1, + ) + + +class ProvisionedService(proto.Message): + r"""Service provisioned for an entitlement. + + Attributes: + provisioning_id (str): + Output only. Provisioning ID of the + entitlement. For Google Workspace, this would be + the underlying Subscription ID. + product_id (str): + Output only. The product pertaining to the + provisioning resource as specified in the Offer. + sku_id (str): + Output only. The SKU pertaining to the + provisioning resource as specified in the Offer. + """ + + provisioning_id = proto.Field( + proto.STRING, + number=1, + ) + product_id = proto.Field( + proto.STRING, + number=2, + ) + sku_id = proto.Field( + proto.STRING, + number=3, + ) + + +class CommitmentSettings(proto.Message): + r"""Commitment settings for commitment-based offers. + + Attributes: + start_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Commitment start timestamp. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Commitment end timestamp. + renewal_settings (google.cloud.channel_v1.types.RenewalSettings): + Optional. Renewal settings applicable for a + commitment-based Offer. + """ + + start_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + renewal_settings = proto.Field( + proto.MESSAGE, + number=4, + message='RenewalSettings', + ) + + +class RenewalSettings(proto.Message): + r"""Renewal settings for renewable Offers. + + Attributes: + enable_renewal (bool): + If false, the plan will be completed at the + end date. + resize_unit_count (bool): + If true and enable_renewal = true, the unit (for example + seats or licenses) will be set to the number of active units + at renewal time. + payment_plan (google.cloud.channel_v1.types.PaymentPlan): + Describes how a reseller will be billed. + payment_cycle (google.cloud.channel_v1.types.Period): + Describes how frequently the reseller will be + billed, such as once per month. + """ + + enable_renewal = proto.Field( + proto.BOOL, + number=1, + ) + resize_unit_count = proto.Field( + proto.BOOL, + number=2, + ) + payment_plan = proto.Field( + proto.ENUM, + number=5, + enum=offers.PaymentPlan, + ) + payment_cycle = proto.Field( + proto.MESSAGE, + number=6, + message=offers.Period, + ) + + +class TrialSettings(proto.Message): + r"""Settings for trial offers. + + Attributes: + trial (bool): + Determines if the entitlement is in a trial or not: + + - ``true`` - The entitlement is in trial. + - ``false`` - The entitlement is not in trial. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Date when the trial ends. The value is in milliseconds using + the UNIX Epoch format. See an example `Epoch + converter `__. + """ + + trial = proto.Field( + proto.BOOL, + number=1, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + + +class TransferableSku(proto.Message): + r"""TransferableSku represents information a reseller needs to + view existing provisioned services for a customer that they do + not own. Read-only. + + Attributes: + transfer_eligibility (google.cloud.channel_v1.types.TransferEligibility): + Describes the transfer eligibility of a SKU. + sku (google.cloud.channel_v1.types.Sku): + The SKU pertaining to the provisioning + resource as specified in the Offer. + legacy_sku (google.cloud.channel_v1.types.Sku): + Optional. The customer to transfer has an + entitlement with the populated legacy SKU. + """ + + transfer_eligibility = proto.Field( + proto.MESSAGE, + number=9, + message='TransferEligibility', + ) + sku = proto.Field( + proto.MESSAGE, + number=11, + message=products.Sku, + ) + legacy_sku = proto.Field( + proto.MESSAGE, + number=12, + message=products.Sku, + ) + + +class TransferEligibility(proto.Message): + r"""Specifies transfer eligibility of a SKU. + + Attributes: + is_eligible (bool): + Whether reseller is eligible to transfer the + SKU. + description (str): + Localized description if reseller is not + eligible to transfer the SKU. + ineligibility_reason (google.cloud.channel_v1.types.TransferEligibility.Reason): + Specified the reason for ineligibility. + """ + class Reason(proto.Enum): + r"""Reason of ineligibility.""" + REASON_UNSPECIFIED = 0 + PENDING_TOS_ACCEPTANCE = 1 + SKU_NOT_ELIGIBLE = 2 + SKU_SUSPENDED = 3 + + is_eligible = proto.Field( + proto.BOOL, + number=1, + ) + description = proto.Field( + proto.STRING, + number=2, + ) + ineligibility_reason = proto.Field( + proto.ENUM, + number=3, + enum=Reason, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/offers.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/offers.py new file mode 100644 index 0000000..9a6bea1 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/types/offers.py @@ -0,0 +1,503 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.channel_v1.types import common +from google.cloud.channel_v1.types import products +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import money_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.channel.v1', + manifest={ + 'PromotionalOrderType', + 'PaymentPlan', + 'PaymentType', + 'ResourceType', + 'PeriodType', + 'Offer', + 'ParameterDefinition', + 'Constraints', + 'CustomerConstraints', + 'Plan', + 'PriceByResource', + 'Price', + 'PricePhase', + 'PriceTier', + 'Period', + }, +) + + +class PromotionalOrderType(proto.Enum): + r"""Constraints type for Promotional offers.""" + PROMOTIONAL_TYPE_UNSPECIFIED = 0 + NEW_UPGRADE = 1 + TRANSFER = 2 + PROMOTION_SWITCH = 3 + + +class PaymentPlan(proto.Enum): + r"""Describes how the reseller will be billed.""" + PAYMENT_PLAN_UNSPECIFIED = 0 + COMMITMENT = 1 + FLEXIBLE = 2 + FREE = 3 + TRIAL = 4 + OFFLINE = 5 + + +class PaymentType(proto.Enum): + r"""Specifies when the payment needs to happen.""" + PAYMENT_TYPE_UNSPECIFIED = 0 + PREPAY = 1 + POSTPAY = 2 + + +class ResourceType(proto.Enum): + r"""Represents the type for a monetizable resource(any entity on + which billing happens). For example, this could be MINUTES for + Google Voice and GB for Google Drive. One SKU can map to + multiple monetizable resources. + """ + RESOURCE_TYPE_UNSPECIFIED = 0 + SEAT = 1 + MAU = 2 + GB = 3 + LICENSED_USER = 4 + MINUTES = 5 + IAAS_USAGE = 6 + SUBSCRIPTION = 7 + + +class PeriodType(proto.Enum): + r"""Period Type.""" + PERIOD_TYPE_UNSPECIFIED = 0 + DAY = 1 + MONTH = 2 + YEAR = 3 + + +class Offer(proto.Message): + r"""Represents an offer made to resellers for purchase. An offer is + associated with a [Sku][google.cloud.channel.v1.Sku], has a plan for + payment, a price, and defines the constraints for buying. + + Attributes: + name (str): + Resource Name of the Offer. Format: + accounts/{account_id}/offers/{offer_id} + marketing_info (google.cloud.channel_v1.types.MarketingInfo): + Marketing information for the Offer. + sku (google.cloud.channel_v1.types.Sku): + SKU the offer is associated with. + plan (google.cloud.channel_v1.types.Plan): + Describes the payment plan for the Offer. + constraints (google.cloud.channel_v1.types.Constraints): + Constraints on transacting the Offer. + price_by_resources (Sequence[google.cloud.channel_v1.types.PriceByResource]): + Price for each monetizable resource type. + start_time (google.protobuf.timestamp_pb2.Timestamp): + Start of the Offer validity time. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. End of the Offer validity time. + parameter_definitions (Sequence[google.cloud.channel_v1.types.ParameterDefinition]): + Parameters required to use current Offer to + purchase. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + marketing_info = proto.Field( + proto.MESSAGE, + number=2, + message=products.MarketingInfo, + ) + sku = proto.Field( + proto.MESSAGE, + number=3, + message=products.Sku, + ) + plan = proto.Field( + proto.MESSAGE, + number=4, + message='Plan', + ) + constraints = proto.Field( + proto.MESSAGE, + number=5, + message='Constraints', + ) + price_by_resources = proto.RepeatedField( + proto.MESSAGE, + number=6, + message='PriceByResource', + ) + start_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + parameter_definitions = proto.RepeatedField( + proto.MESSAGE, + number=9, + message='ParameterDefinition', + ) + + +class ParameterDefinition(proto.Message): + r"""Parameter's definition. Specifies what parameter is required + to use the current Offer to purchase. + + Attributes: + name (str): + Name of the parameter. + parameter_type (google.cloud.channel_v1.types.ParameterDefinition.ParameterType): + Data type of the parameter. Minimal value, + Maximum value and allowed values will use + specified data type here. + min_value (google.cloud.channel_v1.types.Value): + Minimal value of the parameter, if + applicable. Inclusive. For example, minimal + commitment when purchasing Anthos is 0.01. + Applicable to INT64 and DOUBLE parameter types. + max_value (google.cloud.channel_v1.types.Value): + Maximum value of the parameter, if + applicable. Inclusive. For example, maximum + seats when purchasing Google Workspace Business + Standard. Applicable to INT64 and DOUBLE + parameter types. + allowed_values (Sequence[google.cloud.channel_v1.types.Value]): + If not empty, parameter values must be drawn from this list. + For example, [us-west1, us-west2, ...] Applicable to STRING + parameter type. + optional (bool): + If set to true, parameter is optional to + purchase this Offer. + """ + class ParameterType(proto.Enum): + r"""Data type of the parameter.""" + PARAMETER_TYPE_UNSPECIFIED = 0 + INT64 = 1 + STRING = 2 + DOUBLE = 3 + + name = proto.Field( + proto.STRING, + number=1, + ) + parameter_type = proto.Field( + proto.ENUM, + number=2, + enum=ParameterType, + ) + min_value = proto.Field( + proto.MESSAGE, + number=3, + message=common.Value, + ) + max_value = proto.Field( + proto.MESSAGE, + number=4, + message=common.Value, + ) + allowed_values = proto.RepeatedField( + proto.MESSAGE, + number=5, + message=common.Value, + ) + optional = proto.Field( + proto.BOOL, + number=6, + ) + + +class Constraints(proto.Message): + r"""Represents the constraints for buying the Offer. + + Attributes: + customer_constraints (google.cloud.channel_v1.types.CustomerConstraints): + Represents constraints required to purchase + the Offer for a customer. + """ + + customer_constraints = proto.Field( + proto.MESSAGE, + number=1, + message='CustomerConstraints', + ) + + +class CustomerConstraints(proto.Message): + r"""Represents constraints required to purchase the Offer for a + customer. + + Attributes: + allowed_regions (Sequence[str]): + Allowed geographical regions of the customer. + allowed_customer_types (Sequence[google.cloud.channel_v1.types.CloudIdentityInfo.CustomerType]): + Allowed Customer Type. + promotional_order_types (Sequence[google.cloud.channel_v1.types.PromotionalOrderType]): + Allowed Promotional Order Type. Present for + Promotional offers. + """ + + allowed_regions = proto.RepeatedField( + proto.STRING, + number=1, + ) + allowed_customer_types = proto.RepeatedField( + proto.ENUM, + number=2, + enum=common.CloudIdentityInfo.CustomerType, + ) + promotional_order_types = proto.RepeatedField( + proto.ENUM, + number=3, + enum='PromotionalOrderType', + ) + + +class Plan(proto.Message): + r"""The payment plan for the Offer. Describes how to make a + payment. + + Attributes: + payment_plan (google.cloud.channel_v1.types.PaymentPlan): + Describes how a reseller will be billed. + payment_type (google.cloud.channel_v1.types.PaymentType): + Specifies when the payment needs to happen. + payment_cycle (google.cloud.channel_v1.types.Period): + Describes how frequently the reseller will be + billed, such as once per month. + trial_period (google.cloud.channel_v1.types.Period): + Present for Offers with a trial period. + For trial-only Offers, a paid service needs to + start before the trial period ends for continued + service. + For Regular Offers with a trial period, the + regular pricing goes into effect when trial + period ends, or if paid service is started + before the end of the trial period. + billing_account (str): + Reseller Billing account to charge after an + offer transaction. Only present for Google Cloud + Platform offers. + """ + + payment_plan = proto.Field( + proto.ENUM, + number=1, + enum='PaymentPlan', + ) + payment_type = proto.Field( + proto.ENUM, + number=2, + enum='PaymentType', + ) + payment_cycle = proto.Field( + proto.MESSAGE, + number=3, + message='Period', + ) + trial_period = proto.Field( + proto.MESSAGE, + number=4, + message='Period', + ) + billing_account = proto.Field( + proto.STRING, + number=5, + ) + + +class PriceByResource(proto.Message): + r"""Represents price by resource type. + + Attributes: + resource_type (google.cloud.channel_v1.types.ResourceType): + Resource Type. Example: SEAT + price (google.cloud.channel_v1.types.Price): + Price of the Offer. Present if there are no + price phases. + price_phases (Sequence[google.cloud.channel_v1.types.PricePhase]): + Specifies the price by time range. + """ + + resource_type = proto.Field( + proto.ENUM, + number=1, + enum='ResourceType', + ) + price = proto.Field( + proto.MESSAGE, + number=2, + message='Price', + ) + price_phases = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='PricePhase', + ) + + +class Price(proto.Message): + r"""Represents the price of the Offer. + + Attributes: + base_price (google.type.money_pb2.Money): + Base price. + discount (float): + Discount percentage, represented as decimal. + For example, a 20% discount will be represent as + 0.2. + effective_price (google.type.money_pb2.Money): + Effective Price after applying the discounts. + external_price_uri (str): + Link to external price list, such as link to + Google Voice rate card. + """ + + base_price = proto.Field( + proto.MESSAGE, + number=1, + message=money_pb2.Money, + ) + discount = proto.Field( + proto.DOUBLE, + number=2, + ) + effective_price = proto.Field( + proto.MESSAGE, + number=3, + message=money_pb2.Money, + ) + external_price_uri = proto.Field( + proto.STRING, + number=4, + ) + + +class PricePhase(proto.Message): + r"""Specifies the price by the duration of months. + For example, a 20% discount for the first six months, then a 10% + discount starting on the seventh month. + + Attributes: + period_type (google.cloud.channel_v1.types.PeriodType): + Defines the phase period type. + first_period (int): + Defines first period for the phase. + last_period (int): + Defines first period for the phase. + price (google.cloud.channel_v1.types.Price): + Price of the phase. Present if there are no + price tiers. + price_tiers (Sequence[google.cloud.channel_v1.types.PriceTier]): + Price by the resource tiers. + """ + + period_type = proto.Field( + proto.ENUM, + number=1, + enum='PeriodType', + ) + first_period = proto.Field( + proto.INT32, + number=2, + ) + last_period = proto.Field( + proto.INT32, + number=3, + ) + price = proto.Field( + proto.MESSAGE, + number=4, + message='Price', + ) + price_tiers = proto.RepeatedField( + proto.MESSAGE, + number=5, + message='PriceTier', + ) + + +class PriceTier(proto.Message): + r"""Defines price at resource tier level. For example, an offer with + following definition : + + - Tier 1: Provide 25% discount for all seats between 1 and 25. + - Tier 2: Provide 10% discount for all seats between 26 and 100. + - Tier 3: Provide flat 15% discount for all seats above 100. + + Each of these tiers is represented as a PriceTier. + + Attributes: + first_resource (int): + First resource for which the tier price + applies. + last_resource (int): + Last resource for which the tier price + applies. + price (google.cloud.channel_v1.types.Price): + Price of the tier. + """ + + first_resource = proto.Field( + proto.INT32, + number=1, + ) + last_resource = proto.Field( + proto.INT32, + number=2, + ) + price = proto.Field( + proto.MESSAGE, + number=3, + message='Price', + ) + + +class Period(proto.Message): + r"""Represents period in days/months/years. + + Attributes: + duration (int): + Total duration of Period Type defined. + period_type (google.cloud.channel_v1.types.PeriodType): + Period Type. + """ + + duration = proto.Field( + proto.INT32, + number=1, + ) + period_type = proto.Field( + proto.ENUM, + number=2, + enum='PeriodType', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/operations.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/operations.py new file mode 100644 index 0000000..e561f46 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/types/operations.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import proto # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.channel.v1', + manifest={ + 'OperationMetadata', + }, +) + + +class OperationMetadata(proto.Message): + r"""Provides contextual information about a + [google.longrunning.Operation][google.longrunning.Operation]. + + Attributes: + operation_type (google.cloud.channel_v1.types.OperationMetadata.OperationType): + The RPC that initiated this Long Running + Operation. + """ + class OperationType(proto.Enum): + r"""RPCs that return a Long Running Operation.""" + OPERATION_TYPE_UNSPECIFIED = 0 + CREATE_ENTITLEMENT = 1 + CHANGE_RENEWAL_SETTINGS = 3 + START_PAID_SERVICE = 5 + ACTIVATE_ENTITLEMENT = 7 + SUSPEND_ENTITLEMENT = 8 + CANCEL_ENTITLEMENT = 9 + TRANSFER_ENTITLEMENTS = 10 + TRANSFER_ENTITLEMENTS_TO_GOOGLE = 11 + CHANGE_OFFER = 14 + CHANGE_PARAMETERS = 15 + PROVISION_CLOUD_IDENTITY = 16 + + operation_type = proto.Field( + proto.ENUM, + number=1, + enum=OperationType, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/products.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/products.py new file mode 100644 index 0000000..f4fe721 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/types/products.py @@ -0,0 +1,147 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import proto # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.channel.v1', + manifest={ + 'MediaType', + 'Product', + 'Sku', + 'MarketingInfo', + 'Media', + }, +) + + +class MediaType(proto.Enum): + r"""Type of media used.""" + MEDIA_TYPE_UNSPECIFIED = 0 + MEDIA_TYPE_IMAGE = 1 + + +class Product(proto.Message): + r"""A Product is the entity a customer uses when placing an + order. For example, Google Workspace, Google Voice, etc. + + Attributes: + name (str): + Resource Name of the Product. Format: products/{product_id} + marketing_info (google.cloud.channel_v1.types.MarketingInfo): + Marketing information for the product. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + marketing_info = proto.Field( + proto.MESSAGE, + number=2, + message='MarketingInfo', + ) + + +class Sku(proto.Message): + r"""Represents a product's purchasable Stock Keeping Unit (SKU). + SKUs represent the different variations of the product. For + example, Google Workspace Business Standard and Google Workspace + Business Plus are Google Workspace product SKUs. + + Attributes: + name (str): + Resource Name of the SKU. Format: + products/{product_id}/skus/{sku_id} + marketing_info (google.cloud.channel_v1.types.MarketingInfo): + Marketing information for the SKU. + product (google.cloud.channel_v1.types.Product): + Product the SKU is associated with. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + marketing_info = proto.Field( + proto.MESSAGE, + number=2, + message='MarketingInfo', + ) + product = proto.Field( + proto.MESSAGE, + number=3, + message='Product', + ) + + +class MarketingInfo(proto.Message): + r"""Represents the marketing information for a Product, SKU or + Offer. + + Attributes: + display_name (str): + Human readable name. + description (str): + Human readable description. Description can + contain HTML. + default_logo (google.cloud.channel_v1.types.Media): + Default logo. + """ + + display_name = proto.Field( + proto.STRING, + number=1, + ) + description = proto.Field( + proto.STRING, + number=2, + ) + default_logo = proto.Field( + proto.MESSAGE, + number=3, + message='Media', + ) + + +class Media(proto.Message): + r"""Represents media information. + + Attributes: + title (str): + Title of the media. + content (str): + URL of the media. + type_ (google.cloud.channel_v1.types.MediaType): + Type of the media. + """ + + title = proto.Field( + proto.STRING, + number=1, + ) + content = proto.Field( + proto.STRING, + number=2, + ) + type_ = proto.Field( + proto.ENUM, + number=3, + enum='MediaType', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/service.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/service.py new file mode 100644 index 0000000..d078f46 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/types/service.py @@ -0,0 +1,1991 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.channel_v1.types import channel_partner_links as gcc_channel_partner_links +from google.cloud.channel_v1.types import common +from google.cloud.channel_v1.types import customers as gcc_customers +from google.cloud.channel_v1.types import entitlements as gcc_entitlements +from google.cloud.channel_v1.types import offers as gcc_offers +from google.cloud.channel_v1.types import products as gcc_products +from google.protobuf import field_mask_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.channel.v1', + manifest={ + 'CheckCloudIdentityAccountsExistRequest', + 'CloudIdentityCustomerAccount', + 'CheckCloudIdentityAccountsExistResponse', + 'ListCustomersRequest', + 'ListCustomersResponse', + 'GetCustomerRequest', + 'CreateCustomerRequest', + 'UpdateCustomerRequest', + 'DeleteCustomerRequest', + 'ImportCustomerRequest', + 'ProvisionCloudIdentityRequest', + 'ListEntitlementsRequest', + 'ListEntitlementsResponse', + 'ListTransferableSkusRequest', + 'ListTransferableSkusResponse', + 'ListTransferableOffersRequest', + 'ListTransferableOffersResponse', + 'TransferableOffer', + 'GetEntitlementRequest', + 'ListChannelPartnerLinksRequest', + 'ListChannelPartnerLinksResponse', + 'GetChannelPartnerLinkRequest', + 'CreateChannelPartnerLinkRequest', + 'UpdateChannelPartnerLinkRequest', + 'CreateEntitlementRequest', + 'TransferEntitlementsRequest', + 'TransferEntitlementsResponse', + 'TransferEntitlementsToGoogleRequest', + 'ChangeParametersRequest', + 'ChangeRenewalSettingsRequest', + 'ChangeOfferRequest', + 'StartPaidServiceRequest', + 'CancelEntitlementRequest', + 'SuspendEntitlementRequest', + 'ActivateEntitlementRequest', + 'LookupOfferRequest', + 'ListProductsRequest', + 'ListProductsResponse', + 'ListSkusRequest', + 'ListSkusResponse', + 'ListOffersRequest', + 'ListOffersResponse', + 'ListPurchasableSkusRequest', + 'ListPurchasableSkusResponse', + 'PurchasableSku', + 'ListPurchasableOffersRequest', + 'ListPurchasableOffersResponse', + 'PurchasableOffer', + 'RegisterSubscriberRequest', + 'RegisterSubscriberResponse', + 'UnregisterSubscriberRequest', + 'UnregisterSubscriberResponse', + 'ListSubscribersRequest', + 'ListSubscribersResponse', + }, +) + + +class CheckCloudIdentityAccountsExistRequest(proto.Message): + r"""Request message for + [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist]. + + Attributes: + parent (str): + Required. The reseller account's resource name. Parent uses + the format: accounts/{account_id} + domain (str): + Required. Domain to fetch for Cloud Identity + account customer. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + domain = proto.Field( + proto.STRING, + number=2, + ) + + +class CloudIdentityCustomerAccount(proto.Message): + r"""Entity representing a Cloud Identity account that may be + associated with a Channel Services API partner. + + Attributes: + existing (bool): + Returns true if a Cloud Identity account + exists for a specific domain. + owned (bool): + Returns true if the Cloud Identity account is + associated with a customer of the Channel + Services partner. + customer_name (str): + If owned = true, the name of the customer that owns the + Cloud Identity account. Customer_name uses the format: + accounts/{account_id}/customers/{customer_id} + customer_cloud_identity_id (str): + If existing = true, the Cloud Identity ID of + the customer. + """ + + existing = proto.Field( + proto.BOOL, + number=1, + ) + owned = proto.Field( + proto.BOOL, + number=2, + ) + customer_name = proto.Field( + proto.STRING, + number=3, + ) + customer_cloud_identity_id = proto.Field( + proto.STRING, + number=4, + ) + + +class CheckCloudIdentityAccountsExistResponse(proto.Message): + r"""Response message for + [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist]. + + Attributes: + cloud_identity_accounts (Sequence[google.cloud.channel_v1.types.CloudIdentityCustomerAccount]): + The Cloud Identity accounts associated with + the domain. + """ + + cloud_identity_accounts = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='CloudIdentityCustomerAccount', + ) + + +class ListCustomersRequest(proto.Message): + r"""Request message for + [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers] + + Attributes: + parent (str): + Required. The resource name of the reseller account to list + customers from. Parent uses the format: + accounts/{account_id}. + page_size (int): + Optional. The maximum number of customers to + return. The service may return fewer than this + value. If unspecified, returns at most 10 + customers. The maximum value is 50. + page_token (str): + Optional. A token identifying a page of results other than + the first page. Obtained through + [ListCustomersResponse.next_page_token][google.cloud.channel.v1.ListCustomersResponse.next_page_token] + of the previous + [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers] + call. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + + +class ListCustomersResponse(proto.Message): + r"""Response message for + [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers]. + + Attributes: + customers (Sequence[google.cloud.channel_v1.types.Customer]): + The customers belonging to a reseller or + distributor. + next_page_token (str): + A token to retrieve the next page of results. Pass to + [ListCustomersRequest.page_token][google.cloud.channel.v1.ListCustomersRequest.page_token] + to obtain that page. + """ + + @property + def raw_page(self): + return self + + customers = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gcc_customers.Customer, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class GetCustomerRequest(proto.Message): + r"""Request message for + [CloudChannelService.GetCustomer][google.cloud.channel.v1.CloudChannelService.GetCustomer]. + + Attributes: + name (str): + Required. The resource name of the customer to retrieve. + Name uses the format: + accounts/{account_id}/customers/{customer_id} + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateCustomerRequest(proto.Message): + r"""Request message for + [CloudChannelService.CreateCustomer][google.cloud.channel.v1.CloudChannelService.CreateCustomer] + + Attributes: + parent (str): + Required. The resource name of reseller account in which to + create the customer. Parent uses the format: + accounts/{account_id} + customer (google.cloud.channel_v1.types.Customer): + Required. The customer to create. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + customer = proto.Field( + proto.MESSAGE, + number=2, + message=gcc_customers.Customer, + ) + + +class UpdateCustomerRequest(proto.Message): + r"""Request message for + [CloudChannelService.UpdateCustomer][google.cloud.channel.v1.CloudChannelService.UpdateCustomer]. + + Attributes: + customer (google.cloud.channel_v1.types.Customer): + Required. New contents of the customer. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The update mask that applies to the resource. + Optional. + """ + + customer = proto.Field( + proto.MESSAGE, + number=2, + message=gcc_customers.Customer, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=3, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteCustomerRequest(proto.Message): + r"""Request message for + [CloudChannelService.DeleteCustomer][google.cloud.channel.v1.CloudChannelService.DeleteCustomer]. + + Attributes: + name (str): + Required. The resource name of the customer + to delete. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ImportCustomerRequest(proto.Message): + r"""Request message for + [CloudChannelService.ImportCustomer][google.cloud.channel.v1.CloudChannelService.ImportCustomer] + + Attributes: + domain (str): + Required. Customer domain. + cloud_identity_id (str): + Required. Customer's Cloud Identity ID + parent (str): + Required. The resource name of the reseller's account. + Parent takes the format: accounts/{account_id} or + accounts/{account_id}/channelPartnerLinks/{channel_partner_id} + auth_token (str): + Optional. The super admin of the resold + customer generates this token to authorize a + reseller to access their Cloud Identity and + purchase entitlements on their behalf. You can + omit this token after authorization. See + https://support.google.com/a/answer/7643790 for + more details. + overwrite_if_exists (bool): + Required. Choose to overwrite an existing + customer if found. This must be set to true if + there is an existing customer with a conflicting + region code or domain. + channel_partner_id (str): + Optional. Cloud Identity ID of a channel + partner who will be the direct reseller for the + customer's order. This field is required for + 2-tier transfer scenarios and can be provided + via the request Parent binding as well. + customer (str): + Optional. Specifies the customer that will receive imported + Cloud Identity information. Format: + accounts/{account_id}/customers/{customer_id} + """ + + domain = proto.Field( + proto.STRING, + number=2, + oneof='customer_identity', + ) + cloud_identity_id = proto.Field( + proto.STRING, + number=3, + oneof='customer_identity', + ) + parent = proto.Field( + proto.STRING, + number=1, + ) + auth_token = proto.Field( + proto.STRING, + number=4, + ) + overwrite_if_exists = proto.Field( + proto.BOOL, + number=5, + ) + channel_partner_id = proto.Field( + proto.STRING, + number=6, + ) + customer = proto.Field( + proto.STRING, + number=7, + ) + + +class ProvisionCloudIdentityRequest(proto.Message): + r"""Request message for + [CloudChannelService.ProvisionCloudIdentity][google.cloud.channel.v1.CloudChannelService.ProvisionCloudIdentity] + + Attributes: + customer (str): + Required. Resource name of the customer. Format: + accounts/{account_id}/customers/{customer_id} + cloud_identity_info (google.cloud.channel_v1.types.CloudIdentityInfo): + CloudIdentity-specific customer information. + user (google.cloud.channel_v1.types.AdminUser): + Admin user information. + validate_only (bool): + Validate the request and preview the review, + but do not post it. + """ + + customer = proto.Field( + proto.STRING, + number=1, + ) + cloud_identity_info = proto.Field( + proto.MESSAGE, + number=2, + message=common.CloudIdentityInfo, + ) + user = proto.Field( + proto.MESSAGE, + number=3, + message=common.AdminUser, + ) + validate_only = proto.Field( + proto.BOOL, + number=4, + ) + + +class ListEntitlementsRequest(proto.Message): + r"""Request message for + [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements] + + Attributes: + parent (str): + Required. The resource name of the reseller's customer + account to list entitlements for. Parent uses the format: + accounts/{account_id}/customers/{customer_id} + page_size (int): + Optional. Requested page size. Server might + return fewer results than requested. If + unspecified, return at most 50 entitlements. The + maximum value is 100; the server will coerce + values above 100. + page_token (str): + Optional. A token for a page of results other than the first + page. Obtained using + [ListEntitlementsResponse.next_page_token][google.cloud.channel.v1.ListEntitlementsResponse.next_page_token] + of the previous + [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements] + call. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + + +class ListEntitlementsResponse(proto.Message): + r"""Response message for + [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements]. + + Attributes: + entitlements (Sequence[google.cloud.channel_v1.types.Entitlement]): + The reseller customer's entitlements. + next_page_token (str): + A token to list the next page of results. Pass to + [ListEntitlementsRequest.page_token][google.cloud.channel.v1.ListEntitlementsRequest.page_token] + to obtain that page. + """ + + @property + def raw_page(self): + return self + + entitlements = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gcc_entitlements.Entitlement, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class ListTransferableSkusRequest(proto.Message): + r"""Request message for + [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus] + + Attributes: + cloud_identity_id (str): + Customer's Cloud Identity ID + customer_name (str): + A reseller is required to create a customer and use the + resource name of the created customer here. Customer_name + uses the format: + accounts/{account_id}/customers/{customer_id} + parent (str): + Required. The reseller account's resource name. Parent uses + the format: accounts/{account_id} + page_size (int): + The requested page size. Server might return + fewer results than requested. If unspecified, + returns at most 100 SKUs. The maximum value is + 1000; the server will coerce values above 1000. + Optional. + page_token (str): + A token for a page of results other than the first page. + Obtained using + [ListTransferableSkusResponse.next_page_token][google.cloud.channel.v1.ListTransferableSkusResponse.next_page_token] + of the previous + [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus] + call. Optional. + auth_token (str): + The super admin of the resold customer + generates this token to authorize a reseller to + access their Cloud Identity and purchase + entitlements on their behalf. You can omit this + token after authorization. See + https://support.google.com/a/answer/7643790 for + more details. + language_code (str): + The BCP-47 language code. For example, "en- + S". The response will localize in the + corresponding language code, if specified. The + default value is "en-US". + Optional. + """ + + cloud_identity_id = proto.Field( + proto.STRING, + number=4, + oneof='transferred_customer_identity', + ) + customer_name = proto.Field( + proto.STRING, + number=7, + oneof='transferred_customer_identity', + ) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + auth_token = proto.Field( + proto.STRING, + number=5, + ) + language_code = proto.Field( + proto.STRING, + number=6, + ) + + +class ListTransferableSkusResponse(proto.Message): + r"""Response message for + [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus]. + + Attributes: + transferable_skus (Sequence[google.cloud.channel_v1.types.TransferableSku]): + Information about existing SKUs for a + customer that needs a transfer. + next_page_token (str): + A token to retrieve the next page of results. Pass to + [ListTransferableSkusRequest.page_token][google.cloud.channel.v1.ListTransferableSkusRequest.page_token] + to obtain that page. + """ + + @property + def raw_page(self): + return self + + transferable_skus = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gcc_entitlements.TransferableSku, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class ListTransferableOffersRequest(proto.Message): + r"""Request message for + [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers] + + Attributes: + cloud_identity_id (str): + Customer's Cloud Identity ID + customer_name (str): + A reseller should create a customer and use + the resource name of that customer here. + parent (str): + Required. The resource name of the reseller's + account. + page_size (int): + Requested page size. Server might return + fewer results than requested. If unspecified, + returns at most 100 offers. The maximum value is + 1000; the server will coerce values above 1000. + page_token (str): + A token for a page of results other than the first page. + Obtained using + [ListTransferableOffersResponse.next_page_token][google.cloud.channel.v1.ListTransferableOffersResponse.next_page_token] + of the previous + [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers] + call. + sku (str): + Required. The SKU to look up Offers for. + language_code (str): + The BCP-47 language code. For example, "en- + S". The response will localize in the + corresponding language code, if specified. The + default value is "en-US". + """ + + cloud_identity_id = proto.Field( + proto.STRING, + number=4, + oneof='transferred_customer_identity', + ) + customer_name = proto.Field( + proto.STRING, + number=5, + oneof='transferred_customer_identity', + ) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + sku = proto.Field( + proto.STRING, + number=6, + ) + language_code = proto.Field( + proto.STRING, + number=7, + ) + + +class ListTransferableOffersResponse(proto.Message): + r"""Response message for + [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers]. + + Attributes: + transferable_offers (Sequence[google.cloud.channel_v1.types.TransferableOffer]): + Information about Offers for a customer that + can be used for transfer. + next_page_token (str): + A token to retrieve the next page of results. Pass to + [ListTransferableOffersRequest.page_token][google.cloud.channel.v1.ListTransferableOffersRequest.page_token] + to obtain that page. + """ + + @property + def raw_page(self): + return self + + transferable_offers = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='TransferableOffer', + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class TransferableOffer(proto.Message): + r"""TransferableOffer represents an Offer that can be used in + Transfer. Read-only. + + Attributes: + offer (google.cloud.channel_v1.types.Offer): + Offer with parameter constraints updated to + allow the Transfer. + """ + + offer = proto.Field( + proto.MESSAGE, + number=1, + message=gcc_offers.Offer, + ) + + +class GetEntitlementRequest(proto.Message): + r"""Request message for + [CloudChannelService.GetEntitlement][google.cloud.channel.v1.CloudChannelService.GetEntitlement]. + + Attributes: + name (str): + Required. The resource name of the entitlement to retrieve. + Name uses the format: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListChannelPartnerLinksRequest(proto.Message): + r"""Request message for + [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks] + + Attributes: + parent (str): + Required. The resource name of the reseller account for + listing channel partner links. Parent uses the format: + accounts/{account_id} + page_size (int): + Optional. Requested page size. Server might + return fewer results than requested. If + unspecified, server will pick a default size + (25). The maximum value is 200; the server will + coerce values above 200. + page_token (str): + Optional. A token for a page of results other than the first + page. Obtained using + [ListChannelPartnerLinksResponse.next_page_token][google.cloud.channel.v1.ListChannelPartnerLinksResponse.next_page_token] + of the previous + [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks] + call. + view (google.cloud.channel_v1.types.ChannelPartnerLinkView): + Optional. The level of granularity the + ChannelPartnerLink will display. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + view = proto.Field( + proto.ENUM, + number=4, + enum=gcc_channel_partner_links.ChannelPartnerLinkView, + ) + + +class ListChannelPartnerLinksResponse(proto.Message): + r"""Response message for + [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks]. + + Attributes: + channel_partner_links (Sequence[google.cloud.channel_v1.types.ChannelPartnerLink]): + The Channel partner links for a reseller. + next_page_token (str): + A token to retrieve the next page of results. Pass to + [ListChannelPartnerLinksRequest.page_token][google.cloud.channel.v1.ListChannelPartnerLinksRequest.page_token] + to obtain that page. + """ + + @property + def raw_page(self): + return self + + channel_partner_links = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gcc_channel_partner_links.ChannelPartnerLink, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class GetChannelPartnerLinkRequest(proto.Message): + r"""Request message for + [CloudChannelService.GetChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.GetChannelPartnerLink]. + + Attributes: + name (str): + Required. The resource name of the channel partner link to + retrieve. Name uses the format: + accounts/{account_id}/channelPartnerLinks/{id} where {id} is + the Cloud Identity ID of the partner. + view (google.cloud.channel_v1.types.ChannelPartnerLinkView): + Optional. The level of granularity the + ChannelPartnerLink will display. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + view = proto.Field( + proto.ENUM, + number=2, + enum=gcc_channel_partner_links.ChannelPartnerLinkView, + ) + + +class CreateChannelPartnerLinkRequest(proto.Message): + r"""Request message for + [CloudChannelService.CreateChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.CreateChannelPartnerLink] + + Attributes: + parent (str): + Required. Create a channel partner link for the provided + reseller account's resource name. Parent uses the format: + accounts/{account_id} + channel_partner_link (google.cloud.channel_v1.types.ChannelPartnerLink): + Required. The channel partner link to create. Either + channel_partner_link.reseller_cloud_identity_id or domain + can be used to create a link. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + channel_partner_link = proto.Field( + proto.MESSAGE, + number=2, + message=gcc_channel_partner_links.ChannelPartnerLink, + ) + + +class UpdateChannelPartnerLinkRequest(proto.Message): + r"""Request message for + [CloudChannelService.UpdateChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.UpdateChannelPartnerLink] + + Attributes: + name (str): + Required. The resource name of the channel partner link to + cancel. Name uses the format: + accounts/{account_id}/channelPartnerLinks/{id} where {id} is + the Cloud Identity ID of the partner. + channel_partner_link (google.cloud.channel_v1.types.ChannelPartnerLink): + Required. The channel partner link to update. Only + channel_partner_link.link_state is allowed for updates. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask that applies to the resource. The + only allowable value for an update mask is + channel_partner_link.link_state. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + channel_partner_link = proto.Field( + proto.MESSAGE, + number=2, + message=gcc_channel_partner_links.ChannelPartnerLink, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=3, + message=field_mask_pb2.FieldMask, + ) + + +class CreateEntitlementRequest(proto.Message): + r"""Request message for + [CloudChannelService.CreateEntitlement][google.cloud.channel.v1.CloudChannelService.CreateEntitlement] + + Attributes: + parent (str): + Required. The resource name of the reseller's customer + account in which to create the entitlement. Parent uses the + format: accounts/{account_id}/customers/{customer_id} + entitlement (google.cloud.channel_v1.types.Entitlement): + Required. The entitlement to create. + request_id (str): + Optional. You can specify an optional unique request ID, and + if you need to retry your request, the server will know to + ignore the request if it's complete. + + For example, you make an initial request and the request + times out. If you make the request again with the same + request ID, the server can check if it received the original + operation with the same request ID. If it did, it will + ignore the second request. + + 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, + ) + entitlement = proto.Field( + proto.MESSAGE, + number=2, + message=gcc_entitlements.Entitlement, + ) + request_id = proto.Field( + proto.STRING, + number=5, + ) + + +class TransferEntitlementsRequest(proto.Message): + r"""Request message for + [CloudChannelService.TransferEntitlements][google.cloud.channel.v1.CloudChannelService.TransferEntitlements]. + + Attributes: + parent (str): + Required. The resource name of the reseller's customer + account that will receive transferred entitlements. Parent + uses the format: + accounts/{account_id}/customers/{customer_id} + entitlements (Sequence[google.cloud.channel_v1.types.Entitlement]): + Required. The new entitlements to create or + transfer. + auth_token (str): + The super admin of the resold customer + generates this token to authorize a reseller to + access their Cloud Identity and purchase + entitlements on their behalf. You can omit this + token after authorization. See + https://support.google.com/a/answer/7643790 for + more details. + request_id (str): + Optional. You can specify an optional unique request ID, and + if you need to retry your request, the server will know to + ignore the request if it's complete. + + For example, you make an initial request and the request + times out. If you make the request again with the same + request ID, the server can check if it received the original + operation with the same request ID. If it did, it will + ignore the second request. + + 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, + ) + entitlements = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=gcc_entitlements.Entitlement, + ) + auth_token = proto.Field( + proto.STRING, + number=4, + ) + request_id = proto.Field( + proto.STRING, + number=6, + ) + + +class TransferEntitlementsResponse(proto.Message): + r"""Response message for + [CloudChannelService.TransferEntitlements][google.cloud.channel.v1.CloudChannelService.TransferEntitlements]. + This is put in the response field of google.longrunning.Operation. + + Attributes: + entitlements (Sequence[google.cloud.channel_v1.types.Entitlement]): + The transferred entitlements. + """ + + entitlements = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gcc_entitlements.Entitlement, + ) + + +class TransferEntitlementsToGoogleRequest(proto.Message): + r"""Request message for + [CloudChannelService.TransferEntitlementsToGoogle][google.cloud.channel.v1.CloudChannelService.TransferEntitlementsToGoogle]. + + Attributes: + parent (str): + Required. The resource name of the reseller's customer + account where the entitlements transfer from. Parent uses + the format: accounts/{account_id}/customers/{customer_id} + entitlements (Sequence[google.cloud.channel_v1.types.Entitlement]): + Required. The entitlements to transfer to + Google. + request_id (str): + Optional. You can specify an optional unique request ID, and + if you need to retry your request, the server will know to + ignore the request if it's complete. + + For example, you make an initial request and the request + times out. If you make the request again with the same + request ID, the server can check if it received the original + operation with the same request ID. If it did, it will + ignore the second request. + + 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, + ) + entitlements = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=gcc_entitlements.Entitlement, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class ChangeParametersRequest(proto.Message): + r"""Request message for [CloudChannelService.ChangeParametersRequest][]. + + Attributes: + name (str): + Required. The name of the entitlement to update. Name uses + the format: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} + parameters (Sequence[google.cloud.channel_v1.types.Parameter]): + Required. Entitlement parameters to update. + You can only change editable parameters. + request_id (str): + Optional. You can specify an optional unique request ID, and + if you need to retry your request, the server will know to + ignore the request if it's complete. + + For example, you make an initial request and the request + times out. If you make the request again with the same + request ID, the server can check if it received the original + operation with the same request ID. If it did, it will + ignore the second request. + + The request ID must be a valid + `UUID `__ with the + exception that zero UUID is not supported + (``00000000-0000-0000-0000-000000000000``). + purchase_order_id (str): + Optional. Purchase order ID provided by the + reseller. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + parameters = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=gcc_entitlements.Parameter, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + purchase_order_id = proto.Field( + proto.STRING, + number=5, + ) + + +class ChangeRenewalSettingsRequest(proto.Message): + r"""Request message for + [CloudChannelService.ChangeRenewalSettings][google.cloud.channel.v1.CloudChannelService.ChangeRenewalSettings]. + + Attributes: + name (str): + Required. The name of the entitlement to update. Name uses + the format: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} + renewal_settings (google.cloud.channel_v1.types.RenewalSettings): + Required. New renewal settings. + request_id (str): + Optional. You can specify an optional unique request ID, and + if you need to retry your request, the server will know to + ignore the request if it's complete. + + For example, you make an initial request and the request + times out. If you make the request again with the same + request ID, the server can check if it received the original + operation with the same request ID. If it did, it will + ignore the second request. + + 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, + ) + renewal_settings = proto.Field( + proto.MESSAGE, + number=4, + message=gcc_entitlements.RenewalSettings, + ) + request_id = proto.Field( + proto.STRING, + number=5, + ) + + +class ChangeOfferRequest(proto.Message): + r"""Request message for + [CloudChannelService.ChangeOffer][google.cloud.channel.v1.CloudChannelService.ChangeOffer]. + + Attributes: + name (str): + Required. The resource name of the entitlement to update. + Name uses the format: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} + offer (str): + Required. New Offer. Format: + accounts/{account_id}/offers/{offer_id}. + parameters (Sequence[google.cloud.channel_v1.types.Parameter]): + Optional. Parameters needed to purchase the + Offer. + purchase_order_id (str): + Optional. Purchase order id provided by the + reseller. + request_id (str): + Optional. You can specify an optional unique request ID, and + if you need to retry your request, the server will know to + ignore the request if it's complete. + + For example, you make an initial request and the request + times out. If you make the request again with the same + request ID, the server can check if it received the original + operation with the same request ID. If it did, it will + ignore the second request. + + 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, + ) + offer = proto.Field( + proto.STRING, + number=2, + ) + parameters = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=gcc_entitlements.Parameter, + ) + purchase_order_id = proto.Field( + proto.STRING, + number=5, + ) + request_id = proto.Field( + proto.STRING, + number=6, + ) + + +class StartPaidServiceRequest(proto.Message): + r"""Request message for + [CloudChannelService.StartPaidService][google.cloud.channel.v1.CloudChannelService.StartPaidService]. + + Attributes: + name (str): + Required. The name of the entitlement to start a paid + service for. Name uses the format: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} + request_id (str): + Optional. You can specify an optional unique request ID, and + if you need to retry your request, the server will know to + ignore the request if it's complete. + + For example, you make an initial request and the request + times out. If you make the request again with the same + request ID, the server can check if it received the original + operation with the same request ID. If it did, it will + ignore the second request. + + 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=3, + ) + + +class CancelEntitlementRequest(proto.Message): + r"""Request message for + [CloudChannelService.CancelEntitlement][google.cloud.channel.v1.CloudChannelService.CancelEntitlement]. + + Attributes: + name (str): + Required. The resource name of the entitlement to cancel. + Name uses the format: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} + request_id (str): + Optional. You can specify an optional unique request ID, and + if you need to retry your request, the server will know to + ignore the request if it's complete. + + For example, you make an initial request and the request + times out. If you make the request again with the same + request ID, the server can check if it received the original + operation with the same request ID. If it did, it will + ignore the second request. + + 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=3, + ) + + +class SuspendEntitlementRequest(proto.Message): + r"""Request message for + [CloudChannelService.SuspendEntitlement][google.cloud.channel.v1.CloudChannelService.SuspendEntitlement]. + + Attributes: + name (str): + Required. The resource name of the entitlement to suspend. + Name uses the format: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} + request_id (str): + Optional. You can specify an optional unique request ID, and + if you need to retry your request, the server will know to + ignore the request if it's complete. + + For example, you make an initial request and the request + times out. If you make the request again with the same + request ID, the server can check if it received the original + operation with the same request ID. If it did, it will + ignore the second request. + + 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=3, + ) + + +class ActivateEntitlementRequest(proto.Message): + r"""Request message for + [CloudChannelService.ActivateEntitlement][google.cloud.channel.v1.CloudChannelService.ActivateEntitlement]. + + Attributes: + name (str): + Required. The resource name of the entitlement to activate. + Name uses the format: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} + request_id (str): + Optional. You can specify an optional unique request ID, and + if you need to retry your request, the server will know to + ignore the request if it's complete. + + For example, you make an initial request and the request + times out. If you make the request again with the same + request ID, the server can check if it received the original + operation with the same request ID. If it did, it will + ignore the second request. + + 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=3, + ) + + +class LookupOfferRequest(proto.Message): + r"""Request message for LookupOffer. + + Attributes: + entitlement (str): + Required. The resource name of the entitlement to retrieve + the Offer. Entitlement uses the format: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} + """ + + entitlement = proto.Field( + proto.STRING, + number=1, + ) + + +class ListProductsRequest(proto.Message): + r"""Request message for ListProducts. + + Attributes: + account (str): + Required. The resource name of the reseller account. Format: + accounts/{account_id}. + page_size (int): + Optional. Requested page size. Server might + return fewer results than requested. If + unspecified, returns at most 100 Products. The + maximum value is 1000; the server will coerce + values above 1000. + page_token (str): + Optional. A token for a page of results other + than the first page. + language_code (str): + Optional. The BCP-47 language code. For + example, "en-US". The response will localize in + the corresponding language code, if specified. + The default value is "en-US". + """ + + account = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + language_code = proto.Field( + proto.STRING, + number=4, + ) + + +class ListProductsResponse(proto.Message): + r"""Response message for ListProducts. + + Attributes: + products (Sequence[google.cloud.channel_v1.types.Product]): + List of Products requested. + next_page_token (str): + A token to retrieve the next page of results. + """ + + @property + def raw_page(self): + return self + + products = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gcc_products.Product, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class ListSkusRequest(proto.Message): + r"""Request message for ListSkus. + + Attributes: + parent (str): + Required. The resource name of the Product to list SKUs for. + Parent uses the format: products/{product_id}. Supports + products/- to retrieve SKUs for all products. + account (str): + Required. Resource name of the reseller. Format: + accounts/{account_id}. + page_size (int): + Optional. Requested page size. Server might + return fewer results than requested. If + unspecified, returns at most 100 SKUs. The + maximum value is 1000; the server will coerce + values above 1000. + page_token (str): + Optional. A token for a page of results other + than the first page. Optional. + language_code (str): + Optional. The BCP-47 language code. For + example, "en-US". The response will localize in + the corresponding language code, if specified. + The default value is "en-US". + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + account = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) + language_code = proto.Field( + proto.STRING, + number=5, + ) + + +class ListSkusResponse(proto.Message): + r"""Response message for ListSkus. + + Attributes: + skus (Sequence[google.cloud.channel_v1.types.Sku]): + The list of SKUs requested. + next_page_token (str): + A token to retrieve the next page of results. + """ + + @property + def raw_page(self): + return self + + skus = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gcc_products.Sku, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class ListOffersRequest(proto.Message): + r"""Request message for ListOffers. + + Attributes: + parent (str): + Required. The resource name of the reseller account from + which to list Offers. Parent uses the format: + accounts/{account_id}. + page_size (int): + Optional. Requested page size. Server might + return fewer results than requested. If + unspecified, returns at most 500 Offers. The + maximum value is 1000; the server will coerce + values above 1000. + page_token (str): + Optional. A token for a page of results other + than the first page. + filter (str): + Optional. The expression to filter results by + name (name of the Offer), sku.name (name of the + SKU), or sku.product.name (name of the Product). + Example 1: sku.product.name=products/p1 AND + sku.name!=products/p1/skus/s1 Example 2: + name=accounts/a1/offers/o1 + language_code (str): + Optional. The BCP-47 language code. For + example, "en-US". The response will localize in + the corresponding language code, if specified. + The default value is "en-US". + """ + + 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, + ) + language_code = proto.Field( + proto.STRING, + number=5, + ) + + +class ListOffersResponse(proto.Message): + r"""Response message for ListOffers. + + Attributes: + offers (Sequence[google.cloud.channel_v1.types.Offer]): + The list of Offers requested. + next_page_token (str): + A token to retrieve the next page of results. + """ + + @property + def raw_page(self): + return self + + offers = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gcc_offers.Offer, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class ListPurchasableSkusRequest(proto.Message): + r"""Request message for ListPurchasableSkus. + + Attributes: + create_entitlement_purchase (google.cloud.channel_v1.types.ListPurchasableSkusRequest.CreateEntitlementPurchase): + List SKUs for CreateEntitlement purchase. + change_offer_purchase (google.cloud.channel_v1.types.ListPurchasableSkusRequest.ChangeOfferPurchase): + List SKUs for ChangeOffer purchase with a new + SKU. + customer (str): + Required. The resource name of the customer to list SKUs + for. Format: accounts/{account_id}/customers/{customer_id}. + page_size (int): + Optional. Requested page size. Server might + return fewer results than requested. If + unspecified, returns at most 100 SKUs. The + maximum value is 1000; the server will coerce + values above 1000. + page_token (str): + Optional. A token for a page of results other + than the first page. + language_code (str): + Optional. The BCP-47 language code. For + example, "en-US". The response will localize in + the corresponding language code, if specified. + The default value is "en-US". + """ + + class CreateEntitlementPurchase(proto.Message): + r"""List SKUs for a new entitlement. Make the purchase using + [CloudChannelService.CreateEntitlement][google.cloud.channel.v1.CloudChannelService.CreateEntitlement]. + + Attributes: + product (str): + Required. List SKUs belonging to this Product. Format: + products/{product_id}. Supports products/- to retrieve SKUs + for all products. + """ + + product = proto.Field( + proto.STRING, + number=1, + ) + + class ChangeOfferPurchase(proto.Message): + r"""List SKUs for upgrading or downgrading an entitlement. Make the + purchase using + [CloudChannelService.ChangeOffer][google.cloud.channel.v1.CloudChannelService.ChangeOffer]. + + Attributes: + entitlement (str): + Required. Resource name of the entitlement. Format: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} + change_type (google.cloud.channel_v1.types.ListPurchasableSkusRequest.ChangeOfferPurchase.ChangeType): + Required. Change Type for the entitlement. + """ + class ChangeType(proto.Enum): + r"""Change Type enum.""" + CHANGE_TYPE_UNSPECIFIED = 0 + UPGRADE = 1 + DOWNGRADE = 2 + + entitlement = proto.Field( + proto.STRING, + number=1, + ) + change_type = proto.Field( + proto.ENUM, + number=2, + enum='ListPurchasableSkusRequest.ChangeOfferPurchase.ChangeType', + ) + + create_entitlement_purchase = proto.Field( + proto.MESSAGE, + number=2, + oneof='purchase_option', + message=CreateEntitlementPurchase, + ) + change_offer_purchase = proto.Field( + proto.MESSAGE, + number=3, + oneof='purchase_option', + message=ChangeOfferPurchase, + ) + customer = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=4, + ) + page_token = proto.Field( + proto.STRING, + number=5, + ) + language_code = proto.Field( + proto.STRING, + number=6, + ) + + +class ListPurchasableSkusResponse(proto.Message): + r"""Response message for ListPurchasableSkus. + + Attributes: + purchasable_skus (Sequence[google.cloud.channel_v1.types.PurchasableSku]): + The list of SKUs requested. + next_page_token (str): + A token to retrieve the next page of results. + """ + + @property + def raw_page(self): + return self + + purchasable_skus = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='PurchasableSku', + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class PurchasableSku(proto.Message): + r"""SKU that you can purchase. This is used in ListPurchasableSku + API response. + + Attributes: + sku (google.cloud.channel_v1.types.Sku): + SKU + """ + + sku = proto.Field( + proto.MESSAGE, + number=1, + message=gcc_products.Sku, + ) + + +class ListPurchasableOffersRequest(proto.Message): + r"""Request message for ListPurchasableOffers. + + Attributes: + create_entitlement_purchase (google.cloud.channel_v1.types.ListPurchasableOffersRequest.CreateEntitlementPurchase): + List Offers for CreateEntitlement purchase. + change_offer_purchase (google.cloud.channel_v1.types.ListPurchasableOffersRequest.ChangeOfferPurchase): + List Offers for ChangeOffer purchase. + customer (str): + Required. The resource name of the customer to list Offers + for. Format: accounts/{account_id}/customers/{customer_id}. + page_size (int): + Optional. Requested page size. Server might + return fewer results than requested. If + unspecified, returns at most 100 Offers. The + maximum value is 1000; the server will coerce + values above 1000. + page_token (str): + Optional. A token for a page of results other + than the first page. + language_code (str): + Optional. The BCP-47 language code. For + example, "en-US". The response will localize in + the corresponding language code, if specified. + The default value is "en-US". + """ + + class CreateEntitlementPurchase(proto.Message): + r"""List Offers for CreateEntitlement purchase. + + Attributes: + sku (str): + Required. SKU that the result should be restricted to. + Format: products/{product_id}/skus/{sku_id}. + """ + + sku = proto.Field( + proto.STRING, + number=1, + ) + + class ChangeOfferPurchase(proto.Message): + r"""List Offers for ChangeOffer purchase. + + Attributes: + entitlement (str): + Required. Resource name of the entitlement. Format: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} + new_sku (str): + Optional. Resource name of the new target SKU. Provide this + SKU when upgrading or downgrading an entitlement. Format: + products/{product_id}/skus/{sku_id} + """ + + entitlement = proto.Field( + proto.STRING, + number=1, + ) + new_sku = proto.Field( + proto.STRING, + number=2, + ) + + create_entitlement_purchase = proto.Field( + proto.MESSAGE, + number=2, + oneof='purchase_option', + message=CreateEntitlementPurchase, + ) + change_offer_purchase = proto.Field( + proto.MESSAGE, + number=3, + oneof='purchase_option', + message=ChangeOfferPurchase, + ) + customer = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=4, + ) + page_token = proto.Field( + proto.STRING, + number=5, + ) + language_code = proto.Field( + proto.STRING, + number=6, + ) + + +class ListPurchasableOffersResponse(proto.Message): + r"""Response message for ListPurchasableOffers. + + Attributes: + purchasable_offers (Sequence[google.cloud.channel_v1.types.PurchasableOffer]): + The list of Offers requested. + next_page_token (str): + A token to retrieve the next page of results. + """ + + @property + def raw_page(self): + return self + + purchasable_offers = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='PurchasableOffer', + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class PurchasableOffer(proto.Message): + r"""Offer that you can purchase for a customer. This is used in + the ListPurchasableOffer API response. + + Attributes: + offer (google.cloud.channel_v1.types.Offer): + Offer. + """ + + offer = proto.Field( + proto.MESSAGE, + number=1, + message=gcc_offers.Offer, + ) + + +class RegisterSubscriberRequest(proto.Message): + r"""Request Message for RegisterSubscriber. + + Attributes: + account (str): + Required. Resource name of the account. + service_account (str): + Required. Service account that provides + subscriber access to the registered topic. + """ + + account = proto.Field( + proto.STRING, + number=1, + ) + service_account = proto.Field( + proto.STRING, + number=2, + ) + + +class RegisterSubscriberResponse(proto.Message): + r"""Response Message for RegisterSubscriber. + + Attributes: + topic (str): + Name of the topic the subscriber will listen + to. + """ + + topic = proto.Field( + proto.STRING, + number=1, + ) + + +class UnregisterSubscriberRequest(proto.Message): + r"""Request Message for UnregisterSubscriber. + + Attributes: + account (str): + Required. Resource name of the account. + service_account (str): + Required. Service account to unregister from + subscriber access to the topic. + """ + + account = proto.Field( + proto.STRING, + number=1, + ) + service_account = proto.Field( + proto.STRING, + number=2, + ) + + +class UnregisterSubscriberResponse(proto.Message): + r"""Response Message for UnregisterSubscriber. + + Attributes: + topic (str): + Name of the topic the service account + subscriber access was removed from. + """ + + topic = proto.Field( + proto.STRING, + number=1, + ) + + +class ListSubscribersRequest(proto.Message): + r"""Request Message for ListSubscribers. + + Attributes: + account (str): + Required. Resource name of the account. + page_size (int): + Optional. The maximum number of service + accounts to return. The service may return fewer + than this value. If unspecified, returns at most + 100 service accounts. The maximum value is 1000; + the server will coerce values above 1000. + page_token (str): + Optional. A page token, received from a previous + ``ListSubscribers`` call. Provide this to retrieve the + subsequent page. + + When paginating, all other parameters provided to + ``ListSubscribers`` must match the call that provided the + page token. + """ + + account = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + + +class ListSubscribersResponse(proto.Message): + r"""Response Message for ListSubscribers. + + Attributes: + topic (str): + Name of the topic registered with the + reseller. + service_accounts (Sequence[str]): + List of service accounts which have + subscriber access to the topic. + next_page_token (str): + A token that can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + topic = proto.Field( + proto.STRING, + number=1, + ) + service_accounts = proto.RepeatedField( + proto.STRING, + number=2, + ) + next_page_token = proto.Field( + proto.STRING, + number=3, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/subscriber_event.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/subscriber_event.py new file mode 100644 index 0000000..fc32682 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/channel_v1/types/subscriber_event.py @@ -0,0 +1,123 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import proto # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.channel.v1', + manifest={ + 'CustomerEvent', + 'EntitlementEvent', + 'SubscriberEvent', + }, +) + + +class CustomerEvent(proto.Message): + r"""Represents Pub/Sub message content describing customer + update. + + Attributes: + customer (str): + Resource name of the customer. Format: + accounts/{account_id}/customers/{customer_id} + event_type (google.cloud.channel_v1.types.CustomerEvent.Type): + Type of event which happened on the customer. + """ + class Type(proto.Enum): + r"""Type of customer event.""" + TYPE_UNSPECIFIED = 0 + PRIMARY_DOMAIN_CHANGED = 1 + PRIMARY_DOMAIN_VERIFIED = 2 + + customer = proto.Field( + proto.STRING, + number=1, + ) + event_type = proto.Field( + proto.ENUM, + number=2, + enum=Type, + ) + + +class EntitlementEvent(proto.Message): + r"""Represents Pub/Sub message content describing entitlement + update. + + Attributes: + entitlement (str): + Resource name of an entitlement of the form: + accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} + event_type (google.cloud.channel_v1.types.EntitlementEvent.Type): + Type of event which happened on the + entitlement. + """ + class Type(proto.Enum): + r"""Type of entitlement event.""" + TYPE_UNSPECIFIED = 0 + CREATED = 1 + PRICE_PLAN_SWITCHED = 3 + COMMITMENT_CHANGED = 4 + RENEWED = 5 + SUSPENDED = 6 + ACTIVATED = 7 + CANCELLED = 8 + SKU_CHANGED = 9 + RENEWAL_SETTING_CHANGED = 10 + PAID_SERVICE_STARTED = 11 + LICENSE_ASSIGNMENT_CHANGED = 12 + LICENSE_CAP_CHANGED = 13 + + entitlement = proto.Field( + proto.STRING, + number=1, + ) + event_type = proto.Field( + proto.ENUM, + number=2, + enum=Type, + ) + + +class SubscriberEvent(proto.Message): + r"""Represents information which resellers will get as part of + notification from Cloud Pub/Sub. + + Attributes: + customer_event (google.cloud.channel_v1.types.CustomerEvent): + Customer event send as part of Pub/Sub event + to partners. + entitlement_event (google.cloud.channel_v1.types.EntitlementEvent): + Entitlement event send as part of Pub/Sub + event to partners. + """ + + customer_event = proto.Field( + proto.MESSAGE, + number=1, + oneof='event', + message='CustomerEvent', + ) + entitlement_event = proto.Field( + proto.MESSAGE, + number=2, + oneof='event', + message='EntitlementEvent', + ) + + +__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..d514d9a --- /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/channel_v1/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python='3.7') +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python=['3.6', '3.7']) +def mypy(session): + """Run the type checker.""" + session.install('mypy', 'types-pkg_resources') + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python='3.6') +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx<3.0.0", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/owl-bot-staging/v1/scripts/fixup_channel_v1_keywords.py b/owl-bot-staging/v1/scripts/fixup_channel_v1_keywords.py new file mode 100644 index 0000000..210090c --- /dev/null +++ b/owl-bot-staging/v1/scripts/fixup_channel_v1_keywords.py @@ -0,0 +1,210 @@ +#! /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 channelCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'activate_entitlement': ('name', 'request_id', ), + 'cancel_entitlement': ('name', 'request_id', ), + 'change_offer': ('name', 'offer', 'parameters', 'purchase_order_id', 'request_id', ), + 'change_parameters': ('name', 'parameters', 'request_id', 'purchase_order_id', ), + 'change_renewal_settings': ('name', 'renewal_settings', 'request_id', ), + 'check_cloud_identity_accounts_exist': ('parent', 'domain', ), + 'create_channel_partner_link': ('parent', 'channel_partner_link', ), + 'create_customer': ('parent', 'customer', ), + 'create_entitlement': ('parent', 'entitlement', 'request_id', ), + 'delete_customer': ('name', ), + 'get_channel_partner_link': ('name', 'view', ), + 'get_customer': ('name', ), + 'get_entitlement': ('name', ), + 'import_customer': ('domain', 'cloud_identity_id', 'parent', 'overwrite_if_exists', 'auth_token', 'channel_partner_id', 'customer', ), + 'list_channel_partner_links': ('parent', 'page_size', 'page_token', 'view', ), + 'list_customers': ('parent', 'page_size', 'page_token', ), + 'list_entitlements': ('parent', 'page_size', 'page_token', ), + 'list_offers': ('parent', 'page_size', 'page_token', 'filter', 'language_code', ), + 'list_products': ('account', 'page_size', 'page_token', 'language_code', ), + 'list_purchasable_offers': ('customer', 'create_entitlement_purchase', 'change_offer_purchase', 'page_size', 'page_token', 'language_code', ), + 'list_purchasable_skus': ('customer', 'create_entitlement_purchase', 'change_offer_purchase', 'page_size', 'page_token', 'language_code', ), + 'list_skus': ('parent', 'account', 'page_size', 'page_token', 'language_code', ), + 'list_subscribers': ('account', 'page_size', 'page_token', ), + 'list_transferable_offers': ('parent', 'sku', 'cloud_identity_id', 'customer_name', 'page_size', 'page_token', 'language_code', ), + 'list_transferable_skus': ('parent', 'cloud_identity_id', 'customer_name', 'page_size', 'page_token', 'auth_token', 'language_code', ), + 'lookup_offer': ('entitlement', ), + 'provision_cloud_identity': ('customer', 'cloud_identity_info', 'user', 'validate_only', ), + 'register_subscriber': ('account', 'service_account', ), + 'start_paid_service': ('name', 'request_id', ), + 'suspend_entitlement': ('name', 'request_id', ), + 'transfer_entitlements': ('parent', 'entitlements', 'auth_token', 'request_id', ), + 'transfer_entitlements_to_google': ('parent', 'entitlements', 'request_id', ), + 'unregister_subscriber': ('account', 'service_account', ), + 'update_channel_partner_link': ('name', 'channel_partner_link', 'update_mask', ), + 'update_customer': ('customer', 'update_mask', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: a.keyword.value not in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=channelCallTransformer(), +): + """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 channel 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..3e6154d --- /dev/null +++ b/owl-bot-staging/v1/setup.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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-channel', + version=version, + long_description=readme, + packages=setuptools.PEP420PackageFinder.find(), + namespace_packages=('google', 'google.cloud'), + platforms='Posix; MacOS X; Windows', + include_package_data=True, + install_requires=( + 'google-api-core[grpc] >= 1.27.0, < 3.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', + 'Programming Language :: Python :: 3.9', + '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/channel_v1/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/channel_v1/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/channel_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/channel_v1/test_cloud_channel_service.py b/owl-bot-staging/v1/tests/unit/gapic/channel_v1/test_cloud_channel_service.py new file mode 100644 index 0000000..cf2c9d0 --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/channel_v1/test_cloud_channel_service.py @@ -0,0 +1,8683 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.channel_v1.services.cloud_channel_service import CloudChannelServiceAsyncClient +from google.cloud.channel_v1.services.cloud_channel_service import CloudChannelServiceClient +from google.cloud.channel_v1.services.cloud_channel_service import pagers +from google.cloud.channel_v1.services.cloud_channel_service import transports +from google.cloud.channel_v1.services.cloud_channel_service.transports.base import _GOOGLE_AUTH_VERSION +from google.cloud.channel_v1.types import channel_partner_links +from google.cloud.channel_v1.types import common +from google.cloud.channel_v1.types import customers +from google.cloud.channel_v1.types import entitlements +from google.cloud.channel_v1.types import offers +from google.cloud.channel_v1.types import operations +from google.cloud.channel_v1.types import products +from google.cloud.channel_v1.types import service +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import any_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import postal_address_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively +# through google-api-core: +# - Delete the auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert CloudChannelServiceClient._get_default_mtls_endpoint(None) is None + assert CloudChannelServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert CloudChannelServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert CloudChannelServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert CloudChannelServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert CloudChannelServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class", [ + CloudChannelServiceClient, + CloudChannelServiceAsyncClient, +]) +def test_cloud_channel_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 == 'cloudchannel.googleapis.com:443' + + +@pytest.mark.parametrize("transport_class,transport_name", [ + (transports.CloudChannelServiceGrpcTransport, "grpc"), + (transports.CloudChannelServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_cloud_channel_service_client_service_account_always_use_jwt(transport_class, transport_name): + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) + + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize("client_class", [ + CloudChannelServiceClient, + CloudChannelServiceAsyncClient, +]) +def test_cloud_channel_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 == 'cloudchannel.googleapis.com:443' + + +def test_cloud_channel_service_client_get_transport_class(): + transport = CloudChannelServiceClient.get_transport_class() + available_transports = [ + transports.CloudChannelServiceGrpcTransport, + ] + assert transport in available_transports + + transport = CloudChannelServiceClient.get_transport_class("grpc") + assert transport == transports.CloudChannelServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CloudChannelServiceClient, transports.CloudChannelServiceGrpcTransport, "grpc"), + (CloudChannelServiceAsyncClient, transports.CloudChannelServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(CloudChannelServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CloudChannelServiceClient)) +@mock.patch.object(CloudChannelServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CloudChannelServiceAsyncClient)) +def test_cloud_channel_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(CloudChannelServiceClient, '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(CloudChannelServiceClient, '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, + always_use_jwt_access=True, + ) + + # 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, + always_use_jwt_access=True, + ) + + # 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, + always_use_jwt_access=True, + ) + + # 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, + always_use_jwt_access=True, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (CloudChannelServiceClient, transports.CloudChannelServiceGrpcTransport, "grpc", "true"), + (CloudChannelServiceAsyncClient, transports.CloudChannelServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (CloudChannelServiceClient, transports.CloudChannelServiceGrpcTransport, "grpc", "false"), + (CloudChannelServiceAsyncClient, transports.CloudChannelServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(CloudChannelServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CloudChannelServiceClient)) +@mock.patch.object(CloudChannelServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CloudChannelServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_cloud_channel_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, + always_use_jwt_access=True, + ) + + # 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, + always_use_jwt_access=True, + ) + + # 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, + always_use_jwt_access=True, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CloudChannelServiceClient, transports.CloudChannelServiceGrpcTransport, "grpc"), + (CloudChannelServiceAsyncClient, transports.CloudChannelServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_cloud_channel_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, + always_use_jwt_access=True, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (CloudChannelServiceClient, transports.CloudChannelServiceGrpcTransport, "grpc"), + (CloudChannelServiceAsyncClient, transports.CloudChannelServiceGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_cloud_channel_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, + always_use_jwt_access=True, + ) + + +def test_cloud_channel_service_client_client_options_from_dict(): + with mock.patch('google.cloud.channel_v1.services.cloud_channel_service.transports.CloudChannelServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = CloudChannelServiceClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + +def test_list_customers(transport: str = 'grpc', request_type=service.ListCustomersRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_customers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListCustomersResponse( + next_page_token='next_page_token_value', + ) + response = client.list_customers(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.ListCustomersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCustomersPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_customers_from_dict(): + test_list_customers(request_type=dict) + + +def test_list_customers_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_customers), + '__call__') as call: + client.list_customers() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCustomersRequest() + + +@pytest.mark.asyncio +async def test_list_customers_async(transport: str = 'grpc_asyncio', request_type=service.ListCustomersRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_customers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCustomersResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_customers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListCustomersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCustomersAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_customers_async_from_dict(): + await test_list_customers_async(request_type=dict) + + +def test_list_customers_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCustomersRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_customers), + '__call__') as call: + call.return_value = service.ListCustomersResponse() + client.list_customers(request) + + # Establish that the 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_customers_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListCustomersRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_customers), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCustomersResponse()) + await client.list_customers(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_customers_pager(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_customers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCustomersResponse( + customers=[ + customers.Customer(), + customers.Customer(), + customers.Customer(), + ], + next_page_token='abc', + ), + service.ListCustomersResponse( + customers=[], + next_page_token='def', + ), + service.ListCustomersResponse( + customers=[ + customers.Customer(), + ], + next_page_token='ghi', + ), + service.ListCustomersResponse( + customers=[ + customers.Customer(), + customers.Customer(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_customers(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, customers.Customer) + for i in results) + +def test_list_customers_pages(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_customers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCustomersResponse( + customers=[ + customers.Customer(), + customers.Customer(), + customers.Customer(), + ], + next_page_token='abc', + ), + service.ListCustomersResponse( + customers=[], + next_page_token='def', + ), + service.ListCustomersResponse( + customers=[ + customers.Customer(), + ], + next_page_token='ghi', + ), + service.ListCustomersResponse( + customers=[ + customers.Customer(), + customers.Customer(), + ], + ), + RuntimeError, + ) + pages = list(client.list_customers(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_customers_async_pager(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_customers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCustomersResponse( + customers=[ + customers.Customer(), + customers.Customer(), + customers.Customer(), + ], + next_page_token='abc', + ), + service.ListCustomersResponse( + customers=[], + next_page_token='def', + ), + service.ListCustomersResponse( + customers=[ + customers.Customer(), + ], + next_page_token='ghi', + ), + service.ListCustomersResponse( + customers=[ + customers.Customer(), + customers.Customer(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_customers(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, customers.Customer) + for i in responses) + +@pytest.mark.asyncio +async def test_list_customers_async_pages(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_customers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListCustomersResponse( + customers=[ + customers.Customer(), + customers.Customer(), + customers.Customer(), + ], + next_page_token='abc', + ), + service.ListCustomersResponse( + customers=[], + next_page_token='def', + ), + service.ListCustomersResponse( + customers=[ + customers.Customer(), + ], + next_page_token='ghi', + ), + service.ListCustomersResponse( + customers=[ + customers.Customer(), + customers.Customer(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_customers(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_get_customer(transport: str = 'grpc', request_type=service.GetCustomerRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = customers.Customer( + name='name_value', + org_display_name='org_display_name_value', + alternate_email='alternate_email_value', + domain='domain_value', + cloud_identity_id='cloud_identity_id_value', + language_code='language_code_value', + channel_partner_id='channel_partner_id_value', + ) + response = client.get_customer(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.GetCustomerRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, customers.Customer) + assert response.name == 'name_value' + assert response.org_display_name == 'org_display_name_value' + assert response.alternate_email == 'alternate_email_value' + assert response.domain == 'domain_value' + assert response.cloud_identity_id == 'cloud_identity_id_value' + assert response.language_code == 'language_code_value' + assert response.channel_partner_id == 'channel_partner_id_value' + + +def test_get_customer_from_dict(): + test_get_customer(request_type=dict) + + +def test_get_customer_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_customer), + '__call__') as call: + client.get_customer() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCustomerRequest() + + +@pytest.mark.asyncio +async def test_get_customer_async(transport: str = 'grpc_asyncio', request_type=service.GetCustomerRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer( + name='name_value', + org_display_name='org_display_name_value', + alternate_email='alternate_email_value', + domain='domain_value', + cloud_identity_id='cloud_identity_id_value', + language_code='language_code_value', + channel_partner_id='channel_partner_id_value', + )) + response = await client.get_customer(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetCustomerRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, customers.Customer) + assert response.name == 'name_value' + assert response.org_display_name == 'org_display_name_value' + assert response.alternate_email == 'alternate_email_value' + assert response.domain == 'domain_value' + assert response.cloud_identity_id == 'cloud_identity_id_value' + assert response.language_code == 'language_code_value' + assert response.channel_partner_id == 'channel_partner_id_value' + + +@pytest.mark.asyncio +async def test_get_customer_async_from_dict(): + await test_get_customer_async(request_type=dict) + + +def test_get_customer_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCustomerRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_customer), + '__call__') as call: + call.return_value = customers.Customer() + client.get_customer(request) + + # Establish that the 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_customer_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetCustomerRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_customer), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer()) + await client.get_customer(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_customer_flattened(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = customers.Customer() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_customer( + 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_customer_flattened_error(): + client = CloudChannelServiceClient( + 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_customer( + service.GetCustomerRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_customer_flattened_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = customers.Customer() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_customer( + 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_customer_flattened_error_async(): + client = CloudChannelServiceAsyncClient( + 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_customer( + service.GetCustomerRequest(), + name='name_value', + ) + + +def test_check_cloud_identity_accounts_exist(transport: str = 'grpc', request_type=service.CheckCloudIdentityAccountsExistRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_cloud_identity_accounts_exist), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.CheckCloudIdentityAccountsExistResponse( + ) + response = client.check_cloud_identity_accounts_exist(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.CheckCloudIdentityAccountsExistRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.CheckCloudIdentityAccountsExistResponse) + + +def test_check_cloud_identity_accounts_exist_from_dict(): + test_check_cloud_identity_accounts_exist(request_type=dict) + + +def test_check_cloud_identity_accounts_exist_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.check_cloud_identity_accounts_exist), + '__call__') as call: + client.check_cloud_identity_accounts_exist() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CheckCloudIdentityAccountsExistRequest() + + +@pytest.mark.asyncio +async def test_check_cloud_identity_accounts_exist_async(transport: str = 'grpc_asyncio', request_type=service.CheckCloudIdentityAccountsExistRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_cloud_identity_accounts_exist), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.CheckCloudIdentityAccountsExistResponse( + )) + response = await client.check_cloud_identity_accounts_exist(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CheckCloudIdentityAccountsExistRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.CheckCloudIdentityAccountsExistResponse) + + +@pytest.mark.asyncio +async def test_check_cloud_identity_accounts_exist_async_from_dict(): + await test_check_cloud_identity_accounts_exist_async(request_type=dict) + + +def test_check_cloud_identity_accounts_exist_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CheckCloudIdentityAccountsExistRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_cloud_identity_accounts_exist), + '__call__') as call: + call.return_value = service.CheckCloudIdentityAccountsExistResponse() + client.check_cloud_identity_accounts_exist(request) + + # Establish that the 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_check_cloud_identity_accounts_exist_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CheckCloudIdentityAccountsExistRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_cloud_identity_accounts_exist), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.CheckCloudIdentityAccountsExistResponse()) + await client.check_cloud_identity_accounts_exist(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_customer(transport: str = 'grpc', request_type=service.CreateCustomerRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = customers.Customer( + name='name_value', + org_display_name='org_display_name_value', + alternate_email='alternate_email_value', + domain='domain_value', + cloud_identity_id='cloud_identity_id_value', + language_code='language_code_value', + channel_partner_id='channel_partner_id_value', + ) + response = client.create_customer(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.CreateCustomerRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, customers.Customer) + assert response.name == 'name_value' + assert response.org_display_name == 'org_display_name_value' + assert response.alternate_email == 'alternate_email_value' + assert response.domain == 'domain_value' + assert response.cloud_identity_id == 'cloud_identity_id_value' + assert response.language_code == 'language_code_value' + assert response.channel_partner_id == 'channel_partner_id_value' + + +def test_create_customer_from_dict(): + test_create_customer(request_type=dict) + + +def test_create_customer_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_customer), + '__call__') as call: + client.create_customer() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCustomerRequest() + + +@pytest.mark.asyncio +async def test_create_customer_async(transport: str = 'grpc_asyncio', request_type=service.CreateCustomerRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer( + name='name_value', + org_display_name='org_display_name_value', + alternate_email='alternate_email_value', + domain='domain_value', + cloud_identity_id='cloud_identity_id_value', + language_code='language_code_value', + channel_partner_id='channel_partner_id_value', + )) + response = await client.create_customer(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateCustomerRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, customers.Customer) + assert response.name == 'name_value' + assert response.org_display_name == 'org_display_name_value' + assert response.alternate_email == 'alternate_email_value' + assert response.domain == 'domain_value' + assert response.cloud_identity_id == 'cloud_identity_id_value' + assert response.language_code == 'language_code_value' + assert response.channel_partner_id == 'channel_partner_id_value' + + +@pytest.mark.asyncio +async def test_create_customer_async_from_dict(): + await test_create_customer_async(request_type=dict) + + +def test_create_customer_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateCustomerRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_customer), + '__call__') as call: + call.return_value = customers.Customer() + client.create_customer(request) + + # Establish that the 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_customer_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateCustomerRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_customer), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer()) + await client.create_customer(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_update_customer(transport: str = 'grpc', request_type=service.UpdateCustomerRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = customers.Customer( + name='name_value', + org_display_name='org_display_name_value', + alternate_email='alternate_email_value', + domain='domain_value', + cloud_identity_id='cloud_identity_id_value', + language_code='language_code_value', + channel_partner_id='channel_partner_id_value', + ) + response = client.update_customer(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.UpdateCustomerRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, customers.Customer) + assert response.name == 'name_value' + assert response.org_display_name == 'org_display_name_value' + assert response.alternate_email == 'alternate_email_value' + assert response.domain == 'domain_value' + assert response.cloud_identity_id == 'cloud_identity_id_value' + assert response.language_code == 'language_code_value' + assert response.channel_partner_id == 'channel_partner_id_value' + + +def test_update_customer_from_dict(): + test_update_customer(request_type=dict) + + +def test_update_customer_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_customer), + '__call__') as call: + client.update_customer() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCustomerRequest() + + +@pytest.mark.asyncio +async def test_update_customer_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCustomerRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer( + name='name_value', + org_display_name='org_display_name_value', + alternate_email='alternate_email_value', + domain='domain_value', + cloud_identity_id='cloud_identity_id_value', + language_code='language_code_value', + channel_partner_id='channel_partner_id_value', + )) + response = await client.update_customer(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateCustomerRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, customers.Customer) + assert response.name == 'name_value' + assert response.org_display_name == 'org_display_name_value' + assert response.alternate_email == 'alternate_email_value' + assert response.domain == 'domain_value' + assert response.cloud_identity_id == 'cloud_identity_id_value' + assert response.language_code == 'language_code_value' + assert response.channel_partner_id == 'channel_partner_id_value' + + +@pytest.mark.asyncio +async def test_update_customer_async_from_dict(): + await test_update_customer_async(request_type=dict) + + +def test_update_customer_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCustomerRequest() + + request.customer.name = 'customer.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_customer), + '__call__') as call: + call.return_value = customers.Customer() + client.update_customer(request) + + # Establish that the 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', + 'customer.name=customer.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_customer_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateCustomerRequest() + + request.customer.name = 'customer.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_customer), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer()) + await client.update_customer(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', + 'customer.name=customer.name/value', + ) in kw['metadata'] + + +def test_delete_customer(transport: str = 'grpc', request_type=service.DeleteCustomerRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_customer(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.DeleteCustomerRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_customer_from_dict(): + test_delete_customer(request_type=dict) + + +def test_delete_customer_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_customer), + '__call__') as call: + client.delete_customer() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteCustomerRequest() + + +@pytest.mark.asyncio +async def test_delete_customer_async(transport: str = 'grpc_asyncio', request_type=service.DeleteCustomerRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_customer(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.DeleteCustomerRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_customer_async_from_dict(): + await test_delete_customer_async(request_type=dict) + + +def test_delete_customer_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DeleteCustomerRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_customer), + '__call__') as call: + call.return_value = None + client.delete_customer(request) + + # Establish that the 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_customer_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.DeleteCustomerRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_customer), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_customer(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_customer_flattened(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_customer( + 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_customer_flattened_error(): + client = CloudChannelServiceClient( + 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_customer( + service.DeleteCustomerRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_customer_flattened_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_customer( + 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_customer_flattened_error_async(): + client = CloudChannelServiceAsyncClient( + 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_customer( + service.DeleteCustomerRequest(), + name='name_value', + ) + + +def test_import_customer(transport: str = 'grpc', request_type=service.ImportCustomerRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.import_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = customers.Customer( + name='name_value', + org_display_name='org_display_name_value', + alternate_email='alternate_email_value', + domain='domain_value', + cloud_identity_id='cloud_identity_id_value', + language_code='language_code_value', + channel_partner_id='channel_partner_id_value', + ) + response = client.import_customer(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.ImportCustomerRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, customers.Customer) + assert response.name == 'name_value' + assert response.org_display_name == 'org_display_name_value' + assert response.alternate_email == 'alternate_email_value' + assert response.domain == 'domain_value' + assert response.cloud_identity_id == 'cloud_identity_id_value' + assert response.language_code == 'language_code_value' + assert response.channel_partner_id == 'channel_partner_id_value' + + +def test_import_customer_from_dict(): + test_import_customer(request_type=dict) + + +def test_import_customer_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.import_customer), + '__call__') as call: + client.import_customer() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ImportCustomerRequest() + + +@pytest.mark.asyncio +async def test_import_customer_async(transport: str = 'grpc_asyncio', request_type=service.ImportCustomerRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.import_customer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer( + name='name_value', + org_display_name='org_display_name_value', + alternate_email='alternate_email_value', + domain='domain_value', + cloud_identity_id='cloud_identity_id_value', + language_code='language_code_value', + channel_partner_id='channel_partner_id_value', + )) + response = await client.import_customer(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ImportCustomerRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, customers.Customer) + assert response.name == 'name_value' + assert response.org_display_name == 'org_display_name_value' + assert response.alternate_email == 'alternate_email_value' + assert response.domain == 'domain_value' + assert response.cloud_identity_id == 'cloud_identity_id_value' + assert response.language_code == 'language_code_value' + assert response.channel_partner_id == 'channel_partner_id_value' + + +@pytest.mark.asyncio +async def test_import_customer_async_from_dict(): + await test_import_customer_async(request_type=dict) + + +def test_import_customer_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ImportCustomerRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.import_customer), + '__call__') as call: + call.return_value = customers.Customer() + client.import_customer(request) + + # Establish that the 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_import_customer_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ImportCustomerRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.import_customer), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer()) + await client.import_customer(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_provision_cloud_identity(transport: str = 'grpc', request_type=service.ProvisionCloudIdentityRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_cloud_identity), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.provision_cloud_identity(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.ProvisionCloudIdentityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_provision_cloud_identity_from_dict(): + test_provision_cloud_identity(request_type=dict) + + +def test_provision_cloud_identity_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.provision_cloud_identity), + '__call__') as call: + client.provision_cloud_identity() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ProvisionCloudIdentityRequest() + + +@pytest.mark.asyncio +async def test_provision_cloud_identity_async(transport: str = 'grpc_asyncio', request_type=service.ProvisionCloudIdentityRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_cloud_identity), + '__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.provision_cloud_identity(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ProvisionCloudIdentityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_provision_cloud_identity_async_from_dict(): + await test_provision_cloud_identity_async(request_type=dict) + + +def test_provision_cloud_identity_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ProvisionCloudIdentityRequest() + + request.customer = 'customer/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_cloud_identity), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.provision_cloud_identity(request) + + # Establish that the 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', + 'customer=customer/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_provision_cloud_identity_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ProvisionCloudIdentityRequest() + + request.customer = 'customer/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_cloud_identity), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.provision_cloud_identity(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', + 'customer=customer/value', + ) in kw['metadata'] + + +def test_list_entitlements(transport: str = 'grpc', request_type=service.ListEntitlementsRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_entitlements), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListEntitlementsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_entitlements(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.ListEntitlementsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEntitlementsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_entitlements_from_dict(): + test_list_entitlements(request_type=dict) + + +def test_list_entitlements_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_entitlements), + '__call__') as call: + client.list_entitlements() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListEntitlementsRequest() + + +@pytest.mark.asyncio +async def test_list_entitlements_async(transport: str = 'grpc_asyncio', request_type=service.ListEntitlementsRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_entitlements), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListEntitlementsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_entitlements(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListEntitlementsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEntitlementsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_entitlements_async_from_dict(): + await test_list_entitlements_async(request_type=dict) + + +def test_list_entitlements_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListEntitlementsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_entitlements), + '__call__') as call: + call.return_value = service.ListEntitlementsResponse() + client.list_entitlements(request) + + # Establish that the 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_entitlements_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListEntitlementsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_entitlements), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListEntitlementsResponse()) + await client.list_entitlements(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_entitlements_pager(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_entitlements), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListEntitlementsResponse( + entitlements=[ + entitlements.Entitlement(), + entitlements.Entitlement(), + entitlements.Entitlement(), + ], + next_page_token='abc', + ), + service.ListEntitlementsResponse( + entitlements=[], + next_page_token='def', + ), + service.ListEntitlementsResponse( + entitlements=[ + entitlements.Entitlement(), + ], + next_page_token='ghi', + ), + service.ListEntitlementsResponse( + entitlements=[ + entitlements.Entitlement(), + entitlements.Entitlement(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_entitlements(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, entitlements.Entitlement) + for i in results) + +def test_list_entitlements_pages(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_entitlements), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListEntitlementsResponse( + entitlements=[ + entitlements.Entitlement(), + entitlements.Entitlement(), + entitlements.Entitlement(), + ], + next_page_token='abc', + ), + service.ListEntitlementsResponse( + entitlements=[], + next_page_token='def', + ), + service.ListEntitlementsResponse( + entitlements=[ + entitlements.Entitlement(), + ], + next_page_token='ghi', + ), + service.ListEntitlementsResponse( + entitlements=[ + entitlements.Entitlement(), + entitlements.Entitlement(), + ], + ), + RuntimeError, + ) + pages = list(client.list_entitlements(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_entitlements_async_pager(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_entitlements), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListEntitlementsResponse( + entitlements=[ + entitlements.Entitlement(), + entitlements.Entitlement(), + entitlements.Entitlement(), + ], + next_page_token='abc', + ), + service.ListEntitlementsResponse( + entitlements=[], + next_page_token='def', + ), + service.ListEntitlementsResponse( + entitlements=[ + entitlements.Entitlement(), + ], + next_page_token='ghi', + ), + service.ListEntitlementsResponse( + entitlements=[ + entitlements.Entitlement(), + entitlements.Entitlement(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_entitlements(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, entitlements.Entitlement) + for i in responses) + +@pytest.mark.asyncio +async def test_list_entitlements_async_pages(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_entitlements), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListEntitlementsResponse( + entitlements=[ + entitlements.Entitlement(), + entitlements.Entitlement(), + entitlements.Entitlement(), + ], + next_page_token='abc', + ), + service.ListEntitlementsResponse( + entitlements=[], + next_page_token='def', + ), + service.ListEntitlementsResponse( + entitlements=[ + entitlements.Entitlement(), + ], + next_page_token='ghi', + ), + service.ListEntitlementsResponse( + entitlements=[ + entitlements.Entitlement(), + entitlements.Entitlement(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_entitlements(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_list_transferable_skus(transport: str = 'grpc', request_type=service.ListTransferableSkusRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_transferable_skus), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListTransferableSkusResponse( + next_page_token='next_page_token_value', + ) + response = client.list_transferable_skus(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.ListTransferableSkusRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTransferableSkusPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_transferable_skus_from_dict(): + test_list_transferable_skus(request_type=dict) + + +def test_list_transferable_skus_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_transferable_skus), + '__call__') as call: + client.list_transferable_skus() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListTransferableSkusRequest() + + +@pytest.mark.asyncio +async def test_list_transferable_skus_async(transport: str = 'grpc_asyncio', request_type=service.ListTransferableSkusRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_transferable_skus), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListTransferableSkusResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_transferable_skus(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListTransferableSkusRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTransferableSkusAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_transferable_skus_async_from_dict(): + await test_list_transferable_skus_async(request_type=dict) + + +def test_list_transferable_skus_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListTransferableSkusRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_transferable_skus), + '__call__') as call: + call.return_value = service.ListTransferableSkusResponse() + client.list_transferable_skus(request) + + # Establish that the 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_transferable_skus_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListTransferableSkusRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_transferable_skus), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListTransferableSkusResponse()) + await client.list_transferable_skus(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_transferable_skus_pager(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_transferable_skus), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListTransferableSkusResponse( + transferable_skus=[ + entitlements.TransferableSku(), + entitlements.TransferableSku(), + entitlements.TransferableSku(), + ], + next_page_token='abc', + ), + service.ListTransferableSkusResponse( + transferable_skus=[], + next_page_token='def', + ), + service.ListTransferableSkusResponse( + transferable_skus=[ + entitlements.TransferableSku(), + ], + next_page_token='ghi', + ), + service.ListTransferableSkusResponse( + transferable_skus=[ + entitlements.TransferableSku(), + entitlements.TransferableSku(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_transferable_skus(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, entitlements.TransferableSku) + for i in results) + +def test_list_transferable_skus_pages(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_transferable_skus), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListTransferableSkusResponse( + transferable_skus=[ + entitlements.TransferableSku(), + entitlements.TransferableSku(), + entitlements.TransferableSku(), + ], + next_page_token='abc', + ), + service.ListTransferableSkusResponse( + transferable_skus=[], + next_page_token='def', + ), + service.ListTransferableSkusResponse( + transferable_skus=[ + entitlements.TransferableSku(), + ], + next_page_token='ghi', + ), + service.ListTransferableSkusResponse( + transferable_skus=[ + entitlements.TransferableSku(), + entitlements.TransferableSku(), + ], + ), + RuntimeError, + ) + pages = list(client.list_transferable_skus(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_transferable_skus_async_pager(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_transferable_skus), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListTransferableSkusResponse( + transferable_skus=[ + entitlements.TransferableSku(), + entitlements.TransferableSku(), + entitlements.TransferableSku(), + ], + next_page_token='abc', + ), + service.ListTransferableSkusResponse( + transferable_skus=[], + next_page_token='def', + ), + service.ListTransferableSkusResponse( + transferable_skus=[ + entitlements.TransferableSku(), + ], + next_page_token='ghi', + ), + service.ListTransferableSkusResponse( + transferable_skus=[ + entitlements.TransferableSku(), + entitlements.TransferableSku(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_transferable_skus(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, entitlements.TransferableSku) + for i in responses) + +@pytest.mark.asyncio +async def test_list_transferable_skus_async_pages(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_transferable_skus), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListTransferableSkusResponse( + transferable_skus=[ + entitlements.TransferableSku(), + entitlements.TransferableSku(), + entitlements.TransferableSku(), + ], + next_page_token='abc', + ), + service.ListTransferableSkusResponse( + transferable_skus=[], + next_page_token='def', + ), + service.ListTransferableSkusResponse( + transferable_skus=[ + entitlements.TransferableSku(), + ], + next_page_token='ghi', + ), + service.ListTransferableSkusResponse( + transferable_skus=[ + entitlements.TransferableSku(), + entitlements.TransferableSku(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_transferable_skus(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_list_transferable_offers(transport: str = 'grpc', request_type=service.ListTransferableOffersRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_transferable_offers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListTransferableOffersResponse( + next_page_token='next_page_token_value', + ) + response = client.list_transferable_offers(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.ListTransferableOffersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTransferableOffersPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_transferable_offers_from_dict(): + test_list_transferable_offers(request_type=dict) + + +def test_list_transferable_offers_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_transferable_offers), + '__call__') as call: + client.list_transferable_offers() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListTransferableOffersRequest() + + +@pytest.mark.asyncio +async def test_list_transferable_offers_async(transport: str = 'grpc_asyncio', request_type=service.ListTransferableOffersRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_transferable_offers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListTransferableOffersResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_transferable_offers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListTransferableOffersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTransferableOffersAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_transferable_offers_async_from_dict(): + await test_list_transferable_offers_async(request_type=dict) + + +def test_list_transferable_offers_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListTransferableOffersRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_transferable_offers), + '__call__') as call: + call.return_value = service.ListTransferableOffersResponse() + client.list_transferable_offers(request) + + # Establish that the 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_transferable_offers_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListTransferableOffersRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_transferable_offers), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListTransferableOffersResponse()) + await client.list_transferable_offers(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_transferable_offers_pager(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_transferable_offers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListTransferableOffersResponse( + transferable_offers=[ + service.TransferableOffer(), + service.TransferableOffer(), + service.TransferableOffer(), + ], + next_page_token='abc', + ), + service.ListTransferableOffersResponse( + transferable_offers=[], + next_page_token='def', + ), + service.ListTransferableOffersResponse( + transferable_offers=[ + service.TransferableOffer(), + ], + next_page_token='ghi', + ), + service.ListTransferableOffersResponse( + transferable_offers=[ + service.TransferableOffer(), + service.TransferableOffer(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_transferable_offers(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, service.TransferableOffer) + for i in results) + +def test_list_transferable_offers_pages(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_transferable_offers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListTransferableOffersResponse( + transferable_offers=[ + service.TransferableOffer(), + service.TransferableOffer(), + service.TransferableOffer(), + ], + next_page_token='abc', + ), + service.ListTransferableOffersResponse( + transferable_offers=[], + next_page_token='def', + ), + service.ListTransferableOffersResponse( + transferable_offers=[ + service.TransferableOffer(), + ], + next_page_token='ghi', + ), + service.ListTransferableOffersResponse( + transferable_offers=[ + service.TransferableOffer(), + service.TransferableOffer(), + ], + ), + RuntimeError, + ) + pages = list(client.list_transferable_offers(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_transferable_offers_async_pager(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_transferable_offers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListTransferableOffersResponse( + transferable_offers=[ + service.TransferableOffer(), + service.TransferableOffer(), + service.TransferableOffer(), + ], + next_page_token='abc', + ), + service.ListTransferableOffersResponse( + transferable_offers=[], + next_page_token='def', + ), + service.ListTransferableOffersResponse( + transferable_offers=[ + service.TransferableOffer(), + ], + next_page_token='ghi', + ), + service.ListTransferableOffersResponse( + transferable_offers=[ + service.TransferableOffer(), + service.TransferableOffer(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_transferable_offers(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, service.TransferableOffer) + for i in responses) + +@pytest.mark.asyncio +async def test_list_transferable_offers_async_pages(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_transferable_offers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListTransferableOffersResponse( + transferable_offers=[ + service.TransferableOffer(), + service.TransferableOffer(), + service.TransferableOffer(), + ], + next_page_token='abc', + ), + service.ListTransferableOffersResponse( + transferable_offers=[], + next_page_token='def', + ), + service.ListTransferableOffersResponse( + transferable_offers=[ + service.TransferableOffer(), + ], + next_page_token='ghi', + ), + service.ListTransferableOffersResponse( + transferable_offers=[ + service.TransferableOffer(), + service.TransferableOffer(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_transferable_offers(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_get_entitlement(transport: str = 'grpc', request_type=service.GetEntitlementRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_entitlement), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = entitlements.Entitlement( + name='name_value', + offer='offer_value', + provisioning_state=entitlements.Entitlement.ProvisioningState.ACTIVE, + suspension_reasons=[entitlements.Entitlement.SuspensionReason.RESELLER_INITIATED], + purchase_order_id='purchase_order_id_value', + ) + response = client.get_entitlement(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.GetEntitlementRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, entitlements.Entitlement) + assert response.name == 'name_value' + assert response.offer == 'offer_value' + assert response.provisioning_state == entitlements.Entitlement.ProvisioningState.ACTIVE + assert response.suspension_reasons == [entitlements.Entitlement.SuspensionReason.RESELLER_INITIATED] + assert response.purchase_order_id == 'purchase_order_id_value' + + +def test_get_entitlement_from_dict(): + test_get_entitlement(request_type=dict) + + +def test_get_entitlement_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_entitlement), + '__call__') as call: + client.get_entitlement() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetEntitlementRequest() + + +@pytest.mark.asyncio +async def test_get_entitlement_async(transport: str = 'grpc_asyncio', request_type=service.GetEntitlementRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_entitlement), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(entitlements.Entitlement( + name='name_value', + offer='offer_value', + provisioning_state=entitlements.Entitlement.ProvisioningState.ACTIVE, + suspension_reasons=[entitlements.Entitlement.SuspensionReason.RESELLER_INITIATED], + purchase_order_id='purchase_order_id_value', + )) + response = await client.get_entitlement(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetEntitlementRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, entitlements.Entitlement) + assert response.name == 'name_value' + assert response.offer == 'offer_value' + assert response.provisioning_state == entitlements.Entitlement.ProvisioningState.ACTIVE + assert response.suspension_reasons == [entitlements.Entitlement.SuspensionReason.RESELLER_INITIATED] + assert response.purchase_order_id == 'purchase_order_id_value' + + +@pytest.mark.asyncio +async def test_get_entitlement_async_from_dict(): + await test_get_entitlement_async(request_type=dict) + + +def test_get_entitlement_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetEntitlementRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_entitlement), + '__call__') as call: + call.return_value = entitlements.Entitlement() + client.get_entitlement(request) + + # Establish that the 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_entitlement_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetEntitlementRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_entitlement), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(entitlements.Entitlement()) + await client.get_entitlement(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_create_entitlement(transport: str = 'grpc', request_type=service.CreateEntitlementRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_entitlement), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_entitlement(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.CreateEntitlementRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_entitlement_from_dict(): + test_create_entitlement(request_type=dict) + + +def test_create_entitlement_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_entitlement), + '__call__') as call: + client.create_entitlement() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateEntitlementRequest() + + +@pytest.mark.asyncio +async def test_create_entitlement_async(transport: str = 'grpc_asyncio', request_type=service.CreateEntitlementRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_entitlement), + '__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_entitlement(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateEntitlementRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_entitlement_async_from_dict(): + await test_create_entitlement_async(request_type=dict) + + +def test_create_entitlement_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateEntitlementRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_entitlement), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_entitlement(request) + + # Establish that the 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_entitlement_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateEntitlementRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_entitlement), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_entitlement(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_change_parameters(transport: str = 'grpc', request_type=service.ChangeParametersRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.change_parameters), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.change_parameters(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.ChangeParametersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_change_parameters_from_dict(): + test_change_parameters(request_type=dict) + + +def test_change_parameters_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.change_parameters), + '__call__') as call: + client.change_parameters() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ChangeParametersRequest() + + +@pytest.mark.asyncio +async def test_change_parameters_async(transport: str = 'grpc_asyncio', request_type=service.ChangeParametersRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.change_parameters), + '__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.change_parameters(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ChangeParametersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_change_parameters_async_from_dict(): + await test_change_parameters_async(request_type=dict) + + +def test_change_parameters_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ChangeParametersRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.change_parameters), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.change_parameters(request) + + # Establish that the 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_change_parameters_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ChangeParametersRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.change_parameters), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.change_parameters(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_change_renewal_settings(transport: str = 'grpc', request_type=service.ChangeRenewalSettingsRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.change_renewal_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.change_renewal_settings(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.ChangeRenewalSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_change_renewal_settings_from_dict(): + test_change_renewal_settings(request_type=dict) + + +def test_change_renewal_settings_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.change_renewal_settings), + '__call__') as call: + client.change_renewal_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ChangeRenewalSettingsRequest() + + +@pytest.mark.asyncio +async def test_change_renewal_settings_async(transport: str = 'grpc_asyncio', request_type=service.ChangeRenewalSettingsRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.change_renewal_settings), + '__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.change_renewal_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ChangeRenewalSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_change_renewal_settings_async_from_dict(): + await test_change_renewal_settings_async(request_type=dict) + + +def test_change_renewal_settings_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ChangeRenewalSettingsRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.change_renewal_settings), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.change_renewal_settings(request) + + # Establish that the 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_change_renewal_settings_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ChangeRenewalSettingsRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.change_renewal_settings), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.change_renewal_settings(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_change_offer(transport: str = 'grpc', request_type=service.ChangeOfferRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.change_offer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.change_offer(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.ChangeOfferRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_change_offer_from_dict(): + test_change_offer(request_type=dict) + + +def test_change_offer_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.change_offer), + '__call__') as call: + client.change_offer() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ChangeOfferRequest() + + +@pytest.mark.asyncio +async def test_change_offer_async(transport: str = 'grpc_asyncio', request_type=service.ChangeOfferRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.change_offer), + '__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.change_offer(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ChangeOfferRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_change_offer_async_from_dict(): + await test_change_offer_async(request_type=dict) + + +def test_change_offer_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ChangeOfferRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.change_offer), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.change_offer(request) + + # Establish that the 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_change_offer_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ChangeOfferRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.change_offer), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.change_offer(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_start_paid_service(transport: str = 'grpc', request_type=service.StartPaidServiceRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.start_paid_service), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.start_paid_service(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.StartPaidServiceRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_start_paid_service_from_dict(): + test_start_paid_service(request_type=dict) + + +def test_start_paid_service_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.start_paid_service), + '__call__') as call: + client.start_paid_service() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.StartPaidServiceRequest() + + +@pytest.mark.asyncio +async def test_start_paid_service_async(transport: str = 'grpc_asyncio', request_type=service.StartPaidServiceRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.start_paid_service), + '__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.start_paid_service(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.StartPaidServiceRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_start_paid_service_async_from_dict(): + await test_start_paid_service_async(request_type=dict) + + +def test_start_paid_service_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.StartPaidServiceRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.start_paid_service), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.start_paid_service(request) + + # Establish that the 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_start_paid_service_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.StartPaidServiceRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.start_paid_service), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.start_paid_service(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_suspend_entitlement(transport: str = 'grpc', request_type=service.SuspendEntitlementRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.suspend_entitlement), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.suspend_entitlement(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.SuspendEntitlementRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_suspend_entitlement_from_dict(): + test_suspend_entitlement(request_type=dict) + + +def test_suspend_entitlement_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.suspend_entitlement), + '__call__') as call: + client.suspend_entitlement() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.SuspendEntitlementRequest() + + +@pytest.mark.asyncio +async def test_suspend_entitlement_async(transport: str = 'grpc_asyncio', request_type=service.SuspendEntitlementRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.suspend_entitlement), + '__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.suspend_entitlement(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.SuspendEntitlementRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_suspend_entitlement_async_from_dict(): + await test_suspend_entitlement_async(request_type=dict) + + +def test_suspend_entitlement_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.SuspendEntitlementRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.suspend_entitlement), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.suspend_entitlement(request) + + # Establish that the 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_suspend_entitlement_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.SuspendEntitlementRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.suspend_entitlement), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.suspend_entitlement(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_cancel_entitlement(transport: str = 'grpc', request_type=service.CancelEntitlementRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.cancel_entitlement), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.cancel_entitlement(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.CancelEntitlementRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_cancel_entitlement_from_dict(): + test_cancel_entitlement(request_type=dict) + + +def test_cancel_entitlement_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.cancel_entitlement), + '__call__') as call: + client.cancel_entitlement() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CancelEntitlementRequest() + + +@pytest.mark.asyncio +async def test_cancel_entitlement_async(transport: str = 'grpc_asyncio', request_type=service.CancelEntitlementRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.cancel_entitlement), + '__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.cancel_entitlement(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CancelEntitlementRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_cancel_entitlement_async_from_dict(): + await test_cancel_entitlement_async(request_type=dict) + + +def test_cancel_entitlement_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CancelEntitlementRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.cancel_entitlement), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.cancel_entitlement(request) + + # Establish that the 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_cancel_entitlement_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CancelEntitlementRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.cancel_entitlement), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.cancel_entitlement(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_entitlement(transport: str = 'grpc', request_type=service.ActivateEntitlementRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_entitlement), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.activate_entitlement(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.ActivateEntitlementRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_activate_entitlement_from_dict(): + test_activate_entitlement(request_type=dict) + + +def test_activate_entitlement_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_entitlement), + '__call__') as call: + client.activate_entitlement() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ActivateEntitlementRequest() + + +@pytest.mark.asyncio +async def test_activate_entitlement_async(transport: str = 'grpc_asyncio', request_type=service.ActivateEntitlementRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_entitlement), + '__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_entitlement(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ActivateEntitlementRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_activate_entitlement_async_from_dict(): + await test_activate_entitlement_async(request_type=dict) + + +def test_activate_entitlement_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ActivateEntitlementRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_entitlement), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.activate_entitlement(request) + + # Establish that the 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_entitlement_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ActivateEntitlementRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.activate_entitlement), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.activate_entitlement(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_transfer_entitlements(transport: str = 'grpc', request_type=service.TransferEntitlementsRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.transfer_entitlements), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.transfer_entitlements(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.TransferEntitlementsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_transfer_entitlements_from_dict(): + test_transfer_entitlements(request_type=dict) + + +def test_transfer_entitlements_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.transfer_entitlements), + '__call__') as call: + client.transfer_entitlements() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.TransferEntitlementsRequest() + + +@pytest.mark.asyncio +async def test_transfer_entitlements_async(transport: str = 'grpc_asyncio', request_type=service.TransferEntitlementsRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.transfer_entitlements), + '__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.transfer_entitlements(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.TransferEntitlementsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_transfer_entitlements_async_from_dict(): + await test_transfer_entitlements_async(request_type=dict) + + +def test_transfer_entitlements_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.TransferEntitlementsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.transfer_entitlements), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.transfer_entitlements(request) + + # Establish that the 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_transfer_entitlements_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.TransferEntitlementsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.transfer_entitlements), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.transfer_entitlements(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_transfer_entitlements_to_google(transport: str = 'grpc', request_type=service.TransferEntitlementsToGoogleRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.transfer_entitlements_to_google), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.transfer_entitlements_to_google(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.TransferEntitlementsToGoogleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_transfer_entitlements_to_google_from_dict(): + test_transfer_entitlements_to_google(request_type=dict) + + +def test_transfer_entitlements_to_google_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.transfer_entitlements_to_google), + '__call__') as call: + client.transfer_entitlements_to_google() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.TransferEntitlementsToGoogleRequest() + + +@pytest.mark.asyncio +async def test_transfer_entitlements_to_google_async(transport: str = 'grpc_asyncio', request_type=service.TransferEntitlementsToGoogleRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.transfer_entitlements_to_google), + '__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.transfer_entitlements_to_google(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.TransferEntitlementsToGoogleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_transfer_entitlements_to_google_async_from_dict(): + await test_transfer_entitlements_to_google_async(request_type=dict) + + +def test_transfer_entitlements_to_google_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.TransferEntitlementsToGoogleRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.transfer_entitlements_to_google), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.transfer_entitlements_to_google(request) + + # Establish that the 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_transfer_entitlements_to_google_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.TransferEntitlementsToGoogleRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.transfer_entitlements_to_google), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.transfer_entitlements_to_google(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_channel_partner_links(transport: str = 'grpc', request_type=service.ListChannelPartnerLinksRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_channel_partner_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListChannelPartnerLinksResponse( + next_page_token='next_page_token_value', + ) + response = client.list_channel_partner_links(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.ListChannelPartnerLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListChannelPartnerLinksPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_channel_partner_links_from_dict(): + test_list_channel_partner_links(request_type=dict) + + +def test_list_channel_partner_links_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_channel_partner_links), + '__call__') as call: + client.list_channel_partner_links() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListChannelPartnerLinksRequest() + + +@pytest.mark.asyncio +async def test_list_channel_partner_links_async(transport: str = 'grpc_asyncio', request_type=service.ListChannelPartnerLinksRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_channel_partner_links), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListChannelPartnerLinksResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_channel_partner_links(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListChannelPartnerLinksRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListChannelPartnerLinksAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_channel_partner_links_async_from_dict(): + await test_list_channel_partner_links_async(request_type=dict) + + +def test_list_channel_partner_links_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListChannelPartnerLinksRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_channel_partner_links), + '__call__') as call: + call.return_value = service.ListChannelPartnerLinksResponse() + client.list_channel_partner_links(request) + + # Establish that the 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_channel_partner_links_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListChannelPartnerLinksRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_channel_partner_links), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListChannelPartnerLinksResponse()) + await client.list_channel_partner_links(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_channel_partner_links_pager(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_channel_partner_links), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListChannelPartnerLinksResponse( + channel_partner_links=[ + channel_partner_links.ChannelPartnerLink(), + channel_partner_links.ChannelPartnerLink(), + channel_partner_links.ChannelPartnerLink(), + ], + next_page_token='abc', + ), + service.ListChannelPartnerLinksResponse( + channel_partner_links=[], + next_page_token='def', + ), + service.ListChannelPartnerLinksResponse( + channel_partner_links=[ + channel_partner_links.ChannelPartnerLink(), + ], + next_page_token='ghi', + ), + service.ListChannelPartnerLinksResponse( + channel_partner_links=[ + channel_partner_links.ChannelPartnerLink(), + channel_partner_links.ChannelPartnerLink(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_channel_partner_links(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, channel_partner_links.ChannelPartnerLink) + for i in results) + +def test_list_channel_partner_links_pages(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_channel_partner_links), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListChannelPartnerLinksResponse( + channel_partner_links=[ + channel_partner_links.ChannelPartnerLink(), + channel_partner_links.ChannelPartnerLink(), + channel_partner_links.ChannelPartnerLink(), + ], + next_page_token='abc', + ), + service.ListChannelPartnerLinksResponse( + channel_partner_links=[], + next_page_token='def', + ), + service.ListChannelPartnerLinksResponse( + channel_partner_links=[ + channel_partner_links.ChannelPartnerLink(), + ], + next_page_token='ghi', + ), + service.ListChannelPartnerLinksResponse( + channel_partner_links=[ + channel_partner_links.ChannelPartnerLink(), + channel_partner_links.ChannelPartnerLink(), + ], + ), + RuntimeError, + ) + pages = list(client.list_channel_partner_links(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_channel_partner_links_async_pager(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_channel_partner_links), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListChannelPartnerLinksResponse( + channel_partner_links=[ + channel_partner_links.ChannelPartnerLink(), + channel_partner_links.ChannelPartnerLink(), + channel_partner_links.ChannelPartnerLink(), + ], + next_page_token='abc', + ), + service.ListChannelPartnerLinksResponse( + channel_partner_links=[], + next_page_token='def', + ), + service.ListChannelPartnerLinksResponse( + channel_partner_links=[ + channel_partner_links.ChannelPartnerLink(), + ], + next_page_token='ghi', + ), + service.ListChannelPartnerLinksResponse( + channel_partner_links=[ + channel_partner_links.ChannelPartnerLink(), + channel_partner_links.ChannelPartnerLink(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_channel_partner_links(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, channel_partner_links.ChannelPartnerLink) + for i in responses) + +@pytest.mark.asyncio +async def test_list_channel_partner_links_async_pages(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_channel_partner_links), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListChannelPartnerLinksResponse( + channel_partner_links=[ + channel_partner_links.ChannelPartnerLink(), + channel_partner_links.ChannelPartnerLink(), + channel_partner_links.ChannelPartnerLink(), + ], + next_page_token='abc', + ), + service.ListChannelPartnerLinksResponse( + channel_partner_links=[], + next_page_token='def', + ), + service.ListChannelPartnerLinksResponse( + channel_partner_links=[ + channel_partner_links.ChannelPartnerLink(), + ], + next_page_token='ghi', + ), + service.ListChannelPartnerLinksResponse( + channel_partner_links=[ + channel_partner_links.ChannelPartnerLink(), + channel_partner_links.ChannelPartnerLink(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_channel_partner_links(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_get_channel_partner_link(transport: str = 'grpc', request_type=service.GetChannelPartnerLinkRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_channel_partner_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = channel_partner_links.ChannelPartnerLink( + name='name_value', + reseller_cloud_identity_id='reseller_cloud_identity_id_value', + link_state=channel_partner_links.ChannelPartnerLinkState.INVITED, + invite_link_uri='invite_link_uri_value', + public_id='public_id_value', + ) + response = client.get_channel_partner_link(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.GetChannelPartnerLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, channel_partner_links.ChannelPartnerLink) + assert response.name == 'name_value' + assert response.reseller_cloud_identity_id == 'reseller_cloud_identity_id_value' + assert response.link_state == channel_partner_links.ChannelPartnerLinkState.INVITED + assert response.invite_link_uri == 'invite_link_uri_value' + assert response.public_id == 'public_id_value' + + +def test_get_channel_partner_link_from_dict(): + test_get_channel_partner_link(request_type=dict) + + +def test_get_channel_partner_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_channel_partner_link), + '__call__') as call: + client.get_channel_partner_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetChannelPartnerLinkRequest() + + +@pytest.mark.asyncio +async def test_get_channel_partner_link_async(transport: str = 'grpc_asyncio', request_type=service.GetChannelPartnerLinkRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_channel_partner_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(channel_partner_links.ChannelPartnerLink( + name='name_value', + reseller_cloud_identity_id='reseller_cloud_identity_id_value', + link_state=channel_partner_links.ChannelPartnerLinkState.INVITED, + invite_link_uri='invite_link_uri_value', + public_id='public_id_value', + )) + response = await client.get_channel_partner_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.GetChannelPartnerLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, channel_partner_links.ChannelPartnerLink) + assert response.name == 'name_value' + assert response.reseller_cloud_identity_id == 'reseller_cloud_identity_id_value' + assert response.link_state == channel_partner_links.ChannelPartnerLinkState.INVITED + assert response.invite_link_uri == 'invite_link_uri_value' + assert response.public_id == 'public_id_value' + + +@pytest.mark.asyncio +async def test_get_channel_partner_link_async_from_dict(): + await test_get_channel_partner_link_async(request_type=dict) + + +def test_get_channel_partner_link_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetChannelPartnerLinkRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_channel_partner_link), + '__call__') as call: + call.return_value = channel_partner_links.ChannelPartnerLink() + client.get_channel_partner_link(request) + + # Establish that the 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_channel_partner_link_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.GetChannelPartnerLinkRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_channel_partner_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(channel_partner_links.ChannelPartnerLink()) + await client.get_channel_partner_link(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_create_channel_partner_link(transport: str = 'grpc', request_type=service.CreateChannelPartnerLinkRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_channel_partner_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = channel_partner_links.ChannelPartnerLink( + name='name_value', + reseller_cloud_identity_id='reseller_cloud_identity_id_value', + link_state=channel_partner_links.ChannelPartnerLinkState.INVITED, + invite_link_uri='invite_link_uri_value', + public_id='public_id_value', + ) + response = client.create_channel_partner_link(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.CreateChannelPartnerLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, channel_partner_links.ChannelPartnerLink) + assert response.name == 'name_value' + assert response.reseller_cloud_identity_id == 'reseller_cloud_identity_id_value' + assert response.link_state == channel_partner_links.ChannelPartnerLinkState.INVITED + assert response.invite_link_uri == 'invite_link_uri_value' + assert response.public_id == 'public_id_value' + + +def test_create_channel_partner_link_from_dict(): + test_create_channel_partner_link(request_type=dict) + + +def test_create_channel_partner_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_channel_partner_link), + '__call__') as call: + client.create_channel_partner_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateChannelPartnerLinkRequest() + + +@pytest.mark.asyncio +async def test_create_channel_partner_link_async(transport: str = 'grpc_asyncio', request_type=service.CreateChannelPartnerLinkRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_channel_partner_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(channel_partner_links.ChannelPartnerLink( + name='name_value', + reseller_cloud_identity_id='reseller_cloud_identity_id_value', + link_state=channel_partner_links.ChannelPartnerLinkState.INVITED, + invite_link_uri='invite_link_uri_value', + public_id='public_id_value', + )) + response = await client.create_channel_partner_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateChannelPartnerLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, channel_partner_links.ChannelPartnerLink) + assert response.name == 'name_value' + assert response.reseller_cloud_identity_id == 'reseller_cloud_identity_id_value' + assert response.link_state == channel_partner_links.ChannelPartnerLinkState.INVITED + assert response.invite_link_uri == 'invite_link_uri_value' + assert response.public_id == 'public_id_value' + + +@pytest.mark.asyncio +async def test_create_channel_partner_link_async_from_dict(): + await test_create_channel_partner_link_async(request_type=dict) + + +def test_create_channel_partner_link_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateChannelPartnerLinkRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_channel_partner_link), + '__call__') as call: + call.return_value = channel_partner_links.ChannelPartnerLink() + client.create_channel_partner_link(request) + + # Establish that the 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_channel_partner_link_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.CreateChannelPartnerLinkRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_channel_partner_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(channel_partner_links.ChannelPartnerLink()) + await client.create_channel_partner_link(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_update_channel_partner_link(transport: str = 'grpc', request_type=service.UpdateChannelPartnerLinkRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_channel_partner_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = channel_partner_links.ChannelPartnerLink( + name='name_value', + reseller_cloud_identity_id='reseller_cloud_identity_id_value', + link_state=channel_partner_links.ChannelPartnerLinkState.INVITED, + invite_link_uri='invite_link_uri_value', + public_id='public_id_value', + ) + response = client.update_channel_partner_link(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.UpdateChannelPartnerLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, channel_partner_links.ChannelPartnerLink) + assert response.name == 'name_value' + assert response.reseller_cloud_identity_id == 'reseller_cloud_identity_id_value' + assert response.link_state == channel_partner_links.ChannelPartnerLinkState.INVITED + assert response.invite_link_uri == 'invite_link_uri_value' + assert response.public_id == 'public_id_value' + + +def test_update_channel_partner_link_from_dict(): + test_update_channel_partner_link(request_type=dict) + + +def test_update_channel_partner_link_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_channel_partner_link), + '__call__') as call: + client.update_channel_partner_link() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateChannelPartnerLinkRequest() + + +@pytest.mark.asyncio +async def test_update_channel_partner_link_async(transport: str = 'grpc_asyncio', request_type=service.UpdateChannelPartnerLinkRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_channel_partner_link), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(channel_partner_links.ChannelPartnerLink( + name='name_value', + reseller_cloud_identity_id='reseller_cloud_identity_id_value', + link_state=channel_partner_links.ChannelPartnerLinkState.INVITED, + invite_link_uri='invite_link_uri_value', + public_id='public_id_value', + )) + response = await client.update_channel_partner_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateChannelPartnerLinkRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, channel_partner_links.ChannelPartnerLink) + assert response.name == 'name_value' + assert response.reseller_cloud_identity_id == 'reseller_cloud_identity_id_value' + assert response.link_state == channel_partner_links.ChannelPartnerLinkState.INVITED + assert response.invite_link_uri == 'invite_link_uri_value' + assert response.public_id == 'public_id_value' + + +@pytest.mark.asyncio +async def test_update_channel_partner_link_async_from_dict(): + await test_update_channel_partner_link_async(request_type=dict) + + +def test_update_channel_partner_link_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateChannelPartnerLinkRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_channel_partner_link), + '__call__') as call: + call.return_value = channel_partner_links.ChannelPartnerLink() + client.update_channel_partner_link(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_channel_partner_link_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateChannelPartnerLinkRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_channel_partner_link), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(channel_partner_links.ChannelPartnerLink()) + await client.update_channel_partner_link(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_lookup_offer(transport: str = 'grpc', request_type=service.LookupOfferRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.lookup_offer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = offers.Offer( + name='name_value', + ) + response = client.lookup_offer(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.LookupOfferRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, offers.Offer) + assert response.name == 'name_value' + + +def test_lookup_offer_from_dict(): + test_lookup_offer(request_type=dict) + + +def test_lookup_offer_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.lookup_offer), + '__call__') as call: + client.lookup_offer() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.LookupOfferRequest() + + +@pytest.mark.asyncio +async def test_lookup_offer_async(transport: str = 'grpc_asyncio', request_type=service.LookupOfferRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.lookup_offer), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(offers.Offer( + name='name_value', + )) + response = await client.lookup_offer(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.LookupOfferRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, offers.Offer) + assert response.name == 'name_value' + + +@pytest.mark.asyncio +async def test_lookup_offer_async_from_dict(): + await test_lookup_offer_async(request_type=dict) + + +def test_lookup_offer_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.LookupOfferRequest() + + request.entitlement = 'entitlement/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.lookup_offer), + '__call__') as call: + call.return_value = offers.Offer() + client.lookup_offer(request) + + # Establish that the 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', + 'entitlement=entitlement/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_lookup_offer_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.LookupOfferRequest() + + request.entitlement = 'entitlement/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.lookup_offer), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(offers.Offer()) + await client.lookup_offer(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', + 'entitlement=entitlement/value', + ) in kw['metadata'] + + +def test_list_products(transport: str = 'grpc', request_type=service.ListProductsRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_products), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListProductsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_products(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.ListProductsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListProductsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_products_from_dict(): + test_list_products(request_type=dict) + + +def test_list_products_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_products), + '__call__') as call: + client.list_products() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListProductsRequest() + + +@pytest.mark.asyncio +async def test_list_products_async(transport: str = 'grpc_asyncio', request_type=service.ListProductsRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_products), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListProductsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_products(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListProductsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListProductsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_products_async_from_dict(): + await test_list_products_async(request_type=dict) + + +def test_list_products_pager(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_products), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListProductsResponse( + products=[ + products.Product(), + products.Product(), + products.Product(), + ], + next_page_token='abc', + ), + service.ListProductsResponse( + products=[], + next_page_token='def', + ), + service.ListProductsResponse( + products=[ + products.Product(), + ], + next_page_token='ghi', + ), + service.ListProductsResponse( + products=[ + products.Product(), + products.Product(), + ], + ), + RuntimeError, + ) + + metadata = () + pager = client.list_products(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, products.Product) + for i in results) + +def test_list_products_pages(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_products), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListProductsResponse( + products=[ + products.Product(), + products.Product(), + products.Product(), + ], + next_page_token='abc', + ), + service.ListProductsResponse( + products=[], + next_page_token='def', + ), + service.ListProductsResponse( + products=[ + products.Product(), + ], + next_page_token='ghi', + ), + service.ListProductsResponse( + products=[ + products.Product(), + products.Product(), + ], + ), + RuntimeError, + ) + pages = list(client.list_products(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_products_async_pager(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_products), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListProductsResponse( + products=[ + products.Product(), + products.Product(), + products.Product(), + ], + next_page_token='abc', + ), + service.ListProductsResponse( + products=[], + next_page_token='def', + ), + service.ListProductsResponse( + products=[ + products.Product(), + ], + next_page_token='ghi', + ), + service.ListProductsResponse( + products=[ + products.Product(), + products.Product(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_products(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, products.Product) + for i in responses) + +@pytest.mark.asyncio +async def test_list_products_async_pages(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_products), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListProductsResponse( + products=[ + products.Product(), + products.Product(), + products.Product(), + ], + next_page_token='abc', + ), + service.ListProductsResponse( + products=[], + next_page_token='def', + ), + service.ListProductsResponse( + products=[ + products.Product(), + ], + next_page_token='ghi', + ), + service.ListProductsResponse( + products=[ + products.Product(), + products.Product(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_products(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_list_skus(transport: str = 'grpc', request_type=service.ListSkusRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_skus), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListSkusResponse( + next_page_token='next_page_token_value', + ) + response = client.list_skus(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.ListSkusRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSkusPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_skus_from_dict(): + test_list_skus(request_type=dict) + + +def test_list_skus_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_skus), + '__call__') as call: + client.list_skus() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListSkusRequest() + + +@pytest.mark.asyncio +async def test_list_skus_async(transport: str = 'grpc_asyncio', request_type=service.ListSkusRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_skus), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListSkusResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_skus(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListSkusRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSkusAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_skus_async_from_dict(): + await test_list_skus_async(request_type=dict) + + +def test_list_skus_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListSkusRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_skus), + '__call__') as call: + call.return_value = service.ListSkusResponse() + client.list_skus(request) + + # Establish that the 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_skus_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListSkusRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_skus), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListSkusResponse()) + await client.list_skus(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_skus_pager(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_skus), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListSkusResponse( + skus=[ + products.Sku(), + products.Sku(), + products.Sku(), + ], + next_page_token='abc', + ), + service.ListSkusResponse( + skus=[], + next_page_token='def', + ), + service.ListSkusResponse( + skus=[ + products.Sku(), + ], + next_page_token='ghi', + ), + service.ListSkusResponse( + skus=[ + products.Sku(), + products.Sku(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_skus(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, products.Sku) + for i in results) + +def test_list_skus_pages(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_skus), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListSkusResponse( + skus=[ + products.Sku(), + products.Sku(), + products.Sku(), + ], + next_page_token='abc', + ), + service.ListSkusResponse( + skus=[], + next_page_token='def', + ), + service.ListSkusResponse( + skus=[ + products.Sku(), + ], + next_page_token='ghi', + ), + service.ListSkusResponse( + skus=[ + products.Sku(), + products.Sku(), + ], + ), + RuntimeError, + ) + pages = list(client.list_skus(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_skus_async_pager(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_skus), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListSkusResponse( + skus=[ + products.Sku(), + products.Sku(), + products.Sku(), + ], + next_page_token='abc', + ), + service.ListSkusResponse( + skus=[], + next_page_token='def', + ), + service.ListSkusResponse( + skus=[ + products.Sku(), + ], + next_page_token='ghi', + ), + service.ListSkusResponse( + skus=[ + products.Sku(), + products.Sku(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_skus(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, products.Sku) + for i in responses) + +@pytest.mark.asyncio +async def test_list_skus_async_pages(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_skus), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListSkusResponse( + skus=[ + products.Sku(), + products.Sku(), + products.Sku(), + ], + next_page_token='abc', + ), + service.ListSkusResponse( + skus=[], + next_page_token='def', + ), + service.ListSkusResponse( + skus=[ + products.Sku(), + ], + next_page_token='ghi', + ), + service.ListSkusResponse( + skus=[ + products.Sku(), + products.Sku(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_skus(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_list_offers(transport: str = 'grpc', request_type=service.ListOffersRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_offers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListOffersResponse( + next_page_token='next_page_token_value', + ) + response = client.list_offers(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.ListOffersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListOffersPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_offers_from_dict(): + test_list_offers(request_type=dict) + + +def test_list_offers_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_offers), + '__call__') as call: + client.list_offers() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListOffersRequest() + + +@pytest.mark.asyncio +async def test_list_offers_async(transport: str = 'grpc_asyncio', request_type=service.ListOffersRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_offers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListOffersResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_offers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListOffersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListOffersAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_offers_async_from_dict(): + await test_list_offers_async(request_type=dict) + + +def test_list_offers_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListOffersRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_offers), + '__call__') as call: + call.return_value = service.ListOffersResponse() + client.list_offers(request) + + # Establish that the 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_offers_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListOffersRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_offers), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListOffersResponse()) + await client.list_offers(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_offers_pager(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_offers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListOffersResponse( + offers=[ + offers.Offer(), + offers.Offer(), + offers.Offer(), + ], + next_page_token='abc', + ), + service.ListOffersResponse( + offers=[], + next_page_token='def', + ), + service.ListOffersResponse( + offers=[ + offers.Offer(), + ], + next_page_token='ghi', + ), + service.ListOffersResponse( + offers=[ + offers.Offer(), + offers.Offer(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_offers(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, offers.Offer) + for i in results) + +def test_list_offers_pages(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_offers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListOffersResponse( + offers=[ + offers.Offer(), + offers.Offer(), + offers.Offer(), + ], + next_page_token='abc', + ), + service.ListOffersResponse( + offers=[], + next_page_token='def', + ), + service.ListOffersResponse( + offers=[ + offers.Offer(), + ], + next_page_token='ghi', + ), + service.ListOffersResponse( + offers=[ + offers.Offer(), + offers.Offer(), + ], + ), + RuntimeError, + ) + pages = list(client.list_offers(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_offers_async_pager(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_offers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListOffersResponse( + offers=[ + offers.Offer(), + offers.Offer(), + offers.Offer(), + ], + next_page_token='abc', + ), + service.ListOffersResponse( + offers=[], + next_page_token='def', + ), + service.ListOffersResponse( + offers=[ + offers.Offer(), + ], + next_page_token='ghi', + ), + service.ListOffersResponse( + offers=[ + offers.Offer(), + offers.Offer(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_offers(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, offers.Offer) + for i in responses) + +@pytest.mark.asyncio +async def test_list_offers_async_pages(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_offers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListOffersResponse( + offers=[ + offers.Offer(), + offers.Offer(), + offers.Offer(), + ], + next_page_token='abc', + ), + service.ListOffersResponse( + offers=[], + next_page_token='def', + ), + service.ListOffersResponse( + offers=[ + offers.Offer(), + ], + next_page_token='ghi', + ), + service.ListOffersResponse( + offers=[ + offers.Offer(), + offers.Offer(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_offers(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_list_purchasable_skus(transport: str = 'grpc', request_type=service.ListPurchasableSkusRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_purchasable_skus), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListPurchasableSkusResponse( + next_page_token='next_page_token_value', + ) + response = client.list_purchasable_skus(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.ListPurchasableSkusRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPurchasableSkusPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_purchasable_skus_from_dict(): + test_list_purchasable_skus(request_type=dict) + + +def test_list_purchasable_skus_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_purchasable_skus), + '__call__') as call: + client.list_purchasable_skus() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListPurchasableSkusRequest() + + +@pytest.mark.asyncio +async def test_list_purchasable_skus_async(transport: str = 'grpc_asyncio', request_type=service.ListPurchasableSkusRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_purchasable_skus), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListPurchasableSkusResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_purchasable_skus(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListPurchasableSkusRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPurchasableSkusAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_purchasable_skus_async_from_dict(): + await test_list_purchasable_skus_async(request_type=dict) + + +def test_list_purchasable_skus_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListPurchasableSkusRequest() + + request.customer = 'customer/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_purchasable_skus), + '__call__') as call: + call.return_value = service.ListPurchasableSkusResponse() + client.list_purchasable_skus(request) + + # Establish that the 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', + 'customer=customer/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_purchasable_skus_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListPurchasableSkusRequest() + + request.customer = 'customer/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_purchasable_skus), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListPurchasableSkusResponse()) + await client.list_purchasable_skus(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', + 'customer=customer/value', + ) in kw['metadata'] + + +def test_list_purchasable_skus_pager(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_purchasable_skus), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListPurchasableSkusResponse( + purchasable_skus=[ + service.PurchasableSku(), + service.PurchasableSku(), + service.PurchasableSku(), + ], + next_page_token='abc', + ), + service.ListPurchasableSkusResponse( + purchasable_skus=[], + next_page_token='def', + ), + service.ListPurchasableSkusResponse( + purchasable_skus=[ + service.PurchasableSku(), + ], + next_page_token='ghi', + ), + service.ListPurchasableSkusResponse( + purchasable_skus=[ + service.PurchasableSku(), + service.PurchasableSku(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('customer', ''), + )), + ) + pager = client.list_purchasable_skus(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, service.PurchasableSku) + for i in results) + +def test_list_purchasable_skus_pages(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_purchasable_skus), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListPurchasableSkusResponse( + purchasable_skus=[ + service.PurchasableSku(), + service.PurchasableSku(), + service.PurchasableSku(), + ], + next_page_token='abc', + ), + service.ListPurchasableSkusResponse( + purchasable_skus=[], + next_page_token='def', + ), + service.ListPurchasableSkusResponse( + purchasable_skus=[ + service.PurchasableSku(), + ], + next_page_token='ghi', + ), + service.ListPurchasableSkusResponse( + purchasable_skus=[ + service.PurchasableSku(), + service.PurchasableSku(), + ], + ), + RuntimeError, + ) + pages = list(client.list_purchasable_skus(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_purchasable_skus_async_pager(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_purchasable_skus), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListPurchasableSkusResponse( + purchasable_skus=[ + service.PurchasableSku(), + service.PurchasableSku(), + service.PurchasableSku(), + ], + next_page_token='abc', + ), + service.ListPurchasableSkusResponse( + purchasable_skus=[], + next_page_token='def', + ), + service.ListPurchasableSkusResponse( + purchasable_skus=[ + service.PurchasableSku(), + ], + next_page_token='ghi', + ), + service.ListPurchasableSkusResponse( + purchasable_skus=[ + service.PurchasableSku(), + service.PurchasableSku(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_purchasable_skus(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, service.PurchasableSku) + for i in responses) + +@pytest.mark.asyncio +async def test_list_purchasable_skus_async_pages(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_purchasable_skus), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListPurchasableSkusResponse( + purchasable_skus=[ + service.PurchasableSku(), + service.PurchasableSku(), + service.PurchasableSku(), + ], + next_page_token='abc', + ), + service.ListPurchasableSkusResponse( + purchasable_skus=[], + next_page_token='def', + ), + service.ListPurchasableSkusResponse( + purchasable_skus=[ + service.PurchasableSku(), + ], + next_page_token='ghi', + ), + service.ListPurchasableSkusResponse( + purchasable_skus=[ + service.PurchasableSku(), + service.PurchasableSku(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_purchasable_skus(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_list_purchasable_offers(transport: str = 'grpc', request_type=service.ListPurchasableOffersRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_purchasable_offers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListPurchasableOffersResponse( + next_page_token='next_page_token_value', + ) + response = client.list_purchasable_offers(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.ListPurchasableOffersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPurchasableOffersPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_purchasable_offers_from_dict(): + test_list_purchasable_offers(request_type=dict) + + +def test_list_purchasable_offers_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_purchasable_offers), + '__call__') as call: + client.list_purchasable_offers() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListPurchasableOffersRequest() + + +@pytest.mark.asyncio +async def test_list_purchasable_offers_async(transport: str = 'grpc_asyncio', request_type=service.ListPurchasableOffersRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_purchasable_offers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListPurchasableOffersResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_purchasable_offers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListPurchasableOffersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPurchasableOffersAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_purchasable_offers_async_from_dict(): + await test_list_purchasable_offers_async(request_type=dict) + + +def test_list_purchasable_offers_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListPurchasableOffersRequest() + + request.customer = 'customer/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_purchasable_offers), + '__call__') as call: + call.return_value = service.ListPurchasableOffersResponse() + client.list_purchasable_offers(request) + + # Establish that the 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', + 'customer=customer/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_purchasable_offers_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListPurchasableOffersRequest() + + request.customer = 'customer/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_purchasable_offers), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListPurchasableOffersResponse()) + await client.list_purchasable_offers(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', + 'customer=customer/value', + ) in kw['metadata'] + + +def test_list_purchasable_offers_pager(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_purchasable_offers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListPurchasableOffersResponse( + purchasable_offers=[ + service.PurchasableOffer(), + service.PurchasableOffer(), + service.PurchasableOffer(), + ], + next_page_token='abc', + ), + service.ListPurchasableOffersResponse( + purchasable_offers=[], + next_page_token='def', + ), + service.ListPurchasableOffersResponse( + purchasable_offers=[ + service.PurchasableOffer(), + ], + next_page_token='ghi', + ), + service.ListPurchasableOffersResponse( + purchasable_offers=[ + service.PurchasableOffer(), + service.PurchasableOffer(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('customer', ''), + )), + ) + pager = client.list_purchasable_offers(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, service.PurchasableOffer) + for i in results) + +def test_list_purchasable_offers_pages(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_purchasable_offers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListPurchasableOffersResponse( + purchasable_offers=[ + service.PurchasableOffer(), + service.PurchasableOffer(), + service.PurchasableOffer(), + ], + next_page_token='abc', + ), + service.ListPurchasableOffersResponse( + purchasable_offers=[], + next_page_token='def', + ), + service.ListPurchasableOffersResponse( + purchasable_offers=[ + service.PurchasableOffer(), + ], + next_page_token='ghi', + ), + service.ListPurchasableOffersResponse( + purchasable_offers=[ + service.PurchasableOffer(), + service.PurchasableOffer(), + ], + ), + RuntimeError, + ) + pages = list(client.list_purchasable_offers(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_purchasable_offers_async_pager(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_purchasable_offers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListPurchasableOffersResponse( + purchasable_offers=[ + service.PurchasableOffer(), + service.PurchasableOffer(), + service.PurchasableOffer(), + ], + next_page_token='abc', + ), + service.ListPurchasableOffersResponse( + purchasable_offers=[], + next_page_token='def', + ), + service.ListPurchasableOffersResponse( + purchasable_offers=[ + service.PurchasableOffer(), + ], + next_page_token='ghi', + ), + service.ListPurchasableOffersResponse( + purchasable_offers=[ + service.PurchasableOffer(), + service.PurchasableOffer(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_purchasable_offers(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, service.PurchasableOffer) + for i in responses) + +@pytest.mark.asyncio +async def test_list_purchasable_offers_async_pages(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_purchasable_offers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListPurchasableOffersResponse( + purchasable_offers=[ + service.PurchasableOffer(), + service.PurchasableOffer(), + service.PurchasableOffer(), + ], + next_page_token='abc', + ), + service.ListPurchasableOffersResponse( + purchasable_offers=[], + next_page_token='def', + ), + service.ListPurchasableOffersResponse( + purchasable_offers=[ + service.PurchasableOffer(), + ], + next_page_token='ghi', + ), + service.ListPurchasableOffersResponse( + purchasable_offers=[ + service.PurchasableOffer(), + service.PurchasableOffer(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_purchasable_offers(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_register_subscriber(transport: str = 'grpc', request_type=service.RegisterSubscriberRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.register_subscriber), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.RegisterSubscriberResponse( + topic='topic_value', + ) + response = client.register_subscriber(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.RegisterSubscriberRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.RegisterSubscriberResponse) + assert response.topic == 'topic_value' + + +def test_register_subscriber_from_dict(): + test_register_subscriber(request_type=dict) + + +def test_register_subscriber_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.register_subscriber), + '__call__') as call: + client.register_subscriber() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.RegisterSubscriberRequest() + + +@pytest.mark.asyncio +async def test_register_subscriber_async(transport: str = 'grpc_asyncio', request_type=service.RegisterSubscriberRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.register_subscriber), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.RegisterSubscriberResponse( + topic='topic_value', + )) + response = await client.register_subscriber(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.RegisterSubscriberRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.RegisterSubscriberResponse) + assert response.topic == 'topic_value' + + +@pytest.mark.asyncio +async def test_register_subscriber_async_from_dict(): + await test_register_subscriber_async(request_type=dict) + + +def test_register_subscriber_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.RegisterSubscriberRequest() + + request.account = 'account/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.register_subscriber), + '__call__') as call: + call.return_value = service.RegisterSubscriberResponse() + client.register_subscriber(request) + + # Establish that the 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', + 'account=account/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_register_subscriber_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.RegisterSubscriberRequest() + + request.account = 'account/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.register_subscriber), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.RegisterSubscriberResponse()) + await client.register_subscriber(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', + 'account=account/value', + ) in kw['metadata'] + + +def test_unregister_subscriber(transport: str = 'grpc', request_type=service.UnregisterSubscriberRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.unregister_subscriber), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.UnregisterSubscriberResponse( + topic='topic_value', + ) + response = client.unregister_subscriber(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.UnregisterSubscriberRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.UnregisterSubscriberResponse) + assert response.topic == 'topic_value' + + +def test_unregister_subscriber_from_dict(): + test_unregister_subscriber(request_type=dict) + + +def test_unregister_subscriber_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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.unregister_subscriber), + '__call__') as call: + client.unregister_subscriber() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UnregisterSubscriberRequest() + + +@pytest.mark.asyncio +async def test_unregister_subscriber_async(transport: str = 'grpc_asyncio', request_type=service.UnregisterSubscriberRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.unregister_subscriber), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.UnregisterSubscriberResponse( + topic='topic_value', + )) + response = await client.unregister_subscriber(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UnregisterSubscriberRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.UnregisterSubscriberResponse) + assert response.topic == 'topic_value' + + +@pytest.mark.asyncio +async def test_unregister_subscriber_async_from_dict(): + await test_unregister_subscriber_async(request_type=dict) + + +def test_unregister_subscriber_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UnregisterSubscriberRequest() + + request.account = 'account/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.unregister_subscriber), + '__call__') as call: + call.return_value = service.UnregisterSubscriberResponse() + client.unregister_subscriber(request) + + # Establish that the 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', + 'account=account/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_unregister_subscriber_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UnregisterSubscriberRequest() + + request.account = 'account/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.unregister_subscriber), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.UnregisterSubscriberResponse()) + await client.unregister_subscriber(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', + 'account=account/value', + ) in kw['metadata'] + + +def test_list_subscribers(transport: str = 'grpc', request_type=service.ListSubscribersRequest): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_subscribers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = service.ListSubscribersResponse( + topic='topic_value', + service_accounts=['service_accounts_value'], + next_page_token='next_page_token_value', + ) + response = client.list_subscribers(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.ListSubscribersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSubscribersPager) + assert response.topic == 'topic_value' + assert response.service_accounts == ['service_accounts_value'] + assert response.next_page_token == 'next_page_token_value' + + +def test_list_subscribers_from_dict(): + test_list_subscribers(request_type=dict) + + +def test_list_subscribers_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudChannelServiceClient( + 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_subscribers), + '__call__') as call: + client.list_subscribers() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListSubscribersRequest() + + +@pytest.mark.asyncio +async def test_list_subscribers_async(transport: str = 'grpc_asyncio', request_type=service.ListSubscribersRequest): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_subscribers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListSubscribersResponse( + topic='topic_value', + service_accounts=['service_accounts_value'], + next_page_token='next_page_token_value', + )) + response = await client.list_subscribers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.ListSubscribersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSubscribersAsyncPager) + assert response.topic == 'topic_value' + assert response.service_accounts == ['service_accounts_value'] + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_subscribers_async_from_dict(): + await test_list_subscribers_async(request_type=dict) + + +def test_list_subscribers_field_headers(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListSubscribersRequest() + + request.account = 'account/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_subscribers), + '__call__') as call: + call.return_value = service.ListSubscribersResponse() + client.list_subscribers(request) + + # Establish that the 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', + 'account=account/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_subscribers_field_headers_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.ListSubscribersRequest() + + request.account = 'account/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_subscribers), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListSubscribersResponse()) + await client.list_subscribers(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', + 'account=account/value', + ) in kw['metadata'] + + +def test_list_subscribers_pager(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_subscribers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListSubscribersResponse( + service_accounts=[ + str(), + str(), + str(), + ], + next_page_token='abc', + ), + service.ListSubscribersResponse( + service_accounts=[], + next_page_token='def', + ), + service.ListSubscribersResponse( + service_accounts=[ + str(), + ], + next_page_token='ghi', + ), + service.ListSubscribersResponse( + service_accounts=[ + str(), + str(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('account', ''), + )), + ) + pager = client.list_subscribers(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, str) + for i in results) + +def test_list_subscribers_pages(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_subscribers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListSubscribersResponse( + service_accounts=[ + str(), + str(), + str(), + ], + next_page_token='abc', + ), + service.ListSubscribersResponse( + service_accounts=[], + next_page_token='def', + ), + service.ListSubscribersResponse( + service_accounts=[ + str(), + ], + next_page_token='ghi', + ), + service.ListSubscribersResponse( + service_accounts=[ + str(), + str(), + ], + ), + RuntimeError, + ) + pages = list(client.list_subscribers(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_subscribers_async_pager(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_subscribers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListSubscribersResponse( + service_accounts=[ + str(), + str(), + str(), + ], + next_page_token='abc', + ), + service.ListSubscribersResponse( + service_accounts=[], + next_page_token='def', + ), + service.ListSubscribersResponse( + service_accounts=[ + str(), + ], + next_page_token='ghi', + ), + service.ListSubscribersResponse( + service_accounts=[ + str(), + str(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_subscribers(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, str) + for i in responses) + +@pytest.mark.asyncio +async def test_list_subscribers_async_pages(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_subscribers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + service.ListSubscribersResponse( + service_accounts=[ + str(), + str(), + str(), + ], + next_page_token='abc', + ), + service.ListSubscribersResponse( + service_accounts=[], + next_page_token='def', + ), + service.ListSubscribersResponse( + service_accounts=[ + str(), + ], + next_page_token='ghi', + ), + service.ListSubscribersResponse( + service_accounts=[ + str(), + str(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_subscribers(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.CloudChannelServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.CloudChannelServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CloudChannelServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.CloudChannelServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = CloudChannelServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.CloudChannelServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = CloudChannelServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.CloudChannelServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.CloudChannelServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.CloudChannelServiceGrpcTransport, + transports.CloudChannelServiceGrpcAsyncIOTransport, +]) +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 = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CloudChannelServiceGrpcTransport, + ) + +def test_cloud_channel_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.CloudChannelServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_cloud_channel_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.channel_v1.services.cloud_channel_service.transports.CloudChannelServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.CloudChannelServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'list_customers', + 'get_customer', + 'check_cloud_identity_accounts_exist', + 'create_customer', + 'update_customer', + 'delete_customer', + 'import_customer', + 'provision_cloud_identity', + 'list_entitlements', + 'list_transferable_skus', + 'list_transferable_offers', + 'get_entitlement', + 'create_entitlement', + 'change_parameters', + 'change_renewal_settings', + 'change_offer', + 'start_paid_service', + 'suspend_entitlement', + 'cancel_entitlement', + 'activate_entitlement', + 'transfer_entitlements', + 'transfer_entitlements_to_google', + 'list_channel_partner_links', + 'get_channel_partner_link', + 'create_channel_partner_link', + 'update_channel_partner_link', + 'lookup_offer', + 'list_products', + 'list_skus', + 'list_offers', + 'list_purchasable_skus', + 'list_purchasable_offers', + 'register_subscriber', + 'unregister_subscriber', + 'list_subscribers', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + with pytest.raises(NotImplementedError): + transport.close() + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + +@requires_google_auth_gte_1_25_0 +def test_cloud_channel_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.channel_v1.services.cloud_channel_service.transports.CloudChannelServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CloudChannelServiceTransport( + 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/apps.order', +), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_cloud_channel_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.channel_v1.services.cloud_channel_service.transports.CloudChannelServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CloudChannelServiceTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", scopes=( + 'https://www.googleapis.com/auth/apps.order', + ), + quota_project_id="octopus", + ) + + +def test_cloud_channel_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.channel_v1.services.cloud_channel_service.transports.CloudChannelServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CloudChannelServiceTransport() + adc.assert_called_once() + + +@requires_google_auth_gte_1_25_0 +def test_cloud_channel_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) + CloudChannelServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/apps.order', +), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_cloud_channel_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) + CloudChannelServiceClient() + adc.assert_called_once_with( + scopes=( 'https://www.googleapis.com/auth/apps.order',), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.CloudChannelServiceGrpcTransport, + transports.CloudChannelServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_cloud_channel_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/apps.order',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.CloudChannelServiceGrpcTransport, + transports.CloudChannelServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_cloud_channel_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/apps.order', +), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CloudChannelServiceGrpcTransport, grpc_helpers), + (transports.CloudChannelServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_cloud_channel_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( + "cloudchannel.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + 'https://www.googleapis.com/auth/apps.order', +), + scopes=["1", "2"], + default_host="cloudchannel.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.CloudChannelServiceGrpcTransport, transports.CloudChannelServiceGrpcAsyncIOTransport]) +def test_cloud_channel_service_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, + private_key=expected_key + ) + + +def test_cloud_channel_service_host_no_port(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='cloudchannel.googleapis.com'), + ) + assert client.transport._host == 'cloudchannel.googleapis.com:443' + + +def test_cloud_channel_service_host_with_port(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='cloudchannel.googleapis.com:8000'), + ) + assert client.transport._host == 'cloudchannel.googleapis.com:8000' + +def test_cloud_channel_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CloudChannelServiceGrpcTransport( + 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_cloud_channel_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.CloudChannelServiceGrpcAsyncIOTransport( + 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.CloudChannelServiceGrpcTransport, transports.CloudChannelServiceGrpcAsyncIOTransport]) +def test_cloud_channel_service_transport_channel_mtls_with_client_cert_source( + transport_class +): + with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.CloudChannelServiceGrpcTransport, transports.CloudChannelServiceGrpcAsyncIOTransport]) +def test_cloud_channel_service_transport_channel_mtls_with_adc( + transport_class +): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_cloud_channel_service_grpc_lro_client(): + client = CloudChannelServiceClient( + 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_cloud_channel_service_grpc_lro_async_client(): + client = CloudChannelServiceAsyncClient( + 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_customer_path(): + account = "squid" + customer = "clam" + expected = "accounts/{account}/customers/{customer}".format(account=account, customer=customer, ) + actual = CloudChannelServiceClient.customer_path(account, customer) + assert expected == actual + + +def test_parse_customer_path(): + expected = { + "account": "whelk", + "customer": "octopus", + } + path = CloudChannelServiceClient.customer_path(**expected) + + # Check that the path construction is reversible. + actual = CloudChannelServiceClient.parse_customer_path(path) + assert expected == actual + +def test_entitlement_path(): + account = "oyster" + customer = "nudibranch" + entitlement = "cuttlefish" + expected = "accounts/{account}/customers/{customer}/entitlements/{entitlement}".format(account=account, customer=customer, entitlement=entitlement, ) + actual = CloudChannelServiceClient.entitlement_path(account, customer, entitlement) + assert expected == actual + + +def test_parse_entitlement_path(): + expected = { + "account": "mussel", + "customer": "winkle", + "entitlement": "nautilus", + } + path = CloudChannelServiceClient.entitlement_path(**expected) + + # Check that the path construction is reversible. + actual = CloudChannelServiceClient.parse_entitlement_path(path) + assert expected == actual + +def test_offer_path(): + account = "scallop" + offer = "abalone" + expected = "accounts/{account}/offers/{offer}".format(account=account, offer=offer, ) + actual = CloudChannelServiceClient.offer_path(account, offer) + assert expected == actual + + +def test_parse_offer_path(): + expected = { + "account": "squid", + "offer": "clam", + } + path = CloudChannelServiceClient.offer_path(**expected) + + # Check that the path construction is reversible. + actual = CloudChannelServiceClient.parse_offer_path(path) + assert expected == actual + +def test_product_path(): + product = "whelk" + expected = "products/{product}".format(product=product, ) + actual = CloudChannelServiceClient.product_path(product) + assert expected == actual + + +def test_parse_product_path(): + expected = { + "product": "octopus", + } + path = CloudChannelServiceClient.product_path(**expected) + + # Check that the path construction is reversible. + actual = CloudChannelServiceClient.parse_product_path(path) + assert expected == actual + +def test_sku_path(): + product = "oyster" + sku = "nudibranch" + expected = "products/{product}/skus/{sku}".format(product=product, sku=sku, ) + actual = CloudChannelServiceClient.sku_path(product, sku) + assert expected == actual + + +def test_parse_sku_path(): + expected = { + "product": "cuttlefish", + "sku": "mussel", + } + path = CloudChannelServiceClient.sku_path(**expected) + + # Check that the path construction is reversible. + actual = CloudChannelServiceClient.parse_sku_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "winkle" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = CloudChannelServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "nautilus", + } + path = CloudChannelServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = CloudChannelServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "scallop" + expected = "folders/{folder}".format(folder=folder, ) + actual = CloudChannelServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "abalone", + } + path = CloudChannelServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = CloudChannelServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "squid" + expected = "organizations/{organization}".format(organization=organization, ) + actual = CloudChannelServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "clam", + } + path = CloudChannelServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = CloudChannelServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "whelk" + expected = "projects/{project}".format(project=project, ) + actual = CloudChannelServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "octopus", + } + path = CloudChannelServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = CloudChannelServiceClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "oyster" + location = "nudibranch" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = CloudChannelServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "cuttlefish", + "location": "mussel", + } + path = CloudChannelServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = CloudChannelServiceClient.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.CloudChannelServiceTransport, '_prep_wrapped_messages') as prep: + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.CloudChannelServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = CloudChannelServiceClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", + ) + with mock.patch.object(type(getattr(client.transport, "grpc_channel")), "close") as close: + async with client: + close.assert_not_called() + close.assert_called_once() + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport + ) + with mock.patch.object(type(getattr(client.transport, close_name)), "close") as close: + with client: + close.assert_not_called() + close.assert_called_once() + +def test_client_ctx(): + transports = [ + 'grpc', + ] + for transport in transports: + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() From c78d18b18450ece7bdd8990facdd640fea84368e Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 7 Oct 2021 19:36:22 +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 See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../cloud_channel_service/async_client.py | 6 + .../services/cloud_channel_service/client.py | 18 +- .../cloud_channel_service/transports/base.py | 9 + .../cloud_channel_service/transports/grpc.py | 3 + .../transports/grpc_asyncio.py | 3 + google/cloud/channel_v1/types/common.py | 3 + google/cloud/channel_v1/types/customers.py | 2 + google/cloud/channel_v1/types/entitlements.py | 6 + google/cloud/channel_v1/types/offers.py | 4 + google/cloud/channel_v1/types/products.py | 1 + google/cloud/channel_v1/types/service.py | 20 + owl-bot-staging/v1/.coveragerc | 17 - owl-bot-staging/v1/MANIFEST.in | 2 - owl-bot-staging/v1/README.rst | 49 - .../docs/channel_v1/cloud_channel_service.rst | 10 - .../v1/docs/channel_v1/services.rst | 6 - owl-bot-staging/v1/docs/channel_v1/types.rst | 7 - owl-bot-staging/v1/docs/conf.py | 376 - owl-bot-staging/v1/docs/index.rst | 7 - .../v1/google/cloud/channel/__init__.py | 215 - .../v1/google/cloud/channel/py.typed | 2 - .../v1/google/cloud/channel_v1/__init__.py | 216 - .../cloud/channel_v1/gapic_metadata.json | 373 - .../v1/google/cloud/channel_v1/py.typed | 2 - .../cloud/channel_v1/services/__init__.py | 15 - .../cloud_channel_service/__init__.py | 22 - .../cloud_channel_service/async_client.py | 3089 ------ .../services/cloud_channel_service/client.py | 3355 ------- .../services/cloud_channel_service/pagers.py | 1365 --- .../transports/__init__.py | 33 - .../cloud_channel_service/transports/base.py | 665 -- .../cloud_channel_service/transports/grpc.py | 1841 ---- .../transports/grpc_asyncio.py | 1846 ---- .../google/cloud/channel_v1/types/__init__.py | 228 - .../channel_v1/types/channel_partner_links.py | 123 - .../google/cloud/channel_v1/types/common.py | 219 - .../cloud/channel_v1/types/customers.py | 194 - .../cloud/channel_v1/types/entitlements.py | 403 - .../google/cloud/channel_v1/types/offers.py | 503 - .../cloud/channel_v1/types/operations.py | 58 - .../google/cloud/channel_v1/types/products.py | 147 - .../google/cloud/channel_v1/types/service.py | 1991 ---- .../channel_v1/types/subscriber_event.py | 123 - owl-bot-staging/v1/mypy.ini | 3 - owl-bot-staging/v1/noxfile.py | 132 - .../v1/scripts/fixup_channel_v1_keywords.py | 210 - owl-bot-staging/v1/setup.py | 54 - 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/channel_v1/__init__.py | 16 - .../channel_v1/test_cloud_channel_service.py | 8683 ----------------- .../channel_v1/test_cloud_channel_service.py | 50 + 53 files changed, 121 insertions(+), 26652 deletions(-) delete mode 100644 owl-bot-staging/v1/.coveragerc delete mode 100644 owl-bot-staging/v1/MANIFEST.in delete mode 100644 owl-bot-staging/v1/README.rst delete mode 100644 owl-bot-staging/v1/docs/channel_v1/cloud_channel_service.rst delete mode 100644 owl-bot-staging/v1/docs/channel_v1/services.rst delete mode 100644 owl-bot-staging/v1/docs/channel_v1/types.rst delete mode 100644 owl-bot-staging/v1/docs/conf.py delete mode 100644 owl-bot-staging/v1/docs/index.rst delete mode 100644 owl-bot-staging/v1/google/cloud/channel/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel/py.typed delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/py.typed delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/async_client.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/client.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/pagers.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/base.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/__init__.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/channel_partner_links.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/common.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/customers.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/entitlements.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/offers.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/operations.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/products.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/service.py delete mode 100644 owl-bot-staging/v1/google/cloud/channel_v1/types/subscriber_event.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_channel_v1_keywords.py delete mode 100644 owl-bot-staging/v1/setup.py delete mode 100644 owl-bot-staging/v1/tests/__init__.py delete mode 100644 owl-bot-staging/v1/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v1/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/v1/tests/unit/gapic/channel_v1/__init__.py delete mode 100644 owl-bot-staging/v1/tests/unit/gapic/channel_v1/test_cloud_channel_service.py diff --git a/google/cloud/channel_v1/services/cloud_channel_service/async_client.py b/google/cloud/channel_v1/services/cloud_channel_service/async_client.py index 6e1567e..55bac3a 100644 --- a/google/cloud/channel_v1/services/cloud_channel_service/async_client.py +++ b/google/cloud/channel_v1/services/cloud_channel_service/async_client.py @@ -2857,6 +2857,12 @@ async def list_subscribers( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/channel_v1/services/cloud_channel_service/client.py b/google/cloud/channel_v1/services/cloud_channel_service/client.py index 6910f62..d384694 100644 --- a/google/cloud/channel_v1/services/cloud_channel_service/client.py +++ b/google/cloud/channel_v1/services/cloud_channel_service/client.py @@ -427,10 +427,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def list_customers( @@ -3126,6 +3123,19 @@ def list_subscribers( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/channel_v1/services/cloud_channel_service/transports/base.py b/google/cloud/channel_v1/services/cloud_channel_service/transports/base.py index 5846bdb..e0f2d36 100644 --- a/google/cloud/channel_v1/services/cloud_channel_service/transports/base.py +++ b/google/cloud/channel_v1/services/cloud_channel_service/transports/base.py @@ -296,6 +296,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def operations_client(self) -> operations_v1.OperationsClient: """Return the client designed to process long-running operations.""" diff --git a/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc.py b/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc.py index a20533a..6339fa7 100644 --- a/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc.py +++ b/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc.py @@ -1866,5 +1866,8 @@ def list_subscribers( ) return self._stubs["list_subscribers"] + def close(self): + self.grpc_channel.close() + __all__ = ("CloudChannelServiceGrpcTransport",) diff --git a/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc_asyncio.py b/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc_asyncio.py index f353839..18698f2 100644 --- a/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc_asyncio.py +++ b/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc_asyncio.py @@ -1907,5 +1907,8 @@ def list_subscribers( ) return self._stubs["list_subscribers"] + def close(self): + return self.grpc_channel.close() + __all__ = ("CloudChannelServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/channel_v1/types/common.py b/google/cloud/channel_v1/types/common.py index 33b5a77..f088211 100644 --- a/google/cloud/channel_v1/types/common.py +++ b/google/cloud/channel_v1/types/common.py @@ -26,6 +26,7 @@ class EduData(proto.Message): r"""Required Edu Attributes + Attributes: institute_type (google.cloud.channel_v1.types.EduData.InstituteType): Designated institute type of customer. @@ -60,6 +61,7 @@ class InstituteSize(proto.Enum): class CloudIdentityInfo(proto.Message): r"""Cloud Identity information for the Cloud Channel Customer. + Attributes: customer_type (google.cloud.channel_v1.types.CloudIdentityInfo.CustomerType): CustomerType indicates verification type @@ -105,6 +107,7 @@ class CustomerType(proto.Enum): class Value(proto.Message): r"""Data type and value of a parameter. + Attributes: int64_value (int): Represents an int64 value. diff --git a/google/cloud/channel_v1/types/customers.py b/google/cloud/channel_v1/types/customers.py index b6d3b7f..10c24d0 100644 --- a/google/cloud/channel_v1/types/customers.py +++ b/google/cloud/channel_v1/types/customers.py @@ -27,6 +27,7 @@ class Customer(proto.Message): r"""Entity representing a customer of a reseller or distributor. + Attributes: name (str): Output only. Resource name of the customer. Format: @@ -98,6 +99,7 @@ class Customer(proto.Message): class ContactInfo(proto.Message): r"""Contact information for a customer account. + Attributes: first_name (str): The customer account contact's first name. diff --git a/google/cloud/channel_v1/types/entitlements.py b/google/cloud/channel_v1/types/entitlements.py index 2c347ba..a45944f 100644 --- a/google/cloud/channel_v1/types/entitlements.py +++ b/google/cloud/channel_v1/types/entitlements.py @@ -126,6 +126,7 @@ class SuspensionReason(proto.Enum): class Parameter(proto.Message): r"""Definition for extended entitlement parameters. + Attributes: name (str): Name of the parameter. @@ -158,6 +159,7 @@ class AssociationInfo(proto.Message): class ProvisionedService(proto.Message): r"""Service provisioned for an entitlement. + Attributes: provisioning_id (str): Output only. Provisioning ID of the @@ -178,6 +180,7 @@ class ProvisionedService(proto.Message): class CommitmentSettings(proto.Message): r"""Commitment settings for commitment-based offers. + Attributes: start_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Commitment start timestamp. @@ -195,6 +198,7 @@ class CommitmentSettings(proto.Message): class RenewalSettings(proto.Message): r"""Renewal settings for renewable Offers. + Attributes: enable_renewal (bool): If false, the plan will be completed at the @@ -218,6 +222,7 @@ class RenewalSettings(proto.Message): class TrialSettings(proto.Message): r"""Settings for trial offers. + Attributes: trial (bool): Determines if the entitlement is in a trial or not: @@ -259,6 +264,7 @@ class TransferableSku(proto.Message): class TransferEligibility(proto.Message): r"""Specifies transfer eligibility of a SKU. + Attributes: is_eligible (bool): Whether reseller is eligible to transfer the diff --git a/google/cloud/channel_v1/types/offers.py b/google/cloud/channel_v1/types/offers.py index 3d1f3dc..876ea73 100644 --- a/google/cloud/channel_v1/types/offers.py +++ b/google/cloud/channel_v1/types/offers.py @@ -185,6 +185,7 @@ class ParameterType(proto.Enum): class Constraints(proto.Message): r"""Represents the constraints for buying the Offer. + Attributes: customer_constraints (google.cloud.channel_v1.types.CustomerConstraints): Represents constraints required to purchase @@ -255,6 +256,7 @@ class Plan(proto.Message): class PriceByResource(proto.Message): r"""Represents price by resource type. + Attributes: resource_type (google.cloud.channel_v1.types.ResourceType): Resource Type. Example: SEAT @@ -272,6 +274,7 @@ class PriceByResource(proto.Message): class Price(proto.Message): r"""Represents the price of the Offer. + Attributes: base_price (google.type.money_pb2.Money): Base price. @@ -346,6 +349,7 @@ class PriceTier(proto.Message): class Period(proto.Message): r"""Represents period in days/months/years. + Attributes: duration (int): Total duration of Period Type defined. diff --git a/google/cloud/channel_v1/types/products.py b/google/cloud/channel_v1/types/products.py index 6f15a96..5bda6a3 100644 --- a/google/cloud/channel_v1/types/products.py +++ b/google/cloud/channel_v1/types/products.py @@ -85,6 +85,7 @@ class MarketingInfo(proto.Message): class Media(proto.Message): r"""Represents media information. + Attributes: title (str): Title of the media. diff --git a/google/cloud/channel_v1/types/service.py b/google/cloud/channel_v1/types/service.py index f578689..82a9de7 100644 --- a/google/cloud/channel_v1/types/service.py +++ b/google/cloud/channel_v1/types/service.py @@ -825,6 +825,7 @@ class TransferEntitlementsToGoogleRequest(proto.Message): class ChangeParametersRequest(proto.Message): r"""Request message for [CloudChannelService.ChangeParametersRequest][]. + Attributes: name (str): Required. The name of the entitlement to update. Name uses @@ -1062,6 +1063,7 @@ class ActivateEntitlementRequest(proto.Message): class LookupOfferRequest(proto.Message): r"""Request message for LookupOffer. + Attributes: entitlement (str): Required. The resource name of the entitlement to retrieve @@ -1074,6 +1076,7 @@ class LookupOfferRequest(proto.Message): class ListProductsRequest(proto.Message): r"""Request message for ListProducts. + Attributes: account (str): Required. The resource name of the reseller account. Format: @@ -1102,6 +1105,7 @@ class ListProductsRequest(proto.Message): class ListProductsResponse(proto.Message): r"""Response message for ListProducts. + Attributes: products (Sequence[google.cloud.channel_v1.types.Product]): List of Products requested. @@ -1121,6 +1125,7 @@ def raw_page(self): class ListSkusRequest(proto.Message): r"""Request message for ListSkus. + Attributes: parent (str): Required. The resource name of the Product to list SKUs for. @@ -1154,6 +1159,7 @@ class ListSkusRequest(proto.Message): class ListSkusResponse(proto.Message): r"""Response message for ListSkus. + Attributes: skus (Sequence[google.cloud.channel_v1.types.Sku]): The list of SKUs requested. @@ -1171,6 +1177,7 @@ def raw_page(self): class ListOffersRequest(proto.Message): r"""Request message for ListOffers. + Attributes: parent (str): Required. The resource name of the reseller account from @@ -1208,6 +1215,7 @@ class ListOffersRequest(proto.Message): class ListOffersResponse(proto.Message): r"""Response message for ListOffers. + Attributes: offers (Sequence[google.cloud.channel_v1.types.Offer]): The list of Offers requested. @@ -1225,6 +1233,7 @@ def raw_page(self): class ListPurchasableSkusRequest(proto.Message): r"""Request message for ListPurchasableSkus. + Attributes: create_entitlement_purchase (google.cloud.channel_v1.types.ListPurchasableSkusRequest.CreateEntitlementPurchase): List SKUs for CreateEntitlement purchase. @@ -1306,6 +1315,7 @@ class ChangeType(proto.Enum): class ListPurchasableSkusResponse(proto.Message): r"""Response message for ListPurchasableSkus. + Attributes: purchasable_skus (Sequence[google.cloud.channel_v1.types.PurchasableSku]): The list of SKUs requested. @@ -1337,6 +1347,7 @@ class PurchasableSku(proto.Message): class ListPurchasableOffersRequest(proto.Message): r"""Request message for ListPurchasableOffers. + Attributes: create_entitlement_purchase (google.cloud.channel_v1.types.ListPurchasableOffersRequest.CreateEntitlementPurchase): List Offers for CreateEntitlement purchase. @@ -1363,6 +1374,7 @@ class ListPurchasableOffersRequest(proto.Message): class CreateEntitlementPurchase(proto.Message): r"""List Offers for CreateEntitlement purchase. + Attributes: sku (str): Required. SKU that the result should be restricted to. @@ -1373,6 +1385,7 @@ class CreateEntitlementPurchase(proto.Message): class ChangeOfferPurchase(proto.Message): r"""List Offers for ChangeOffer purchase. + Attributes: entitlement (str): Required. Resource name of the entitlement. Format: @@ -1403,6 +1416,7 @@ class ChangeOfferPurchase(proto.Message): class ListPurchasableOffersResponse(proto.Message): r"""Response message for ListPurchasableOffers. + Attributes: purchasable_offers (Sequence[google.cloud.channel_v1.types.PurchasableOffer]): The list of Offers requested. @@ -1434,6 +1448,7 @@ class PurchasableOffer(proto.Message): class RegisterSubscriberRequest(proto.Message): r"""Request Message for RegisterSubscriber. + Attributes: account (str): Required. Resource name of the account. @@ -1448,6 +1463,7 @@ class RegisterSubscriberRequest(proto.Message): class RegisterSubscriberResponse(proto.Message): r"""Response Message for RegisterSubscriber. + Attributes: topic (str): Name of the topic the subscriber will listen @@ -1459,6 +1475,7 @@ class RegisterSubscriberResponse(proto.Message): class UnregisterSubscriberRequest(proto.Message): r"""Request Message for UnregisterSubscriber. + Attributes: account (str): Required. Resource name of the account. @@ -1473,6 +1490,7 @@ class UnregisterSubscriberRequest(proto.Message): class UnregisterSubscriberResponse(proto.Message): r"""Response Message for UnregisterSubscriber. + Attributes: topic (str): Name of the topic the service account @@ -1484,6 +1502,7 @@ class UnregisterSubscriberResponse(proto.Message): class ListSubscribersRequest(proto.Message): r"""Request Message for ListSubscribers. + Attributes: account (str): Required. Resource name of the account. @@ -1510,6 +1529,7 @@ class ListSubscribersRequest(proto.Message): class ListSubscribersResponse(proto.Message): r"""Response Message for ListSubscribers. + Attributes: topic (str): Name of the topic registered with the diff --git a/owl-bot-staging/v1/.coveragerc b/owl-bot-staging/v1/.coveragerc deleted file mode 100644 index 44d34f9..0000000 --- a/owl-bot-staging/v1/.coveragerc +++ /dev/null @@ -1,17 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/channel/__init__.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/owl-bot-staging/v1/MANIFEST.in b/owl-bot-staging/v1/MANIFEST.in deleted file mode 100644 index 299d625..0000000 --- a/owl-bot-staging/v1/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/channel *.py -recursive-include google/cloud/channel_v1 *.py diff --git a/owl-bot-staging/v1/README.rst b/owl-bot-staging/v1/README.rst deleted file mode 100644 index 1b0de78..0000000 --- a/owl-bot-staging/v1/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Channel 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 Channel 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/channel_v1/cloud_channel_service.rst b/owl-bot-staging/v1/docs/channel_v1/cloud_channel_service.rst deleted file mode 100644 index 917d45e..0000000 --- a/owl-bot-staging/v1/docs/channel_v1/cloud_channel_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -CloudChannelService -------------------------------------- - -.. automodule:: google.cloud.channel_v1.services.cloud_channel_service - :members: - :inherited-members: - -.. automodule:: google.cloud.channel_v1.services.cloud_channel_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v1/docs/channel_v1/services.rst b/owl-bot-staging/v1/docs/channel_v1/services.rst deleted file mode 100644 index afcb3e9..0000000 --- a/owl-bot-staging/v1/docs/channel_v1/services.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Channel v1 API -======================================== -.. toctree:: - :maxdepth: 2 - - cloud_channel_service diff --git a/owl-bot-staging/v1/docs/channel_v1/types.rst b/owl-bot-staging/v1/docs/channel_v1/types.rst deleted file mode 100644 index 1c173ec..0000000 --- a/owl-bot-staging/v1/docs/channel_v1/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Channel v1 API -===================================== - -.. automodule:: google.cloud.channel_v1.types - :members: - :undoc-members: - :show-inheritance: diff --git a/owl-bot-staging/v1/docs/conf.py b/owl-bot-staging/v1/docs/conf.py deleted file mode 100644 index fa3dcab..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-channel 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-channel" -copyright = u"2020, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Client Libraries for Python", - "github_user": "googleapis", - "github_repo": "google-cloud-python", - "github_banner": True, - "font_family": "'Roboto', Georgia, sans", - "head_font_family": "'Roboto', Georgia, serif", - "code_font_family": "'Roboto Mono', 'Consolas', monospace", -} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-channel-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-channel.tex", - u"google-cloud-channel 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-channel", - u"Google Cloud Channel 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-channel", - u"google-cloud-channel Documentation", - author, - "google-cloud-channel", - "GAPIC library for Google Cloud Channel 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 d497c89..0000000 --- a/owl-bot-staging/v1/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - channel_v1/services - channel_v1/types diff --git a/owl-bot-staging/v1/google/cloud/channel/__init__.py b/owl-bot-staging/v1/google/cloud/channel/__init__.py deleted file mode 100644 index b856b64..0000000 --- a/owl-bot-staging/v1/google/cloud/channel/__init__.py +++ /dev/null @@ -1,215 +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.channel_v1.services.cloud_channel_service.client import CloudChannelServiceClient -from google.cloud.channel_v1.services.cloud_channel_service.async_client import CloudChannelServiceAsyncClient - -from google.cloud.channel_v1.types.channel_partner_links import ChannelPartnerLink -from google.cloud.channel_v1.types.channel_partner_links import ChannelPartnerLinkState -from google.cloud.channel_v1.types.channel_partner_links import ChannelPartnerLinkView -from google.cloud.channel_v1.types.common import AdminUser -from google.cloud.channel_v1.types.common import CloudIdentityInfo -from google.cloud.channel_v1.types.common import EduData -from google.cloud.channel_v1.types.common import Value -from google.cloud.channel_v1.types.customers import ContactInfo -from google.cloud.channel_v1.types.customers import Customer -from google.cloud.channel_v1.types.entitlements import AssociationInfo -from google.cloud.channel_v1.types.entitlements import CommitmentSettings -from google.cloud.channel_v1.types.entitlements import Entitlement -from google.cloud.channel_v1.types.entitlements import Parameter -from google.cloud.channel_v1.types.entitlements import ProvisionedService -from google.cloud.channel_v1.types.entitlements import RenewalSettings -from google.cloud.channel_v1.types.entitlements import TransferableSku -from google.cloud.channel_v1.types.entitlements import TransferEligibility -from google.cloud.channel_v1.types.entitlements import TrialSettings -from google.cloud.channel_v1.types.offers import Constraints -from google.cloud.channel_v1.types.offers import CustomerConstraints -from google.cloud.channel_v1.types.offers import Offer -from google.cloud.channel_v1.types.offers import ParameterDefinition -from google.cloud.channel_v1.types.offers import Period -from google.cloud.channel_v1.types.offers import Plan -from google.cloud.channel_v1.types.offers import Price -from google.cloud.channel_v1.types.offers import PriceByResource -from google.cloud.channel_v1.types.offers import PricePhase -from google.cloud.channel_v1.types.offers import PriceTier -from google.cloud.channel_v1.types.offers import PaymentPlan -from google.cloud.channel_v1.types.offers import PaymentType -from google.cloud.channel_v1.types.offers import PeriodType -from google.cloud.channel_v1.types.offers import PromotionalOrderType -from google.cloud.channel_v1.types.offers import ResourceType -from google.cloud.channel_v1.types.operations import OperationMetadata -from google.cloud.channel_v1.types.products import MarketingInfo -from google.cloud.channel_v1.types.products import Media -from google.cloud.channel_v1.types.products import Product -from google.cloud.channel_v1.types.products import Sku -from google.cloud.channel_v1.types.products import MediaType -from google.cloud.channel_v1.types.service import ActivateEntitlementRequest -from google.cloud.channel_v1.types.service import CancelEntitlementRequest -from google.cloud.channel_v1.types.service import ChangeOfferRequest -from google.cloud.channel_v1.types.service import ChangeParametersRequest -from google.cloud.channel_v1.types.service import ChangeRenewalSettingsRequest -from google.cloud.channel_v1.types.service import CheckCloudIdentityAccountsExistRequest -from google.cloud.channel_v1.types.service import CheckCloudIdentityAccountsExistResponse -from google.cloud.channel_v1.types.service import CloudIdentityCustomerAccount -from google.cloud.channel_v1.types.service import CreateChannelPartnerLinkRequest -from google.cloud.channel_v1.types.service import CreateCustomerRequest -from google.cloud.channel_v1.types.service import CreateEntitlementRequest -from google.cloud.channel_v1.types.service import DeleteCustomerRequest -from google.cloud.channel_v1.types.service import GetChannelPartnerLinkRequest -from google.cloud.channel_v1.types.service import GetCustomerRequest -from google.cloud.channel_v1.types.service import GetEntitlementRequest -from google.cloud.channel_v1.types.service import ImportCustomerRequest -from google.cloud.channel_v1.types.service import ListChannelPartnerLinksRequest -from google.cloud.channel_v1.types.service import ListChannelPartnerLinksResponse -from google.cloud.channel_v1.types.service import ListCustomersRequest -from google.cloud.channel_v1.types.service import ListCustomersResponse -from google.cloud.channel_v1.types.service import ListEntitlementsRequest -from google.cloud.channel_v1.types.service import ListEntitlementsResponse -from google.cloud.channel_v1.types.service import ListOffersRequest -from google.cloud.channel_v1.types.service import ListOffersResponse -from google.cloud.channel_v1.types.service import ListProductsRequest -from google.cloud.channel_v1.types.service import ListProductsResponse -from google.cloud.channel_v1.types.service import ListPurchasableOffersRequest -from google.cloud.channel_v1.types.service import ListPurchasableOffersResponse -from google.cloud.channel_v1.types.service import ListPurchasableSkusRequest -from google.cloud.channel_v1.types.service import ListPurchasableSkusResponse -from google.cloud.channel_v1.types.service import ListSkusRequest -from google.cloud.channel_v1.types.service import ListSkusResponse -from google.cloud.channel_v1.types.service import ListSubscribersRequest -from google.cloud.channel_v1.types.service import ListSubscribersResponse -from google.cloud.channel_v1.types.service import ListTransferableOffersRequest -from google.cloud.channel_v1.types.service import ListTransferableOffersResponse -from google.cloud.channel_v1.types.service import ListTransferableSkusRequest -from google.cloud.channel_v1.types.service import ListTransferableSkusResponse -from google.cloud.channel_v1.types.service import LookupOfferRequest -from google.cloud.channel_v1.types.service import ProvisionCloudIdentityRequest -from google.cloud.channel_v1.types.service import PurchasableOffer -from google.cloud.channel_v1.types.service import PurchasableSku -from google.cloud.channel_v1.types.service import RegisterSubscriberRequest -from google.cloud.channel_v1.types.service import RegisterSubscriberResponse -from google.cloud.channel_v1.types.service import StartPaidServiceRequest -from google.cloud.channel_v1.types.service import SuspendEntitlementRequest -from google.cloud.channel_v1.types.service import TransferableOffer -from google.cloud.channel_v1.types.service import TransferEntitlementsRequest -from google.cloud.channel_v1.types.service import TransferEntitlementsResponse -from google.cloud.channel_v1.types.service import TransferEntitlementsToGoogleRequest -from google.cloud.channel_v1.types.service import UnregisterSubscriberRequest -from google.cloud.channel_v1.types.service import UnregisterSubscriberResponse -from google.cloud.channel_v1.types.service import UpdateChannelPartnerLinkRequest -from google.cloud.channel_v1.types.service import UpdateCustomerRequest -from google.cloud.channel_v1.types.subscriber_event import CustomerEvent -from google.cloud.channel_v1.types.subscriber_event import EntitlementEvent -from google.cloud.channel_v1.types.subscriber_event import SubscriberEvent - -__all__ = ('CloudChannelServiceClient', - 'CloudChannelServiceAsyncClient', - 'ChannelPartnerLink', - 'ChannelPartnerLinkState', - 'ChannelPartnerLinkView', - 'AdminUser', - 'CloudIdentityInfo', - 'EduData', - 'Value', - 'ContactInfo', - 'Customer', - 'AssociationInfo', - 'CommitmentSettings', - 'Entitlement', - 'Parameter', - 'ProvisionedService', - 'RenewalSettings', - 'TransferableSku', - 'TransferEligibility', - 'TrialSettings', - 'Constraints', - 'CustomerConstraints', - 'Offer', - 'ParameterDefinition', - 'Period', - 'Plan', - 'Price', - 'PriceByResource', - 'PricePhase', - 'PriceTier', - 'PaymentPlan', - 'PaymentType', - 'PeriodType', - 'PromotionalOrderType', - 'ResourceType', - 'OperationMetadata', - 'MarketingInfo', - 'Media', - 'Product', - 'Sku', - 'MediaType', - 'ActivateEntitlementRequest', - 'CancelEntitlementRequest', - 'ChangeOfferRequest', - 'ChangeParametersRequest', - 'ChangeRenewalSettingsRequest', - 'CheckCloudIdentityAccountsExistRequest', - 'CheckCloudIdentityAccountsExistResponse', - 'CloudIdentityCustomerAccount', - 'CreateChannelPartnerLinkRequest', - 'CreateCustomerRequest', - 'CreateEntitlementRequest', - 'DeleteCustomerRequest', - 'GetChannelPartnerLinkRequest', - 'GetCustomerRequest', - 'GetEntitlementRequest', - 'ImportCustomerRequest', - 'ListChannelPartnerLinksRequest', - 'ListChannelPartnerLinksResponse', - 'ListCustomersRequest', - 'ListCustomersResponse', - 'ListEntitlementsRequest', - 'ListEntitlementsResponse', - 'ListOffersRequest', - 'ListOffersResponse', - 'ListProductsRequest', - 'ListProductsResponse', - 'ListPurchasableOffersRequest', - 'ListPurchasableOffersResponse', - 'ListPurchasableSkusRequest', - 'ListPurchasableSkusResponse', - 'ListSkusRequest', - 'ListSkusResponse', - 'ListSubscribersRequest', - 'ListSubscribersResponse', - 'ListTransferableOffersRequest', - 'ListTransferableOffersResponse', - 'ListTransferableSkusRequest', - 'ListTransferableSkusResponse', - 'LookupOfferRequest', - 'ProvisionCloudIdentityRequest', - 'PurchasableOffer', - 'PurchasableSku', - 'RegisterSubscriberRequest', - 'RegisterSubscriberResponse', - 'StartPaidServiceRequest', - 'SuspendEntitlementRequest', - 'TransferableOffer', - 'TransferEntitlementsRequest', - 'TransferEntitlementsResponse', - 'TransferEntitlementsToGoogleRequest', - 'UnregisterSubscriberRequest', - 'UnregisterSubscriberResponse', - 'UpdateChannelPartnerLinkRequest', - 'UpdateCustomerRequest', - 'CustomerEvent', - 'EntitlementEvent', - 'SubscriberEvent', -) diff --git a/owl-bot-staging/v1/google/cloud/channel/py.typed b/owl-bot-staging/v1/google/cloud/channel/py.typed deleted file mode 100644 index 0915275..0000000 --- a/owl-bot-staging/v1/google/cloud/channel/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-channel package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/__init__.py b/owl-bot-staging/v1/google/cloud/channel_v1/__init__.py deleted file mode 100644 index b3091c2..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/__init__.py +++ /dev/null @@ -1,216 +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.cloud_channel_service import CloudChannelServiceClient -from .services.cloud_channel_service import CloudChannelServiceAsyncClient - -from .types.channel_partner_links import ChannelPartnerLink -from .types.channel_partner_links import ChannelPartnerLinkState -from .types.channel_partner_links import ChannelPartnerLinkView -from .types.common import AdminUser -from .types.common import CloudIdentityInfo -from .types.common import EduData -from .types.common import Value -from .types.customers import ContactInfo -from .types.customers import Customer -from .types.entitlements import AssociationInfo -from .types.entitlements import CommitmentSettings -from .types.entitlements import Entitlement -from .types.entitlements import Parameter -from .types.entitlements import ProvisionedService -from .types.entitlements import RenewalSettings -from .types.entitlements import TransferableSku -from .types.entitlements import TransferEligibility -from .types.entitlements import TrialSettings -from .types.offers import Constraints -from .types.offers import CustomerConstraints -from .types.offers import Offer -from .types.offers import ParameterDefinition -from .types.offers import Period -from .types.offers import Plan -from .types.offers import Price -from .types.offers import PriceByResource -from .types.offers import PricePhase -from .types.offers import PriceTier -from .types.offers import PaymentPlan -from .types.offers import PaymentType -from .types.offers import PeriodType -from .types.offers import PromotionalOrderType -from .types.offers import ResourceType -from .types.operations import OperationMetadata -from .types.products import MarketingInfo -from .types.products import Media -from .types.products import Product -from .types.products import Sku -from .types.products import MediaType -from .types.service import ActivateEntitlementRequest -from .types.service import CancelEntitlementRequest -from .types.service import ChangeOfferRequest -from .types.service import ChangeParametersRequest -from .types.service import ChangeRenewalSettingsRequest -from .types.service import CheckCloudIdentityAccountsExistRequest -from .types.service import CheckCloudIdentityAccountsExistResponse -from .types.service import CloudIdentityCustomerAccount -from .types.service import CreateChannelPartnerLinkRequest -from .types.service import CreateCustomerRequest -from .types.service import CreateEntitlementRequest -from .types.service import DeleteCustomerRequest -from .types.service import GetChannelPartnerLinkRequest -from .types.service import GetCustomerRequest -from .types.service import GetEntitlementRequest -from .types.service import ImportCustomerRequest -from .types.service import ListChannelPartnerLinksRequest -from .types.service import ListChannelPartnerLinksResponse -from .types.service import ListCustomersRequest -from .types.service import ListCustomersResponse -from .types.service import ListEntitlementsRequest -from .types.service import ListEntitlementsResponse -from .types.service import ListOffersRequest -from .types.service import ListOffersResponse -from .types.service import ListProductsRequest -from .types.service import ListProductsResponse -from .types.service import ListPurchasableOffersRequest -from .types.service import ListPurchasableOffersResponse -from .types.service import ListPurchasableSkusRequest -from .types.service import ListPurchasableSkusResponse -from .types.service import ListSkusRequest -from .types.service import ListSkusResponse -from .types.service import ListSubscribersRequest -from .types.service import ListSubscribersResponse -from .types.service import ListTransferableOffersRequest -from .types.service import ListTransferableOffersResponse -from .types.service import ListTransferableSkusRequest -from .types.service import ListTransferableSkusResponse -from .types.service import LookupOfferRequest -from .types.service import ProvisionCloudIdentityRequest -from .types.service import PurchasableOffer -from .types.service import PurchasableSku -from .types.service import RegisterSubscriberRequest -from .types.service import RegisterSubscriberResponse -from .types.service import StartPaidServiceRequest -from .types.service import SuspendEntitlementRequest -from .types.service import TransferableOffer -from .types.service import TransferEntitlementsRequest -from .types.service import TransferEntitlementsResponse -from .types.service import TransferEntitlementsToGoogleRequest -from .types.service import UnregisterSubscriberRequest -from .types.service import UnregisterSubscriberResponse -from .types.service import UpdateChannelPartnerLinkRequest -from .types.service import UpdateCustomerRequest -from .types.subscriber_event import CustomerEvent -from .types.subscriber_event import EntitlementEvent -from .types.subscriber_event import SubscriberEvent - -__all__ = ( - 'CloudChannelServiceAsyncClient', -'ActivateEntitlementRequest', -'AdminUser', -'AssociationInfo', -'CancelEntitlementRequest', -'ChangeOfferRequest', -'ChangeParametersRequest', -'ChangeRenewalSettingsRequest', -'ChannelPartnerLink', -'ChannelPartnerLinkState', -'ChannelPartnerLinkView', -'CheckCloudIdentityAccountsExistRequest', -'CheckCloudIdentityAccountsExistResponse', -'CloudChannelServiceClient', -'CloudIdentityCustomerAccount', -'CloudIdentityInfo', -'CommitmentSettings', -'Constraints', -'ContactInfo', -'CreateChannelPartnerLinkRequest', -'CreateCustomerRequest', -'CreateEntitlementRequest', -'Customer', -'CustomerConstraints', -'CustomerEvent', -'DeleteCustomerRequest', -'EduData', -'Entitlement', -'EntitlementEvent', -'GetChannelPartnerLinkRequest', -'GetCustomerRequest', -'GetEntitlementRequest', -'ImportCustomerRequest', -'ListChannelPartnerLinksRequest', -'ListChannelPartnerLinksResponse', -'ListCustomersRequest', -'ListCustomersResponse', -'ListEntitlementsRequest', -'ListEntitlementsResponse', -'ListOffersRequest', -'ListOffersResponse', -'ListProductsRequest', -'ListProductsResponse', -'ListPurchasableOffersRequest', -'ListPurchasableOffersResponse', -'ListPurchasableSkusRequest', -'ListPurchasableSkusResponse', -'ListSkusRequest', -'ListSkusResponse', -'ListSubscribersRequest', -'ListSubscribersResponse', -'ListTransferableOffersRequest', -'ListTransferableOffersResponse', -'ListTransferableSkusRequest', -'ListTransferableSkusResponse', -'LookupOfferRequest', -'MarketingInfo', -'Media', -'MediaType', -'Offer', -'OperationMetadata', -'Parameter', -'ParameterDefinition', -'PaymentPlan', -'PaymentType', -'Period', -'PeriodType', -'Plan', -'Price', -'PriceByResource', -'PricePhase', -'PriceTier', -'Product', -'PromotionalOrderType', -'ProvisionCloudIdentityRequest', -'ProvisionedService', -'PurchasableOffer', -'PurchasableSku', -'RegisterSubscriberRequest', -'RegisterSubscriberResponse', -'RenewalSettings', -'ResourceType', -'Sku', -'StartPaidServiceRequest', -'SubscriberEvent', -'SuspendEntitlementRequest', -'TransferEligibility', -'TransferEntitlementsRequest', -'TransferEntitlementsResponse', -'TransferEntitlementsToGoogleRequest', -'TransferableOffer', -'TransferableSku', -'TrialSettings', -'UnregisterSubscriberRequest', -'UnregisterSubscriberResponse', -'UpdateChannelPartnerLinkRequest', -'UpdateCustomerRequest', -'Value', -) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/gapic_metadata.json b/owl-bot-staging/v1/google/cloud/channel_v1/gapic_metadata.json deleted file mode 100644 index 9c71a5f..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/gapic_metadata.json +++ /dev/null @@ -1,373 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.channel_v1", - "protoPackage": "google.cloud.channel.v1", - "schema": "1.0", - "services": { - "CloudChannelService": { - "clients": { - "grpc": { - "libraryClient": "CloudChannelServiceClient", - "rpcs": { - "ActivateEntitlement": { - "methods": [ - "activate_entitlement" - ] - }, - "CancelEntitlement": { - "methods": [ - "cancel_entitlement" - ] - }, - "ChangeOffer": { - "methods": [ - "change_offer" - ] - }, - "ChangeParameters": { - "methods": [ - "change_parameters" - ] - }, - "ChangeRenewalSettings": { - "methods": [ - "change_renewal_settings" - ] - }, - "CheckCloudIdentityAccountsExist": { - "methods": [ - "check_cloud_identity_accounts_exist" - ] - }, - "CreateChannelPartnerLink": { - "methods": [ - "create_channel_partner_link" - ] - }, - "CreateCustomer": { - "methods": [ - "create_customer" - ] - }, - "CreateEntitlement": { - "methods": [ - "create_entitlement" - ] - }, - "DeleteCustomer": { - "methods": [ - "delete_customer" - ] - }, - "GetChannelPartnerLink": { - "methods": [ - "get_channel_partner_link" - ] - }, - "GetCustomer": { - "methods": [ - "get_customer" - ] - }, - "GetEntitlement": { - "methods": [ - "get_entitlement" - ] - }, - "ImportCustomer": { - "methods": [ - "import_customer" - ] - }, - "ListChannelPartnerLinks": { - "methods": [ - "list_channel_partner_links" - ] - }, - "ListCustomers": { - "methods": [ - "list_customers" - ] - }, - "ListEntitlements": { - "methods": [ - "list_entitlements" - ] - }, - "ListOffers": { - "methods": [ - "list_offers" - ] - }, - "ListProducts": { - "methods": [ - "list_products" - ] - }, - "ListPurchasableOffers": { - "methods": [ - "list_purchasable_offers" - ] - }, - "ListPurchasableSkus": { - "methods": [ - "list_purchasable_skus" - ] - }, - "ListSkus": { - "methods": [ - "list_skus" - ] - }, - "ListSubscribers": { - "methods": [ - "list_subscribers" - ] - }, - "ListTransferableOffers": { - "methods": [ - "list_transferable_offers" - ] - }, - "ListTransferableSkus": { - "methods": [ - "list_transferable_skus" - ] - }, - "LookupOffer": { - "methods": [ - "lookup_offer" - ] - }, - "ProvisionCloudIdentity": { - "methods": [ - "provision_cloud_identity" - ] - }, - "RegisterSubscriber": { - "methods": [ - "register_subscriber" - ] - }, - "StartPaidService": { - "methods": [ - "start_paid_service" - ] - }, - "SuspendEntitlement": { - "methods": [ - "suspend_entitlement" - ] - }, - "TransferEntitlements": { - "methods": [ - "transfer_entitlements" - ] - }, - "TransferEntitlementsToGoogle": { - "methods": [ - "transfer_entitlements_to_google" - ] - }, - "UnregisterSubscriber": { - "methods": [ - "unregister_subscriber" - ] - }, - "UpdateChannelPartnerLink": { - "methods": [ - "update_channel_partner_link" - ] - }, - "UpdateCustomer": { - "methods": [ - "update_customer" - ] - } - } - }, - "grpc-async": { - "libraryClient": "CloudChannelServiceAsyncClient", - "rpcs": { - "ActivateEntitlement": { - "methods": [ - "activate_entitlement" - ] - }, - "CancelEntitlement": { - "methods": [ - "cancel_entitlement" - ] - }, - "ChangeOffer": { - "methods": [ - "change_offer" - ] - }, - "ChangeParameters": { - "methods": [ - "change_parameters" - ] - }, - "ChangeRenewalSettings": { - "methods": [ - "change_renewal_settings" - ] - }, - "CheckCloudIdentityAccountsExist": { - "methods": [ - "check_cloud_identity_accounts_exist" - ] - }, - "CreateChannelPartnerLink": { - "methods": [ - "create_channel_partner_link" - ] - }, - "CreateCustomer": { - "methods": [ - "create_customer" - ] - }, - "CreateEntitlement": { - "methods": [ - "create_entitlement" - ] - }, - "DeleteCustomer": { - "methods": [ - "delete_customer" - ] - }, - "GetChannelPartnerLink": { - "methods": [ - "get_channel_partner_link" - ] - }, - "GetCustomer": { - "methods": [ - "get_customer" - ] - }, - "GetEntitlement": { - "methods": [ - "get_entitlement" - ] - }, - "ImportCustomer": { - "methods": [ - "import_customer" - ] - }, - "ListChannelPartnerLinks": { - "methods": [ - "list_channel_partner_links" - ] - }, - "ListCustomers": { - "methods": [ - "list_customers" - ] - }, - "ListEntitlements": { - "methods": [ - "list_entitlements" - ] - }, - "ListOffers": { - "methods": [ - "list_offers" - ] - }, - "ListProducts": { - "methods": [ - "list_products" - ] - }, - "ListPurchasableOffers": { - "methods": [ - "list_purchasable_offers" - ] - }, - "ListPurchasableSkus": { - "methods": [ - "list_purchasable_skus" - ] - }, - "ListSkus": { - "methods": [ - "list_skus" - ] - }, - "ListSubscribers": { - "methods": [ - "list_subscribers" - ] - }, - "ListTransferableOffers": { - "methods": [ - "list_transferable_offers" - ] - }, - "ListTransferableSkus": { - "methods": [ - "list_transferable_skus" - ] - }, - "LookupOffer": { - "methods": [ - "lookup_offer" - ] - }, - "ProvisionCloudIdentity": { - "methods": [ - "provision_cloud_identity" - ] - }, - "RegisterSubscriber": { - "methods": [ - "register_subscriber" - ] - }, - "StartPaidService": { - "methods": [ - "start_paid_service" - ] - }, - "SuspendEntitlement": { - "methods": [ - "suspend_entitlement" - ] - }, - "TransferEntitlements": { - "methods": [ - "transfer_entitlements" - ] - }, - "TransferEntitlementsToGoogle": { - "methods": [ - "transfer_entitlements_to_google" - ] - }, - "UnregisterSubscriber": { - "methods": [ - "unregister_subscriber" - ] - }, - "UpdateChannelPartnerLink": { - "methods": [ - "update_channel_partner_link" - ] - }, - "UpdateCustomer": { - "methods": [ - "update_customer" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/py.typed b/owl-bot-staging/v1/google/cloud/channel_v1/py.typed deleted file mode 100644 index 0915275..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-channel package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/__init__.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/__init__.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/__init__.py deleted file mode 100644 index bc5d708..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_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 CloudChannelServiceClient -from .async_client import CloudChannelServiceAsyncClient - -__all__ = ( - 'CloudChannelServiceClient', - 'CloudChannelServiceAsyncClient', -) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/async_client.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/async_client.py deleted file mode 100644 index f8e4dcd..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/async_client.py +++ /dev/null @@ -1,3089 +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.channel_v1.services.cloud_channel_service import pagers -from google.cloud.channel_v1.types import channel_partner_links -from google.cloud.channel_v1.types import common -from google.cloud.channel_v1.types import customers -from google.cloud.channel_v1.types import entitlements -from google.cloud.channel_v1.types import offers -from google.cloud.channel_v1.types import operations -from google.cloud.channel_v1.types import products -from google.cloud.channel_v1.types import service -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.type import postal_address_pb2 # type: ignore -from .transports.base import CloudChannelServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import CloudChannelServiceGrpcAsyncIOTransport -from .client import CloudChannelServiceClient - - -class CloudChannelServiceAsyncClient: - """CloudChannelService lets Google cloud resellers and distributors - manage their customers, channel partners, entitlements, and reports. - - Using this service: - - 1. Resellers and distributors can manage a customer entity. - 2. Distributors can register an authorized reseller in their channel - and provide them with delegated admin access. - 3. Resellers and distributors can manage customer entitlements. - - CloudChannelService exposes the following resources: - - - [Customer][google.cloud.channel.v1.Customer]s: An entity—usually - an enterprise—managed by a reseller or distributor. - - - [Entitlement][google.cloud.channel.v1.Entitlement]s: An entity - that provides a customer with the means to use a service. - Entitlements are created or updated as a result of a successful - fulfillment. - - - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s: - An entity that identifies links between distributors and their - indirect resellers in a channel. - """ - - _client: CloudChannelServiceClient - - DEFAULT_ENDPOINT = CloudChannelServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = CloudChannelServiceClient.DEFAULT_MTLS_ENDPOINT - - customer_path = staticmethod(CloudChannelServiceClient.customer_path) - parse_customer_path = staticmethod(CloudChannelServiceClient.parse_customer_path) - entitlement_path = staticmethod(CloudChannelServiceClient.entitlement_path) - parse_entitlement_path = staticmethod(CloudChannelServiceClient.parse_entitlement_path) - offer_path = staticmethod(CloudChannelServiceClient.offer_path) - parse_offer_path = staticmethod(CloudChannelServiceClient.parse_offer_path) - product_path = staticmethod(CloudChannelServiceClient.product_path) - parse_product_path = staticmethod(CloudChannelServiceClient.parse_product_path) - sku_path = staticmethod(CloudChannelServiceClient.sku_path) - parse_sku_path = staticmethod(CloudChannelServiceClient.parse_sku_path) - common_billing_account_path = staticmethod(CloudChannelServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(CloudChannelServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(CloudChannelServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(CloudChannelServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(CloudChannelServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(CloudChannelServiceClient.parse_common_organization_path) - common_project_path = staticmethod(CloudChannelServiceClient.common_project_path) - parse_common_project_path = staticmethod(CloudChannelServiceClient.parse_common_project_path) - common_location_path = staticmethod(CloudChannelServiceClient.common_location_path) - parse_common_location_path = staticmethod(CloudChannelServiceClient.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: - CloudChannelServiceAsyncClient: The constructed client. - """ - return CloudChannelServiceClient.from_service_account_info.__func__(CloudChannelServiceAsyncClient, 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: - CloudChannelServiceAsyncClient: The constructed client. - """ - return CloudChannelServiceClient.from_service_account_file.__func__(CloudChannelServiceAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> CloudChannelServiceTransport: - """Returns the transport used by the client instance. - - Returns: - CloudChannelServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(CloudChannelServiceClient).get_transport_class, type(CloudChannelServiceClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, CloudChannelServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the cloud channel 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, ~.CloudChannelServiceTransport]): 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 = CloudChannelServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_customers(self, - request: service.ListCustomersRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCustomersAsyncPager: - r"""List [Customer][google.cloud.channel.v1.Customer]s. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: List of - [Customer][google.cloud.channel.v1.Customer]s, or an empty list - if there are no customers. - - Args: - request (:class:`google.cloud.channel_v1.types.ListCustomersRequest`): - The request object. Request message for - [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListCustomersAsyncPager: - Response message for - [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - request = service.ListCustomersRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_customers, - 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.ListCustomersAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_customer(self, - request: service.GetCustomerRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> customers.Customer: - r"""Returns the requested - [Customer][google.cloud.channel.v1.Customer] resource. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer resource doesn't exist. Usually the - result of an invalid name parameter. - - Return value: The [Customer][google.cloud.channel.v1.Customer] - resource. - - Args: - request (:class:`google.cloud.channel_v1.types.GetCustomerRequest`): - The request object. Request message for - [CloudChannelService.GetCustomer][google.cloud.channel.v1.CloudChannelService.GetCustomer]. - name (:class:`str`): - Required. The resource name of the customer to retrieve. - Name uses the format: - accounts/{account_id}/customers/{customer_id} - - 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.channel_v1.types.Customer: - Entity representing a customer of a - reseller or distributor. - - """ - # Create or coerce a protobuf request object. - # Sanity 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.GetCustomerRequest(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_customer, - 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 check_cloud_identity_accounts_exist(self, - request: service.CheckCloudIdentityAccountsExistRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.CheckCloudIdentityAccountsExistResponse: - r"""Confirms the existence of Cloud Identity accounts based on the - domain and if the Cloud Identity accounts are owned by the - reseller. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - INVALID_VALUE: Invalid domain value in the request. - - Return value: A list of - [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] - resources for the domain (may be empty) - - Note: in the v1alpha1 version of the API, a NOT_FOUND error - returns if no - [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] - resources match the domain. - - Args: - request (:class:`google.cloud.channel_v1.types.CheckCloudIdentityAccountsExistRequest`): - The request object. Request message for - [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.CheckCloudIdentityAccountsExistResponse: - Response message for - [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist]. - - """ - # Create or coerce a protobuf request object. - request = service.CheckCloudIdentityAccountsExistRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.check_cloud_identity_accounts_exist, - 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 create_customer(self, - request: service.CreateCustomerRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> customers.Customer: - r"""Creates a new [Customer][google.cloud.channel.v1.Customer] - resource under the reseller or distributor account. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: - - - Required request parameters are missing or invalid. - - Domain field value doesn't match the primary email domain. - - Return value: The newly created - [Customer][google.cloud.channel.v1.Customer] resource. - - Args: - request (:class:`google.cloud.channel_v1.types.CreateCustomerRequest`): - The request object. Request message for - [CloudChannelService.CreateCustomer][google.cloud.channel.v1.CloudChannelService.CreateCustomer] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Customer: - Entity representing a customer of a - reseller or distributor. - - """ - # Create or coerce a protobuf request object. - request = service.CreateCustomerRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.create_customer, - 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 update_customer(self, - request: service.UpdateCustomerRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> customers.Customer: - r"""Updates an existing [Customer][google.cloud.channel.v1.Customer] - resource for the reseller or distributor. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] - resource found for the name in the request. - - Return value: The updated - [Customer][google.cloud.channel.v1.Customer] resource. - - Args: - request (:class:`google.cloud.channel_v1.types.UpdateCustomerRequest`): - The request object. Request message for - [CloudChannelService.UpdateCustomer][google.cloud.channel.v1.CloudChannelService.UpdateCustomer]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Customer: - Entity representing a customer of a - reseller or distributor. - - """ - # Create or coerce a protobuf request object. - request = service.UpdateCustomerRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.update_customer, - 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(( - ("customer.name", request.customer.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_customer(self, - request: service.DeleteCustomerRequest = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes the given [Customer][google.cloud.channel.v1.Customer] - permanently. - - Possible error codes: - - - PERMISSION_DENIED: The account making the request does not - own this customer. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - FAILED_PRECONDITION: The customer has existing entitlements. - - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] - resource found for the name in the request. - - Args: - request (:class:`google.cloud.channel_v1.types.DeleteCustomerRequest`): - The request object. Request message for - [CloudChannelService.DeleteCustomer][google.cloud.channel.v1.CloudChannelService.DeleteCustomer]. - name (:class:`str`): - Required. The resource name of the - customer to delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity 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.DeleteCustomerRequest(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_customer, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def import_customer(self, - request: service.ImportCustomerRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> customers.Customer: - r"""Imports a [Customer][google.cloud.channel.v1.Customer] from the - Cloud Identity associated with the provided Cloud Identity ID or - domain before a TransferEntitlements call. If a linked Customer - already exists and overwrite_if_exists is true, it will update - that Customer's data. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - NOT_FOUND: Cloud Identity doesn't exist or was deleted. - - INVALID_ARGUMENT: Required parameters are missing, or the - auth_token is expired or invalid. - - ALREADY_EXISTS: A customer already exists and has conflicting - critical fields. Requires an overwrite. - - Return value: The [Customer][google.cloud.channel.v1.Customer]. - - Args: - request (:class:`google.cloud.channel_v1.types.ImportCustomerRequest`): - The request object. Request message for - [CloudChannelService.ImportCustomer][google.cloud.channel.v1.CloudChannelService.ImportCustomer] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Customer: - Entity representing a customer of a - reseller or distributor. - - """ - # Create or coerce a protobuf request object. - request = service.ImportCustomerRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.import_customer, - 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 provision_cloud_identity(self, - request: service.ProvisionCloudIdentityRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a Cloud Identity for the given customer using the - customer's information, or the information provided here. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer was not found. - - ALREADY_EXISTS: The customer's primary email already exists. - Retry after changing the customer's primary contact email. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - contains an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (:class:`google.cloud.channel_v1.types.ProvisionCloudIdentityRequest`): - The request object. Request message for - [CloudChannelService.ProvisionCloudIdentity][google.cloud.channel.v1.CloudChannelService.ProvisionCloudIdentity] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Customer` Entity - representing a customer of a reseller or distributor. - - """ - # Create or coerce a protobuf request object. - request = service.ProvisionCloudIdentityRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.provision_cloud_identity, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("customer", request.customer), - )), - ) - - # 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, - customers.Customer, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_entitlements(self, - request: service.ListEntitlementsRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListEntitlementsAsyncPager: - r"""Lists [Entitlement][google.cloud.channel.v1.Entitlement]s - belonging to a customer. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: A list of the customer's - [Entitlement][google.cloud.channel.v1.Entitlement]s. - - Args: - request (:class:`google.cloud.channel_v1.types.ListEntitlementsRequest`): - The request object. Request message for - [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListEntitlementsAsyncPager: - Response message for - [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - request = service.ListEntitlementsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_entitlements, - 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.ListEntitlementsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_transferable_skus(self, - request: service.ListTransferableSkusRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListTransferableSkusAsyncPager: - r"""List [TransferableSku][google.cloud.channel.v1.TransferableSku]s - of a customer based on the Cloud Identity ID or Customer Name in - the request. - - Use this method to list the entitlements information of an - unowned customer. You should provide the customer's Cloud - Identity ID or Customer Name. - - Possible error codes: - - - PERMISSION_DENIED: - - - The customer doesn't belong to the reseller and has no - auth token. - - The supplied auth token is invalid. - - The reseller account making the request is different from - the reseller account in the query. - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: A list of the customer's - [TransferableSku][google.cloud.channel.v1.TransferableSku]. - - Args: - request (:class:`google.cloud.channel_v1.types.ListTransferableSkusRequest`): - The request object. Request message for - [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListTransferableSkusAsyncPager: - Response message for - [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - request = service.ListTransferableSkusRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_transferable_skus, - 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.ListTransferableSkusAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_transferable_offers(self, - request: service.ListTransferableOffersRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListTransferableOffersAsyncPager: - r"""List - [TransferableOffer][google.cloud.channel.v1.TransferableOffer]s - of a customer based on Cloud Identity ID or Customer Name in the - request. - - Use this method when a reseller gets the entitlement information - of an unowned customer. The reseller should provide the - customer's Cloud Identity ID or Customer Name. - - Possible error codes: - - - PERMISSION_DENIED: - - - The customer doesn't belong to the reseller and has no - auth token. - - The supplied auth token is invalid. - - The reseller account making the request is different from - the reseller account in the query. - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: List of - [TransferableOffer][google.cloud.channel.v1.TransferableOffer] - for the given customer and SKU. - - Args: - request (:class:`google.cloud.channel_v1.types.ListTransferableOffersRequest`): - The request object. Request message for - [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListTransferableOffersAsyncPager: - Response message for - [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - request = service.ListTransferableOffersRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_transferable_offers, - 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.ListTransferableOffersAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_entitlement(self, - request: service.GetEntitlementRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> entitlements.Entitlement: - r"""Returns the requested - [Entitlement][google.cloud.channel.v1.Entitlement] resource. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer entitlement was not found. - - Return value: The requested - [Entitlement][google.cloud.channel.v1.Entitlement] resource. - - Args: - request (:class:`google.cloud.channel_v1.types.GetEntitlementRequest`): - The request object. Request message for - [CloudChannelService.GetEntitlement][google.cloud.channel.v1.CloudChannelService.GetEntitlement]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement: - An entitlement is a representation of - a customer's ability to use a service. - - """ - # Create or coerce a protobuf request object. - request = service.GetEntitlementRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.get_entitlement, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_entitlement(self, - request: service.CreateEntitlementRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates an entitlement for a customer. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: - - - Required request parameters are missing or invalid. - - There is already a customer entitlement for a SKU from the - same product family. - - - INVALID_VALUE: Make sure the OfferId is valid. If it is, - contact Google Channel support for further troubleshooting. - - NOT_FOUND: The customer or offer resource was not found. - - ALREADY_EXISTS: - - - The SKU was already purchased for the customer. - - The customer's primary email already exists. Retry after - changing the customer's primary contact email. - - - CONDITION_NOT_MET or FAILED_PRECONDITION: - - - The domain required for purchasing a SKU has not been - verified. - - A pre-requisite SKU required to purchase an Add-On SKU is - missing. For example, Google Workspace Business Starter is - required to purchase Vault or Drive. - - (Developer accounts only) Reseller and resold domain must - meet the following naming requirements: - - - Domain names must start with goog-test. - - Domain names must include the reseller domain. - - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (:class:`google.cloud.channel_v1.types.CreateEntitlementRequest`): - The request object. Request message for - [CloudChannelService.CreateEntitlement][google.cloud.channel.v1.CloudChannelService.CreateEntitlement] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - request = service.CreateEntitlementRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.create_entitlement, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - async def change_parameters(self, - request: service.ChangeParametersRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Change parameters of the entitlement. - - An entitlement update is a long-running operation and it updates - the entitlement as a result of fulfillment. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. For example, the number of seats being changed is - greater than the allowed number of max seats, or decreasing - seats for a commitment based plan. - - NOT_FOUND: Entitlement resource not found. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (:class:`google.cloud.channel_v1.types.ChangeParametersRequest`): - The request object. Request message for - [CloudChannelService.ChangeParametersRequest][]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - request = service.ChangeParametersRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.change_parameters, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - async def change_renewal_settings(self, - request: service.ChangeRenewalSettingsRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the renewal settings for an existing customer - entitlement. - - An entitlement update is a long-running operation and it updates - the entitlement as a result of fulfillment. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - NOT_COMMITMENT_PLAN: Renewal Settings are only applicable for - a commitment plan. Can't enable or disable renewals for - non-commitment plans. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (:class:`google.cloud.channel_v1.types.ChangeRenewalSettingsRequest`): - The request object. Request message for - [CloudChannelService.ChangeRenewalSettings][google.cloud.channel.v1.CloudChannelService.ChangeRenewalSettings]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - request = service.ChangeRenewalSettingsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.change_renewal_settings, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - async def change_offer(self, - request: service.ChangeOfferRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the Offer for an existing customer entitlement. - - An entitlement update is a long-running operation and it updates - the entitlement as a result of fulfillment. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Offer or Entitlement resource not found. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (:class:`google.cloud.channel_v1.types.ChangeOfferRequest`): - The request object. Request message for - [CloudChannelService.ChangeOffer][google.cloud.channel.v1.CloudChannelService.ChangeOffer]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - request = service.ChangeOfferRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.change_offer, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - async def start_paid_service(self, - request: service.StartPaidServiceRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Starts paid service for a trial entitlement. - - Starts paid service for a trial entitlement immediately. This - method is only applicable if a plan is set up for a trial - entitlement but has some trial days remaining. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - FAILED_PRECONDITION/NOT_IN_TRIAL: This method only works for - entitlement on trial plans. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (:class:`google.cloud.channel_v1.types.StartPaidServiceRequest`): - The request object. Request message for - [CloudChannelService.StartPaidService][google.cloud.channel.v1.CloudChannelService.StartPaidService]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - request = service.StartPaidServiceRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.start_paid_service, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - async def suspend_entitlement(self, - request: service.SuspendEntitlementRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Suspends a previously fulfilled entitlement. - - An entitlement suspension is a long-running operation. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - NOT_ACTIVE: Entitlement is not active. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (:class:`google.cloud.channel_v1.types.SuspendEntitlementRequest`): - The request object. Request message for - [CloudChannelService.SuspendEntitlement][google.cloud.channel.v1.CloudChannelService.SuspendEntitlement]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - request = service.SuspendEntitlementRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.suspend_entitlement, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - async def cancel_entitlement(self, - request: service.CancelEntitlementRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Cancels a previously fulfilled entitlement. - - An entitlement cancellation is a long-running operation. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - FAILED_PRECONDITION: There are Google Cloud projects linked - to the Google Cloud entitlement's Cloud Billing subaccount. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - DELETION_TYPE_NOT_ALLOWED: Cancel is only allowed for Google - Workspace add-ons, or entitlements for Google Cloud's - development platform. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The response will - contain google.protobuf.Empty on success. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (:class:`google.cloud.channel_v1.types.CancelEntitlementRequest`): - The request object. Request message for - [CloudChannelService.CancelEntitlement][google.cloud.channel.v1.CloudChannelService.CancelEntitlement]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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. - request = service.CancelEntitlementRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.cancel_entitlement, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - async def activate_entitlement(self, - request: service.ActivateEntitlementRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Activates a previously suspended entitlement. Entitlements - suspended for pending ToS acceptance can't be activated using - this method. - - An entitlement activation is a long-running operation and it - updates the state of the customer entitlement. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - SUSPENSION_NOT_RESELLER_INITIATED: Can only activate - reseller-initiated suspensions and entitlements that have - accepted the TOS. - - NOT_SUSPENDED: Can only activate suspended entitlements not - in an ACTIVE state. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (:class:`google.cloud.channel_v1.types.ActivateEntitlementRequest`): - The request object. Request message for - [CloudChannelService.ActivateEntitlement][google.cloud.channel.v1.CloudChannelService.ActivateEntitlement]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - request = service.ActivateEntitlementRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.activate_entitlement, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - async def transfer_entitlements(self, - request: service.TransferEntitlementsRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Transfers customer entitlements to new reseller. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer or offer resource was not found. - - ALREADY_EXISTS: The SKU was already transferred for the - customer. - - CONDITION_NOT_MET or FAILED_PRECONDITION: - - - The SKU requires domain verification to transfer, but the - domain is not verified. - - An Add-On SKU (example, Vault or Drive) is missing the - pre-requisite SKU (example, G Suite Basic). - - (Developer accounts only) Reseller and resold domain must - meet the following naming requirements: - - - Domain names must start with goog-test. - - Domain names must include the reseller domain. - - - Specify all transferring entitlements. - - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (:class:`google.cloud.channel_v1.types.TransferEntitlementsRequest`): - The request object. Request message for - [CloudChannelService.TransferEntitlements][google.cloud.channel.v1.CloudChannelService.TransferEntitlements]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.TransferEntitlementsResponse` Response message for [CloudChannelService.TransferEntitlements][google.cloud.channel.v1.CloudChannelService.TransferEntitlements]. - This is put in the response field of - google.longrunning.Operation. - - """ - # Create or coerce a protobuf request object. - request = service.TransferEntitlementsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.transfer_entitlements, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - service.TransferEntitlementsResponse, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - async def transfer_entitlements_to_google(self, - request: service.TransferEntitlementsToGoogleRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Transfers customer entitlements from their current reseller to - Google. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer or offer resource was not found. - - ALREADY_EXISTS: The SKU was already transferred for the - customer. - - CONDITION_NOT_MET or FAILED_PRECONDITION: - - - The SKU requires domain verification to transfer, but the - domain is not verified. - - An Add-On SKU (example, Vault or Drive) is missing the - pre-requisite SKU (example, G Suite Basic). - - (Developer accounts only) Reseller and resold domain must - meet the following naming requirements: - - - Domain names must start with goog-test. - - Domain names must include the reseller domain. - - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The response will - contain google.protobuf.Empty on success. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (:class:`google.cloud.channel_v1.types.TransferEntitlementsToGoogleRequest`): - The request object. Request message for - [CloudChannelService.TransferEntitlementsToGoogle][google.cloud.channel.v1.CloudChannelService.TransferEntitlementsToGoogle]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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. - request = service.TransferEntitlementsToGoogleRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.transfer_entitlements_to_google, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_channel_partner_links(self, - request: service.ListChannelPartnerLinksRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListChannelPartnerLinksAsyncPager: - r"""List - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s - belonging to a distributor. You must be a distributor to call - this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: The list of the distributor account's - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resources. - - Args: - request (:class:`google.cloud.channel_v1.types.ListChannelPartnerLinksRequest`): - The request object. Request message for - [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListChannelPartnerLinksAsyncPager: - Response message for - [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - request = service.ListChannelPartnerLinksRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_channel_partner_links, - 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.ListChannelPartnerLinksAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_channel_partner_link(self, - request: service.GetChannelPartnerLinkRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> channel_partner_links.ChannelPartnerLink: - r"""Returns the requested - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. You must be a distributor to call this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: ChannelPartnerLink resource not found because of - an invalid channel partner link name. - - Return value: The - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. - - Args: - request (:class:`google.cloud.channel_v1.types.GetChannelPartnerLinkRequest`): - The request object. Request message for - [CloudChannelService.GetChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.GetChannelPartnerLink]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.ChannelPartnerLink: - Entity representing a link between - distributors and their indirect - resellers in an n-tier resale channel. - - """ - # Create or coerce a protobuf request object. - request = service.GetChannelPartnerLinkRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.get_channel_partner_link, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_channel_partner_link(self, - request: service.CreateChannelPartnerLinkRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> channel_partner_links.ChannelPartnerLink: - r"""Initiates a channel partner link between a distributor and a - reseller, or between resellers in an n-tier reseller channel. - Invited partners need to follow the invite_link_uri provided in - the response to accept. After accepting the invitation, a link - is set up between the two parties. You must be a distributor to - call this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - ALREADY_EXISTS: The ChannelPartnerLink sent in the request - already exists. - - NOT_FOUND: No Cloud Identity customer exists for provided - domain. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The new - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. - - Args: - request (:class:`google.cloud.channel_v1.types.CreateChannelPartnerLinkRequest`): - The request object. Request message for - [CloudChannelService.CreateChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.CreateChannelPartnerLink] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.ChannelPartnerLink: - Entity representing a link between - distributors and their indirect - resellers in an n-tier resale channel. - - """ - # Create or coerce a protobuf request object. - request = service.CreateChannelPartnerLinkRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.create_channel_partner_link, - 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 update_channel_partner_link(self, - request: service.UpdateChannelPartnerLinkRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> channel_partner_links.ChannelPartnerLink: - r"""Updates a channel partner link. Distributors call this method to - change a link's status. For example, to suspend a partner link. - You must be a distributor to call this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: - - - Required request parameters are missing or invalid. - - Link state cannot change from invited to active or - suspended. - - Cannot send reseller_cloud_identity_id, invite_url, or - name in update mask. - - - NOT_FOUND: ChannelPartnerLink resource not found. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The updated - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. - - Args: - request (:class:`google.cloud.channel_v1.types.UpdateChannelPartnerLinkRequest`): - The request object. Request message for - [CloudChannelService.UpdateChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.UpdateChannelPartnerLink] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.ChannelPartnerLink: - Entity representing a link between - distributors and their indirect - resellers in an n-tier resale channel. - - """ - # Create or coerce a protobuf request object. - request = service.UpdateChannelPartnerLinkRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.update_channel_partner_link, - 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 lookup_offer(self, - request: service.LookupOfferRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> offers.Offer: - r"""Returns the requested [Offer][google.cloud.channel.v1.Offer] - resource. - - Possible error codes: - - - PERMISSION_DENIED: The entitlement doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement or offer was not found. - - Return value: The [Offer][google.cloud.channel.v1.Offer] - resource. - - Args: - request (:class:`google.cloud.channel_v1.types.LookupOfferRequest`): - The request object. Request message for LookupOffer. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Offer: - Represents an offer made to resellers for purchase. - An offer is associated with a - [Sku][google.cloud.channel.v1.Sku], has a plan for - payment, a price, and defines the constraints for - buying. - - """ - # Create or coerce a protobuf request object. - request = service.LookupOfferRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.lookup_offer, - 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(( - ("entitlement", request.entitlement), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_products(self, - request: service.ListProductsRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListProductsAsyncPager: - r"""Lists the Products the reseller is authorized to sell. - - Possible error codes: - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Args: - request (:class:`google.cloud.channel_v1.types.ListProductsRequest`): - The request object. Request message for ListProducts. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListProductsAsyncPager: - Response message for ListProducts. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - request = service.ListProductsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_products, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # 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.ListProductsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_skus(self, - request: service.ListSkusRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListSkusAsyncPager: - r"""Lists the SKUs for a product the reseller is authorized to sell. - - Possible error codes: - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Args: - request (:class:`google.cloud.channel_v1.types.ListSkusRequest`): - The request object. Request message for ListSkus. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListSkusAsyncPager: - Response message for ListSkus. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - request = service.ListSkusRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_skus, - 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.ListSkusAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_offers(self, - request: service.ListOffersRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListOffersAsyncPager: - r"""Lists the Offers the reseller can sell. - - Possible error codes: - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Args: - request (:class:`google.cloud.channel_v1.types.ListOffersRequest`): - The request object. Request message for ListOffers. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListOffersAsyncPager: - Response message for ListOffers. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - request = service.ListOffersRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_offers, - 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.ListOffersAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_purchasable_skus(self, - request: service.ListPurchasableSkusRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListPurchasableSkusAsyncPager: - r"""Lists the following: - - - SKUs that you can purchase for a customer - - SKUs that you can upgrade or downgrade for an entitlement. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Args: - request (:class:`google.cloud.channel_v1.types.ListPurchasableSkusRequest`): - The request object. Request message for - ListPurchasableSkus. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListPurchasableSkusAsyncPager: - Response message for - ListPurchasableSkus. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - request = service.ListPurchasableSkusRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_purchasable_skus, - 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(( - ("customer", request.customer), - )), - ) - - # 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.ListPurchasableSkusAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_purchasable_offers(self, - request: service.ListPurchasableOffersRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListPurchasableOffersAsyncPager: - r"""Lists the following: - - - Offers that you can purchase for a customer. - - Offers that you can change for an entitlement. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Args: - request (:class:`google.cloud.channel_v1.types.ListPurchasableOffersRequest`): - The request object. Request message for - ListPurchasableOffers. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListPurchasableOffersAsyncPager: - Response message for - ListPurchasableOffers. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - request = service.ListPurchasableOffersRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_purchasable_offers, - 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(( - ("customer", request.customer), - )), - ) - - # 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.ListPurchasableOffersAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def register_subscriber(self, - request: service.RegisterSubscriberRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.RegisterSubscriberResponse: - r"""Registers a service account with subscriber privileges on the - Cloud Pub/Sub topic for this Channel Services account. After you - create a subscriber, you get the events through - [SubscriberEvent][google.cloud.channel.v1.SubscriberEvent] - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request - and the provided reseller account are different, or the - impersonated user is not a super admin. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The topic name with the registered service email - address. - - Args: - request (:class:`google.cloud.channel_v1.types.RegisterSubscriberRequest`): - The request object. Request Message for - RegisterSubscriber. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.RegisterSubscriberResponse: - Response Message for - RegisterSubscriber. - - """ - # Create or coerce a protobuf request object. - request = service.RegisterSubscriberRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.register_subscriber, - 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(( - ("account", request.account), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def unregister_subscriber(self, - request: service.UnregisterSubscriberRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.UnregisterSubscriberResponse: - r"""Unregisters a service account with subscriber privileges on the - Cloud Pub/Sub topic created for this Channel Services account. - If there are no service accounts left with subscriber - privileges, this deletes the topic. You can call ListSubscribers - to check for these accounts. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request - and the provided reseller account are different, or the - impersonated user is not a super admin. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The topic resource doesn't exist. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The topic name that unregistered the service email - address. Returns a success response if the service email address - wasn't registered with the topic. - - Args: - request (:class:`google.cloud.channel_v1.types.UnregisterSubscriberRequest`): - The request object. Request Message for - UnregisterSubscriber. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.UnregisterSubscriberResponse: - Response Message for - UnregisterSubscriber. - - """ - # Create or coerce a protobuf request object. - request = service.UnregisterSubscriberRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.unregister_subscriber, - 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(( - ("account", request.account), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_subscribers(self, - request: service.ListSubscribersRequest = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListSubscribersAsyncPager: - r"""Lists service accounts with subscriber privileges on the Cloud - Pub/Sub topic created for this Channel Services account. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request - and the provided reseller account are different, or the - impersonated user is not a super admin. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The topic resource doesn't exist. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: A list of service email addresses. - - Args: - request (:class:`google.cloud.channel_v1.types.ListSubscribersRequest`): - The request object. Request Message for ListSubscribers. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListSubscribersAsyncPager: - Response Message for ListSubscribers. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - request = service.ListSubscribersRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_subscribers, - 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(( - ("account", request.account), - )), - ) - - # 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.ListSubscribersAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def __aenter__(self): - return self - - async def __aexit__(self, exc_type, exc, tb): - await self.transport.close() - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-channel", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "CloudChannelServiceAsyncClient", -) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/client.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/client.py deleted file mode 100644 index 6c4c556..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/client.py +++ /dev/null @@ -1,3355 +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 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.channel_v1.services.cloud_channel_service import pagers -from google.cloud.channel_v1.types import channel_partner_links -from google.cloud.channel_v1.types import common -from google.cloud.channel_v1.types import customers -from google.cloud.channel_v1.types import entitlements -from google.cloud.channel_v1.types import offers -from google.cloud.channel_v1.types import operations -from google.cloud.channel_v1.types import products -from google.cloud.channel_v1.types import service -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.type import postal_address_pb2 # type: ignore -from .transports.base import CloudChannelServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import CloudChannelServiceGrpcTransport -from .transports.grpc_asyncio import CloudChannelServiceGrpcAsyncIOTransport - - -class CloudChannelServiceClientMeta(type): - """Metaclass for the CloudChannelService 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[CloudChannelServiceTransport]] - _transport_registry["grpc"] = CloudChannelServiceGrpcTransport - _transport_registry["grpc_asyncio"] = CloudChannelServiceGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[CloudChannelServiceTransport]: - """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 CloudChannelServiceClient(metaclass=CloudChannelServiceClientMeta): - """CloudChannelService lets Google cloud resellers and distributors - manage their customers, channel partners, entitlements, and reports. - - Using this service: - - 1. Resellers and distributors can manage a customer entity. - 2. Distributors can register an authorized reseller in their channel - and provide them with delegated admin access. - 3. Resellers and distributors can manage customer entitlements. - - CloudChannelService exposes the following resources: - - - [Customer][google.cloud.channel.v1.Customer]s: An entity—usually - an enterprise—managed by a reseller or distributor. - - - [Entitlement][google.cloud.channel.v1.Entitlement]s: An entity - that provides a customer with the means to use a service. - Entitlements are created or updated as a result of a successful - fulfillment. - - - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s: - An entity that identifies links between distributors and their - indirect resellers in a channel. - """ - - @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 = "cloudchannel.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: - CloudChannelServiceClient: 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: - CloudChannelServiceClient: 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) -> CloudChannelServiceTransport: - """Returns the transport used by the client instance. - - Returns: - CloudChannelServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def customer_path(account: str,customer: str,) -> str: - """Returns a fully-qualified customer string.""" - return "accounts/{account}/customers/{customer}".format(account=account, customer=customer, ) - - @staticmethod - def parse_customer_path(path: str) -> Dict[str,str]: - """Parses a customer path into its component segments.""" - m = re.match(r"^accounts/(?P.+?)/customers/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def entitlement_path(account: str,customer: str,entitlement: str,) -> str: - """Returns a fully-qualified entitlement string.""" - return "accounts/{account}/customers/{customer}/entitlements/{entitlement}".format(account=account, customer=customer, entitlement=entitlement, ) - - @staticmethod - def parse_entitlement_path(path: str) -> Dict[str,str]: - """Parses a entitlement path into its component segments.""" - m = re.match(r"^accounts/(?P.+?)/customers/(?P.+?)/entitlements/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def offer_path(account: str,offer: str,) -> str: - """Returns a fully-qualified offer string.""" - return "accounts/{account}/offers/{offer}".format(account=account, offer=offer, ) - - @staticmethod - def parse_offer_path(path: str) -> Dict[str,str]: - """Parses a offer path into its component segments.""" - m = re.match(r"^accounts/(?P.+?)/offers/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def product_path(product: str,) -> str: - """Returns a fully-qualified product string.""" - return "products/{product}".format(product=product, ) - - @staticmethod - def parse_product_path(path: str) -> Dict[str,str]: - """Parses a product path into its component segments.""" - m = re.match(r"^products/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def sku_path(product: str,sku: str,) -> str: - """Returns a fully-qualified sku string.""" - return "products/{product}/skus/{sku}".format(product=product, sku=sku, ) - - @staticmethod - def parse_sku_path(path: str) -> Dict[str,str]: - """Parses a sku path into its component segments.""" - m = re.match(r"^products/(?P.+?)/skus/(?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, CloudChannelServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the cloud channel 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, CloudChannelServiceTransport]): 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, CloudChannelServiceTransport): - # transport is a CloudChannelServiceTransport 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, - always_use_jwt_access=True, - ) - - def list_customers(self, - request: Union[service.ListCustomersRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListCustomersPager: - r"""List [Customer][google.cloud.channel.v1.Customer]s. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: List of - [Customer][google.cloud.channel.v1.Customer]s, or an empty list - if there are no customers. - - Args: - request (Union[google.cloud.channel_v1.types.ListCustomersRequest, dict]): - The request object. Request message for - [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListCustomersPager: - Response message for - [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ListCustomersRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListCustomersRequest): - request = service.ListCustomersRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_customers] - - # 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.ListCustomersPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_customer(self, - request: Union[service.GetCustomerRequest, dict] = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> customers.Customer: - r"""Returns the requested - [Customer][google.cloud.channel.v1.Customer] resource. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer resource doesn't exist. Usually the - result of an invalid name parameter. - - Return value: The [Customer][google.cloud.channel.v1.Customer] - resource. - - Args: - request (Union[google.cloud.channel_v1.types.GetCustomerRequest, dict]): - The request object. Request message for - [CloudChannelService.GetCustomer][google.cloud.channel.v1.CloudChannelService.GetCustomer]. - name (str): - Required. The resource name of the customer to retrieve. - Name uses the format: - accounts/{account_id}/customers/{customer_id} - - 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.channel_v1.types.Customer: - Entity representing a customer of a - reseller or distributor. - - """ - # Create or coerce a protobuf request object. - # Sanity 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.GetCustomerRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetCustomerRequest): - request = service.GetCustomerRequest(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_customer] - - # Certain 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 check_cloud_identity_accounts_exist(self, - request: Union[service.CheckCloudIdentityAccountsExistRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.CheckCloudIdentityAccountsExistResponse: - r"""Confirms the existence of Cloud Identity accounts based on the - domain and if the Cloud Identity accounts are owned by the - reseller. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - INVALID_VALUE: Invalid domain value in the request. - - Return value: A list of - [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] - resources for the domain (may be empty) - - Note: in the v1alpha1 version of the API, a NOT_FOUND error - returns if no - [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] - resources match the domain. - - Args: - request (Union[google.cloud.channel_v1.types.CheckCloudIdentityAccountsExistRequest, dict]): - The request object. Request message for - [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.CheckCloudIdentityAccountsExistResponse: - Response message for - [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.CheckCloudIdentityAccountsExistRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CheckCloudIdentityAccountsExistRequest): - request = service.CheckCloudIdentityAccountsExistRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.check_cloud_identity_accounts_exist] - - # 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 create_customer(self, - request: Union[service.CreateCustomerRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> customers.Customer: - r"""Creates a new [Customer][google.cloud.channel.v1.Customer] - resource under the reseller or distributor account. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: - - - Required request parameters are missing or invalid. - - Domain field value doesn't match the primary email domain. - - Return value: The newly created - [Customer][google.cloud.channel.v1.Customer] resource. - - Args: - request (Union[google.cloud.channel_v1.types.CreateCustomerRequest, dict]): - The request object. Request message for - [CloudChannelService.CreateCustomer][google.cloud.channel.v1.CloudChannelService.CreateCustomer] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Customer: - Entity representing a customer of a - reseller or distributor. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.CreateCustomerRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CreateCustomerRequest): - request = service.CreateCustomerRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_customer] - - # 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 update_customer(self, - request: Union[service.UpdateCustomerRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> customers.Customer: - r"""Updates an existing [Customer][google.cloud.channel.v1.Customer] - resource for the reseller or distributor. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] - resource found for the name in the request. - - Return value: The updated - [Customer][google.cloud.channel.v1.Customer] resource. - - Args: - request (Union[google.cloud.channel_v1.types.UpdateCustomerRequest, dict]): - The request object. Request message for - [CloudChannelService.UpdateCustomer][google.cloud.channel.v1.CloudChannelService.UpdateCustomer]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Customer: - Entity representing a customer of a - reseller or distributor. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.UpdateCustomerRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UpdateCustomerRequest): - request = service.UpdateCustomerRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_customer] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("customer.name", request.customer.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_customer(self, - request: Union[service.DeleteCustomerRequest, dict] = None, - *, - name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes the given [Customer][google.cloud.channel.v1.Customer] - permanently. - - Possible error codes: - - - PERMISSION_DENIED: The account making the request does not - own this customer. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - FAILED_PRECONDITION: The customer has existing entitlements. - - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] - resource found for the name in the request. - - Args: - request (Union[google.cloud.channel_v1.types.DeleteCustomerRequest, dict]): - The request object. Request message for - [CloudChannelService.DeleteCustomer][google.cloud.channel.v1.CloudChannelService.DeleteCustomer]. - name (str): - Required. The resource name of the - customer to delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Sanity 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.DeleteCustomerRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.DeleteCustomerRequest): - request = service.DeleteCustomerRequest(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_customer] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def import_customer(self, - request: Union[service.ImportCustomerRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> customers.Customer: - r"""Imports a [Customer][google.cloud.channel.v1.Customer] from the - Cloud Identity associated with the provided Cloud Identity ID or - domain before a TransferEntitlements call. If a linked Customer - already exists and overwrite_if_exists is true, it will update - that Customer's data. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - NOT_FOUND: Cloud Identity doesn't exist or was deleted. - - INVALID_ARGUMENT: Required parameters are missing, or the - auth_token is expired or invalid. - - ALREADY_EXISTS: A customer already exists and has conflicting - critical fields. Requires an overwrite. - - Return value: The [Customer][google.cloud.channel.v1.Customer]. - - Args: - request (Union[google.cloud.channel_v1.types.ImportCustomerRequest, dict]): - The request object. Request message for - [CloudChannelService.ImportCustomer][google.cloud.channel.v1.CloudChannelService.ImportCustomer] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Customer: - Entity representing a customer of a - reseller or distributor. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ImportCustomerRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ImportCustomerRequest): - request = service.ImportCustomerRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.import_customer] - - # 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 provision_cloud_identity(self, - request: Union[service.ProvisionCloudIdentityRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates a Cloud Identity for the given customer using the - customer's information, or the information provided here. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer was not found. - - ALREADY_EXISTS: The customer's primary email already exists. - Retry after changing the customer's primary contact email. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - contains an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (Union[google.cloud.channel_v1.types.ProvisionCloudIdentityRequest, dict]): - The request object. Request message for - [CloudChannelService.ProvisionCloudIdentity][google.cloud.channel.v1.CloudChannelService.ProvisionCloudIdentity] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Customer` Entity - representing a customer of a reseller or distributor. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ProvisionCloudIdentityRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ProvisionCloudIdentityRequest): - request = service.ProvisionCloudIdentityRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.provision_cloud_identity] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("customer", request.customer), - )), - ) - - # 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, - customers.Customer, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_entitlements(self, - request: Union[service.ListEntitlementsRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListEntitlementsPager: - r"""Lists [Entitlement][google.cloud.channel.v1.Entitlement]s - belonging to a customer. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: A list of the customer's - [Entitlement][google.cloud.channel.v1.Entitlement]s. - - Args: - request (Union[google.cloud.channel_v1.types.ListEntitlementsRequest, dict]): - The request object. Request message for - [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListEntitlementsPager: - Response message for - [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ListEntitlementsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListEntitlementsRequest): - request = service.ListEntitlementsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_entitlements] - - # 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.ListEntitlementsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_transferable_skus(self, - request: Union[service.ListTransferableSkusRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListTransferableSkusPager: - r"""List [TransferableSku][google.cloud.channel.v1.TransferableSku]s - of a customer based on the Cloud Identity ID or Customer Name in - the request. - - Use this method to list the entitlements information of an - unowned customer. You should provide the customer's Cloud - Identity ID or Customer Name. - - Possible error codes: - - - PERMISSION_DENIED: - - - The customer doesn't belong to the reseller and has no - auth token. - - The supplied auth token is invalid. - - The reseller account making the request is different from - the reseller account in the query. - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: A list of the customer's - [TransferableSku][google.cloud.channel.v1.TransferableSku]. - - Args: - request (Union[google.cloud.channel_v1.types.ListTransferableSkusRequest, dict]): - The request object. Request message for - [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListTransferableSkusPager: - Response message for - [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ListTransferableSkusRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListTransferableSkusRequest): - request = service.ListTransferableSkusRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_transferable_skus] - - # 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.ListTransferableSkusPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_transferable_offers(self, - request: Union[service.ListTransferableOffersRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListTransferableOffersPager: - r"""List - [TransferableOffer][google.cloud.channel.v1.TransferableOffer]s - of a customer based on Cloud Identity ID or Customer Name in the - request. - - Use this method when a reseller gets the entitlement information - of an unowned customer. The reseller should provide the - customer's Cloud Identity ID or Customer Name. - - Possible error codes: - - - PERMISSION_DENIED: - - - The customer doesn't belong to the reseller and has no - auth token. - - The supplied auth token is invalid. - - The reseller account making the request is different from - the reseller account in the query. - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: List of - [TransferableOffer][google.cloud.channel.v1.TransferableOffer] - for the given customer and SKU. - - Args: - request (Union[google.cloud.channel_v1.types.ListTransferableOffersRequest, dict]): - The request object. Request message for - [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListTransferableOffersPager: - Response message for - [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ListTransferableOffersRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListTransferableOffersRequest): - request = service.ListTransferableOffersRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_transferable_offers] - - # 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.ListTransferableOffersPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_entitlement(self, - request: Union[service.GetEntitlementRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> entitlements.Entitlement: - r"""Returns the requested - [Entitlement][google.cloud.channel.v1.Entitlement] resource. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer entitlement was not found. - - Return value: The requested - [Entitlement][google.cloud.channel.v1.Entitlement] resource. - - Args: - request (Union[google.cloud.channel_v1.types.GetEntitlementRequest, dict]): - The request object. Request message for - [CloudChannelService.GetEntitlement][google.cloud.channel.v1.CloudChannelService.GetEntitlement]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement: - An entitlement is a representation of - a customer's ability to use a service. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.GetEntitlementRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetEntitlementRequest): - request = service.GetEntitlementRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_entitlement] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_entitlement(self, - request: Union[service.CreateEntitlementRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates an entitlement for a customer. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: - - - Required request parameters are missing or invalid. - - There is already a customer entitlement for a SKU from the - same product family. - - - INVALID_VALUE: Make sure the OfferId is valid. If it is, - contact Google Channel support for further troubleshooting. - - NOT_FOUND: The customer or offer resource was not found. - - ALREADY_EXISTS: - - - The SKU was already purchased for the customer. - - The customer's primary email already exists. Retry after - changing the customer's primary contact email. - - - CONDITION_NOT_MET or FAILED_PRECONDITION: - - - The domain required for purchasing a SKU has not been - verified. - - A pre-requisite SKU required to purchase an Add-On SKU is - missing. For example, Google Workspace Business Starter is - required to purchase Vault or Drive. - - (Developer accounts only) Reseller and resold domain must - meet the following naming requirements: - - - Domain names must start with goog-test. - - Domain names must include the reseller domain. - - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (Union[google.cloud.channel_v1.types.CreateEntitlementRequest, dict]): - The request object. Request message for - [CloudChannelService.CreateEntitlement][google.cloud.channel.v1.CloudChannelService.CreateEntitlement] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.CreateEntitlementRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CreateEntitlementRequest): - request = service.CreateEntitlementRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_entitlement] - - # 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, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - def change_parameters(self, - request: Union[service.ChangeParametersRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Change parameters of the entitlement. - - An entitlement update is a long-running operation and it updates - the entitlement as a result of fulfillment. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. For example, the number of seats being changed is - greater than the allowed number of max seats, or decreasing - seats for a commitment based plan. - - NOT_FOUND: Entitlement resource not found. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (Union[google.cloud.channel_v1.types.ChangeParametersRequest, dict]): - The request object. Request message for - [CloudChannelService.ChangeParametersRequest][]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ChangeParametersRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ChangeParametersRequest): - request = service.ChangeParametersRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.change_parameters] - - # Certain 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, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - def change_renewal_settings(self, - request: Union[service.ChangeRenewalSettingsRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Updates the renewal settings for an existing customer - entitlement. - - An entitlement update is a long-running operation and it updates - the entitlement as a result of fulfillment. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - NOT_COMMITMENT_PLAN: Renewal Settings are only applicable for - a commitment plan. Can't enable or disable renewals for - non-commitment plans. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (Union[google.cloud.channel_v1.types.ChangeRenewalSettingsRequest, dict]): - The request object. Request message for - [CloudChannelService.ChangeRenewalSettings][google.cloud.channel.v1.CloudChannelService.ChangeRenewalSettings]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ChangeRenewalSettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ChangeRenewalSettingsRequest): - request = service.ChangeRenewalSettingsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.change_renewal_settings] - - # Certain 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, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - def change_offer(self, - request: Union[service.ChangeOfferRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Updates the Offer for an existing customer entitlement. - - An entitlement update is a long-running operation and it updates - the entitlement as a result of fulfillment. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Offer or Entitlement resource not found. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (Union[google.cloud.channel_v1.types.ChangeOfferRequest, dict]): - The request object. Request message for - [CloudChannelService.ChangeOffer][google.cloud.channel.v1.CloudChannelService.ChangeOffer]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ChangeOfferRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ChangeOfferRequest): - request = service.ChangeOfferRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.change_offer] - - # Certain 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, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - def start_paid_service(self, - request: Union[service.StartPaidServiceRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Starts paid service for a trial entitlement. - - Starts paid service for a trial entitlement immediately. This - method is only applicable if a plan is set up for a trial - entitlement but has some trial days remaining. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - FAILED_PRECONDITION/NOT_IN_TRIAL: This method only works for - entitlement on trial plans. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (Union[google.cloud.channel_v1.types.StartPaidServiceRequest, dict]): - The request object. Request message for - [CloudChannelService.StartPaidService][google.cloud.channel.v1.CloudChannelService.StartPaidService]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.StartPaidServiceRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.StartPaidServiceRequest): - request = service.StartPaidServiceRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.start_paid_service] - - # Certain 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, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - def suspend_entitlement(self, - request: Union[service.SuspendEntitlementRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Suspends a previously fulfilled entitlement. - - An entitlement suspension is a long-running operation. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - NOT_ACTIVE: Entitlement is not active. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (Union[google.cloud.channel_v1.types.SuspendEntitlementRequest, dict]): - The request object. Request message for - [CloudChannelService.SuspendEntitlement][google.cloud.channel.v1.CloudChannelService.SuspendEntitlement]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.SuspendEntitlementRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.SuspendEntitlementRequest): - request = service.SuspendEntitlementRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.suspend_entitlement] - - # Certain 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, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - def cancel_entitlement(self, - request: Union[service.CancelEntitlementRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Cancels a previously fulfilled entitlement. - - An entitlement cancellation is a long-running operation. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - FAILED_PRECONDITION: There are Google Cloud projects linked - to the Google Cloud entitlement's Cloud Billing subaccount. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - DELETION_TYPE_NOT_ALLOWED: Cancel is only allowed for Google - Workspace add-ons, or entitlements for Google Cloud's - development platform. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The response will - contain google.protobuf.Empty on success. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (Union[google.cloud.channel_v1.types.CancelEntitlementRequest, dict]): - The request object. Request message for - [CloudChannelService.CancelEntitlement][google.cloud.channel.v1.CloudChannelService.CancelEntitlement]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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. - # Minor optimization to avoid making a copy if the user passes - # in a service.CancelEntitlementRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CancelEntitlementRequest): - request = service.CancelEntitlementRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.cancel_entitlement] - - # Certain 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=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - def activate_entitlement(self, - request: Union[service.ActivateEntitlementRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Activates a previously suspended entitlement. Entitlements - suspended for pending ToS acceptance can't be activated using - this method. - - An entitlement activation is a long-running operation and it - updates the state of the customer entitlement. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - SUSPENSION_NOT_RESELLER_INITIATED: Can only activate - reseller-initiated suspensions and entitlements that have - accepted the TOS. - - NOT_SUSPENDED: Can only activate suspended entitlements not - in an ACTIVE state. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (Union[google.cloud.channel_v1.types.ActivateEntitlementRequest, dict]): - The request object. Request message for - [CloudChannelService.ActivateEntitlement][google.cloud.channel.v1.CloudChannelService.ActivateEntitlement]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Entitlement` An - entitlement is a representation of a customer's ability - to use a service. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ActivateEntitlementRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ActivateEntitlementRequest): - request = service.ActivateEntitlementRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.activate_entitlement] - - # Certain 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, - entitlements.Entitlement, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - def transfer_entitlements(self, - request: Union[service.TransferEntitlementsRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Transfers customer entitlements to new reseller. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer or offer resource was not found. - - ALREADY_EXISTS: The SKU was already transferred for the - customer. - - CONDITION_NOT_MET or FAILED_PRECONDITION: - - - The SKU requires domain verification to transfer, but the - domain is not verified. - - An Add-On SKU (example, Vault or Drive) is missing the - pre-requisite SKU (example, G Suite Basic). - - (Developer accounts only) Reseller and resold domain must - meet the following naming requirements: - - - Domain names must start with goog-test. - - Domain names must include the reseller domain. - - - Specify all transferring entitlements. - - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (Union[google.cloud.channel_v1.types.TransferEntitlementsRequest, dict]): - The request object. Request message for - [CloudChannelService.TransferEntitlements][google.cloud.channel.v1.CloudChannelService.TransferEntitlements]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.TransferEntitlementsResponse` Response message for [CloudChannelService.TransferEntitlements][google.cloud.channel.v1.CloudChannelService.TransferEntitlements]. - This is put in the response field of - google.longrunning.Operation. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.TransferEntitlementsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.TransferEntitlementsRequest): - request = service.TransferEntitlementsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.transfer_entitlements] - - # 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, - service.TransferEntitlementsResponse, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - def transfer_entitlements_to_google(self, - request: Union[service.TransferEntitlementsToGoogleRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Transfers customer entitlements from their current reseller to - Google. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer or offer resource was not found. - - ALREADY_EXISTS: The SKU was already transferred for the - customer. - - CONDITION_NOT_MET or FAILED_PRECONDITION: - - - The SKU requires domain verification to transfer, but the - domain is not verified. - - An Add-On SKU (example, Vault or Drive) is missing the - pre-requisite SKU (example, G Suite Basic). - - (Developer accounts only) Reseller and resold domain must - meet the following naming requirements: - - - Domain names must start with goog-test. - - Domain names must include the reseller domain. - - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The response will - contain google.protobuf.Empty on success. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Args: - request (Union[google.cloud.channel_v1.types.TransferEntitlementsToGoogleRequest, dict]): - The request object. Request message for - [CloudChannelService.TransferEntitlementsToGoogle][google.cloud.channel.v1.CloudChannelService.TransferEntitlementsToGoogle]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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. - # Minor optimization to avoid making a copy if the user passes - # in a service.TransferEntitlementsToGoogleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.TransferEntitlementsToGoogleRequest): - request = service.TransferEntitlementsToGoogleRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.transfer_entitlements_to_google] - - # 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, - empty_pb2.Empty, - metadata_type=operations.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_channel_partner_links(self, - request: Union[service.ListChannelPartnerLinksRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListChannelPartnerLinksPager: - r"""List - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s - belonging to a distributor. You must be a distributor to call - this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: The list of the distributor account's - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resources. - - Args: - request (Union[google.cloud.channel_v1.types.ListChannelPartnerLinksRequest, dict]): - The request object. Request message for - [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListChannelPartnerLinksPager: - Response message for - [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks]. - - Iterating over this object will yield results and - resolve additional pages automatically. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ListChannelPartnerLinksRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListChannelPartnerLinksRequest): - request = service.ListChannelPartnerLinksRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_channel_partner_links] - - # 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.ListChannelPartnerLinksPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_channel_partner_link(self, - request: Union[service.GetChannelPartnerLinkRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> channel_partner_links.ChannelPartnerLink: - r"""Returns the requested - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. You must be a distributor to call this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: ChannelPartnerLink resource not found because of - an invalid channel partner link name. - - Return value: The - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. - - Args: - request (Union[google.cloud.channel_v1.types.GetChannelPartnerLinkRequest, dict]): - The request object. Request message for - [CloudChannelService.GetChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.GetChannelPartnerLink]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.ChannelPartnerLink: - Entity representing a link between - distributors and their indirect - resellers in an n-tier resale channel. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.GetChannelPartnerLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.GetChannelPartnerLinkRequest): - request = service.GetChannelPartnerLinkRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_channel_partner_link] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_channel_partner_link(self, - request: Union[service.CreateChannelPartnerLinkRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> channel_partner_links.ChannelPartnerLink: - r"""Initiates a channel partner link between a distributor and a - reseller, or between resellers in an n-tier reseller channel. - Invited partners need to follow the invite_link_uri provided in - the response to accept. After accepting the invitation, a link - is set up between the two parties. You must be a distributor to - call this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - ALREADY_EXISTS: The ChannelPartnerLink sent in the request - already exists. - - NOT_FOUND: No Cloud Identity customer exists for provided - domain. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The new - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. - - Args: - request (Union[google.cloud.channel_v1.types.CreateChannelPartnerLinkRequest, dict]): - The request object. Request message for - [CloudChannelService.CreateChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.CreateChannelPartnerLink] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.ChannelPartnerLink: - Entity representing a link between - distributors and their indirect - resellers in an n-tier resale channel. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.CreateChannelPartnerLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.CreateChannelPartnerLinkRequest): - request = service.CreateChannelPartnerLinkRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_channel_partner_link] - - # 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 update_channel_partner_link(self, - request: Union[service.UpdateChannelPartnerLinkRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> channel_partner_links.ChannelPartnerLink: - r"""Updates a channel partner link. Distributors call this method to - change a link's status. For example, to suspend a partner link. - You must be a distributor to call this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: - - - Required request parameters are missing or invalid. - - Link state cannot change from invited to active or - suspended. - - Cannot send reseller_cloud_identity_id, invite_url, or - name in update mask. - - - NOT_FOUND: ChannelPartnerLink resource not found. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The updated - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. - - Args: - request (Union[google.cloud.channel_v1.types.UpdateChannelPartnerLinkRequest, dict]): - The request object. Request message for - [CloudChannelService.UpdateChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.UpdateChannelPartnerLink] - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.ChannelPartnerLink: - Entity representing a link between - distributors and their indirect - resellers in an n-tier resale channel. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.UpdateChannelPartnerLinkRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UpdateChannelPartnerLinkRequest): - request = service.UpdateChannelPartnerLinkRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_channel_partner_link] - - # Certain 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 lookup_offer(self, - request: Union[service.LookupOfferRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> offers.Offer: - r"""Returns the requested [Offer][google.cloud.channel.v1.Offer] - resource. - - Possible error codes: - - - PERMISSION_DENIED: The entitlement doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement or offer was not found. - - Return value: The [Offer][google.cloud.channel.v1.Offer] - resource. - - Args: - request (Union[google.cloud.channel_v1.types.LookupOfferRequest, dict]): - The request object. Request message for LookupOffer. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.Offer: - Represents an offer made to resellers for purchase. - An offer is associated with a - [Sku][google.cloud.channel.v1.Sku], has a plan for - payment, a price, and defines the constraints for - buying. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.LookupOfferRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.LookupOfferRequest): - request = service.LookupOfferRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.lookup_offer] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("entitlement", request.entitlement), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_products(self, - request: Union[service.ListProductsRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListProductsPager: - r"""Lists the Products the reseller is authorized to sell. - - Possible error codes: - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Args: - request (Union[google.cloud.channel_v1.types.ListProductsRequest, dict]): - The request object. Request message for ListProducts. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListProductsPager: - Response message for ListProducts. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ListProductsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListProductsRequest): - request = service.ListProductsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_products] - - # 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.ListProductsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_skus(self, - request: Union[service.ListSkusRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListSkusPager: - r"""Lists the SKUs for a product the reseller is authorized to sell. - - Possible error codes: - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Args: - request (Union[google.cloud.channel_v1.types.ListSkusRequest, dict]): - The request object. Request message for ListSkus. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListSkusPager: - Response message for ListSkus. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ListSkusRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListSkusRequest): - request = service.ListSkusRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_skus] - - # 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.ListSkusPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_offers(self, - request: Union[service.ListOffersRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListOffersPager: - r"""Lists the Offers the reseller can sell. - - Possible error codes: - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Args: - request (Union[google.cloud.channel_v1.types.ListOffersRequest, dict]): - The request object. Request message for ListOffers. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListOffersPager: - Response message for ListOffers. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ListOffersRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListOffersRequest): - request = service.ListOffersRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_offers] - - # 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.ListOffersPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_purchasable_skus(self, - request: Union[service.ListPurchasableSkusRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListPurchasableSkusPager: - r"""Lists the following: - - - SKUs that you can purchase for a customer - - SKUs that you can upgrade or downgrade for an entitlement. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Args: - request (Union[google.cloud.channel_v1.types.ListPurchasableSkusRequest, dict]): - The request object. Request message for - ListPurchasableSkus. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListPurchasableSkusPager: - Response message for - ListPurchasableSkus. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ListPurchasableSkusRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListPurchasableSkusRequest): - request = service.ListPurchasableSkusRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_purchasable_skus] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("customer", request.customer), - )), - ) - - # 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.ListPurchasableSkusPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_purchasable_offers(self, - request: Union[service.ListPurchasableOffersRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListPurchasableOffersPager: - r"""Lists the following: - - - Offers that you can purchase for a customer. - - Offers that you can change for an entitlement. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Args: - request (Union[google.cloud.channel_v1.types.ListPurchasableOffersRequest, dict]): - The request object. Request message for - ListPurchasableOffers. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListPurchasableOffersPager: - Response message for - ListPurchasableOffers. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ListPurchasableOffersRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListPurchasableOffersRequest): - request = service.ListPurchasableOffersRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_purchasable_offers] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("customer", request.customer), - )), - ) - - # 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.ListPurchasableOffersPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def register_subscriber(self, - request: Union[service.RegisterSubscriberRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.RegisterSubscriberResponse: - r"""Registers a service account with subscriber privileges on the - Cloud Pub/Sub topic for this Channel Services account. After you - create a subscriber, you get the events through - [SubscriberEvent][google.cloud.channel.v1.SubscriberEvent] - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request - and the provided reseller account are different, or the - impersonated user is not a super admin. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The topic name with the registered service email - address. - - Args: - request (Union[google.cloud.channel_v1.types.RegisterSubscriberRequest, dict]): - The request object. Request Message for - RegisterSubscriber. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.RegisterSubscriberResponse: - Response Message for - RegisterSubscriber. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.RegisterSubscriberRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.RegisterSubscriberRequest): - request = service.RegisterSubscriberRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.register_subscriber] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("account", request.account), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def unregister_subscriber(self, - request: Union[service.UnregisterSubscriberRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> service.UnregisterSubscriberResponse: - r"""Unregisters a service account with subscriber privileges on the - Cloud Pub/Sub topic created for this Channel Services account. - If there are no service accounts left with subscriber - privileges, this deletes the topic. You can call ListSubscribers - to check for these accounts. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request - and the provided reseller account are different, or the - impersonated user is not a super admin. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The topic resource doesn't exist. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The topic name that unregistered the service email - address. Returns a success response if the service email address - wasn't registered with the topic. - - Args: - request (Union[google.cloud.channel_v1.types.UnregisterSubscriberRequest, dict]): - The request object. Request Message for - UnregisterSubscriber. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.types.UnregisterSubscriberResponse: - Response Message for - UnregisterSubscriber. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.UnregisterSubscriberRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.UnregisterSubscriberRequest): - request = service.UnregisterSubscriberRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.unregister_subscriber] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("account", request.account), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_subscribers(self, - request: Union[service.ListSubscribersRequest, dict] = None, - *, - retry: retries.Retry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListSubscribersPager: - r"""Lists service accounts with subscriber privileges on the Cloud - Pub/Sub topic created for this Channel Services account. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request - and the provided reseller account are different, or the - impersonated user is not a super admin. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The topic resource doesn't exist. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: A list of service email addresses. - - Args: - request (Union[google.cloud.channel_v1.types.ListSubscribersRequest, dict]): - The request object. Request Message for ListSubscribers. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (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.channel_v1.services.cloud_channel_service.pagers.ListSubscribersPager: - Response Message for ListSubscribers. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a service.ListSubscribersRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, service.ListSubscribersRequest): - request = service.ListSubscribersRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_subscribers] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("account", request.account), - )), - ) - - # 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.ListSubscribersPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def __enter__(self): - return self - - def __exit__(self, type, value, traceback): - """Releases underlying transport's resources. - - .. warning:: - ONLY use as a context manager if the transport is NOT shared - with other clients! Exiting the with block will CLOSE the transport - and may cause errors in other clients! - """ - self.transport.close() - - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-channel", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "CloudChannelServiceClient", -) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/pagers.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/pagers.py deleted file mode 100644 index 3aebc96..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/pagers.py +++ /dev/null @@ -1,1365 +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, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator - -from google.cloud.channel_v1.types import channel_partner_links -from google.cloud.channel_v1.types import customers -from google.cloud.channel_v1.types import entitlements -from google.cloud.channel_v1.types import offers -from google.cloud.channel_v1.types import products -from google.cloud.channel_v1.types import service - - -class ListCustomersPager: - """A pager for iterating through ``list_customers`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListCustomersResponse` object, and - provides an ``__iter__`` method to iterate through its - ``customers`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCustomers`` requests and continue to iterate - through the ``customers`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListCustomersResponse` - 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.ListCustomersResponse], - request: service.ListCustomersRequest, - response: service.ListCustomersResponse, - *, - 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.channel_v1.types.ListCustomersRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListCustomersResponse): - 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.ListCustomersRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[service.ListCustomersResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[customers.Customer]: - for page in self.pages: - yield from page.customers - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCustomersAsyncPager: - """A pager for iterating through ``list_customers`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListCustomersResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``customers`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCustomers`` requests and continue to iterate - through the ``customers`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListCustomersResponse` - 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.ListCustomersResponse]], - request: service.ListCustomersRequest, - response: service.ListCustomersResponse, - *, - 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.channel_v1.types.ListCustomersRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListCustomersResponse): - 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.ListCustomersRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[service.ListCustomersResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[customers.Customer]: - async def async_generator(): - async for page in self.pages: - for response in page.customers: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListEntitlementsPager: - """A pager for iterating through ``list_entitlements`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListEntitlementsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``entitlements`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListEntitlements`` requests and continue to iterate - through the ``entitlements`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListEntitlementsResponse` - 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.ListEntitlementsResponse], - request: service.ListEntitlementsRequest, - response: service.ListEntitlementsResponse, - *, - 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.channel_v1.types.ListEntitlementsRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListEntitlementsResponse): - 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.ListEntitlementsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[service.ListEntitlementsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[entitlements.Entitlement]: - for page in self.pages: - yield from page.entitlements - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListEntitlementsAsyncPager: - """A pager for iterating through ``list_entitlements`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListEntitlementsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``entitlements`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListEntitlements`` requests and continue to iterate - through the ``entitlements`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListEntitlementsResponse` - 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.ListEntitlementsResponse]], - request: service.ListEntitlementsRequest, - response: service.ListEntitlementsResponse, - *, - 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.channel_v1.types.ListEntitlementsRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListEntitlementsResponse): - 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.ListEntitlementsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[service.ListEntitlementsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[entitlements.Entitlement]: - async def async_generator(): - async for page in self.pages: - for response in page.entitlements: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTransferableSkusPager: - """A pager for iterating through ``list_transferable_skus`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListTransferableSkusResponse` object, and - provides an ``__iter__`` method to iterate through its - ``transferable_skus`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListTransferableSkus`` requests and continue to iterate - through the ``transferable_skus`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListTransferableSkusResponse` - 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.ListTransferableSkusResponse], - request: service.ListTransferableSkusRequest, - response: service.ListTransferableSkusResponse, - *, - 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.channel_v1.types.ListTransferableSkusRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListTransferableSkusResponse): - 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.ListTransferableSkusRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[service.ListTransferableSkusResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[entitlements.TransferableSku]: - for page in self.pages: - yield from page.transferable_skus - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTransferableSkusAsyncPager: - """A pager for iterating through ``list_transferable_skus`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListTransferableSkusResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``transferable_skus`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListTransferableSkus`` requests and continue to iterate - through the ``transferable_skus`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListTransferableSkusResponse` - 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.ListTransferableSkusResponse]], - request: service.ListTransferableSkusRequest, - response: service.ListTransferableSkusResponse, - *, - 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.channel_v1.types.ListTransferableSkusRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListTransferableSkusResponse): - 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.ListTransferableSkusRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[service.ListTransferableSkusResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[entitlements.TransferableSku]: - async def async_generator(): - async for page in self.pages: - for response in page.transferable_skus: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTransferableOffersPager: - """A pager for iterating through ``list_transferable_offers`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListTransferableOffersResponse` object, and - provides an ``__iter__`` method to iterate through its - ``transferable_offers`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListTransferableOffers`` requests and continue to iterate - through the ``transferable_offers`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListTransferableOffersResponse` - 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.ListTransferableOffersResponse], - request: service.ListTransferableOffersRequest, - response: service.ListTransferableOffersResponse, - *, - 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.channel_v1.types.ListTransferableOffersRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListTransferableOffersResponse): - 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.ListTransferableOffersRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[service.ListTransferableOffersResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[service.TransferableOffer]: - for page in self.pages: - yield from page.transferable_offers - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTransferableOffersAsyncPager: - """A pager for iterating through ``list_transferable_offers`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListTransferableOffersResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``transferable_offers`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListTransferableOffers`` requests and continue to iterate - through the ``transferable_offers`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListTransferableOffersResponse` - 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.ListTransferableOffersResponse]], - request: service.ListTransferableOffersRequest, - response: service.ListTransferableOffersResponse, - *, - 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.channel_v1.types.ListTransferableOffersRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListTransferableOffersResponse): - 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.ListTransferableOffersRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[service.ListTransferableOffersResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[service.TransferableOffer]: - async def async_generator(): - async for page in self.pages: - for response in page.transferable_offers: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListChannelPartnerLinksPager: - """A pager for iterating through ``list_channel_partner_links`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListChannelPartnerLinksResponse` object, and - provides an ``__iter__`` method to iterate through its - ``channel_partner_links`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListChannelPartnerLinks`` requests and continue to iterate - through the ``channel_partner_links`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListChannelPartnerLinksResponse` - 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.ListChannelPartnerLinksResponse], - request: service.ListChannelPartnerLinksRequest, - response: service.ListChannelPartnerLinksResponse, - *, - 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.channel_v1.types.ListChannelPartnerLinksRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListChannelPartnerLinksResponse): - 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.ListChannelPartnerLinksRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[service.ListChannelPartnerLinksResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[channel_partner_links.ChannelPartnerLink]: - for page in self.pages: - yield from page.channel_partner_links - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListChannelPartnerLinksAsyncPager: - """A pager for iterating through ``list_channel_partner_links`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListChannelPartnerLinksResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``channel_partner_links`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListChannelPartnerLinks`` requests and continue to iterate - through the ``channel_partner_links`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListChannelPartnerLinksResponse` - 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.ListChannelPartnerLinksResponse]], - request: service.ListChannelPartnerLinksRequest, - response: service.ListChannelPartnerLinksResponse, - *, - 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.channel_v1.types.ListChannelPartnerLinksRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListChannelPartnerLinksResponse): - 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.ListChannelPartnerLinksRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[service.ListChannelPartnerLinksResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[channel_partner_links.ChannelPartnerLink]: - async def async_generator(): - async for page in self.pages: - for response in page.channel_partner_links: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListProductsPager: - """A pager for iterating through ``list_products`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListProductsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``products`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListProducts`` requests and continue to iterate - through the ``products`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListProductsResponse` - 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.ListProductsResponse], - request: service.ListProductsRequest, - response: service.ListProductsResponse, - *, - 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.channel_v1.types.ListProductsRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListProductsResponse): - 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.ListProductsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[service.ListProductsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[products.Product]: - for page in self.pages: - yield from page.products - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListProductsAsyncPager: - """A pager for iterating through ``list_products`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListProductsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``products`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListProducts`` requests and continue to iterate - through the ``products`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListProductsResponse` - 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.ListProductsResponse]], - request: service.ListProductsRequest, - response: service.ListProductsResponse, - *, - 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.channel_v1.types.ListProductsRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListProductsResponse): - 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.ListProductsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[service.ListProductsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[products.Product]: - async def async_generator(): - async for page in self.pages: - for response in page.products: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListSkusPager: - """A pager for iterating through ``list_skus`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListSkusResponse` object, and - provides an ``__iter__`` method to iterate through its - ``skus`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListSkus`` requests and continue to iterate - through the ``skus`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListSkusResponse` - 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.ListSkusResponse], - request: service.ListSkusRequest, - response: service.ListSkusResponse, - *, - 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.channel_v1.types.ListSkusRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListSkusResponse): - 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.ListSkusRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[service.ListSkusResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[products.Sku]: - for page in self.pages: - yield from page.skus - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListSkusAsyncPager: - """A pager for iterating through ``list_skus`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListSkusResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``skus`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListSkus`` requests and continue to iterate - through the ``skus`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListSkusResponse` - 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.ListSkusResponse]], - request: service.ListSkusRequest, - response: service.ListSkusResponse, - *, - 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.channel_v1.types.ListSkusRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListSkusResponse): - 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.ListSkusRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[service.ListSkusResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[products.Sku]: - async def async_generator(): - async for page in self.pages: - for response in page.skus: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListOffersPager: - """A pager for iterating through ``list_offers`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListOffersResponse` object, and - provides an ``__iter__`` method to iterate through its - ``offers`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListOffers`` requests and continue to iterate - through the ``offers`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListOffersResponse` - 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.ListOffersResponse], - request: service.ListOffersRequest, - response: service.ListOffersResponse, - *, - 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.channel_v1.types.ListOffersRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListOffersResponse): - 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.ListOffersRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[service.ListOffersResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[offers.Offer]: - for page in self.pages: - yield from page.offers - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListOffersAsyncPager: - """A pager for iterating through ``list_offers`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListOffersResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``offers`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListOffers`` requests and continue to iterate - through the ``offers`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListOffersResponse` - 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.ListOffersResponse]], - request: service.ListOffersRequest, - response: service.ListOffersResponse, - *, - 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.channel_v1.types.ListOffersRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListOffersResponse): - 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.ListOffersRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[service.ListOffersResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[offers.Offer]: - async def async_generator(): - async for page in self.pages: - for response in page.offers: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPurchasableSkusPager: - """A pager for iterating through ``list_purchasable_skus`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListPurchasableSkusResponse` object, and - provides an ``__iter__`` method to iterate through its - ``purchasable_skus`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListPurchasableSkus`` requests and continue to iterate - through the ``purchasable_skus`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListPurchasableSkusResponse` - 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.ListPurchasableSkusResponse], - request: service.ListPurchasableSkusRequest, - response: service.ListPurchasableSkusResponse, - *, - 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.channel_v1.types.ListPurchasableSkusRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListPurchasableSkusResponse): - 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.ListPurchasableSkusRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[service.ListPurchasableSkusResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[service.PurchasableSku]: - for page in self.pages: - yield from page.purchasable_skus - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPurchasableSkusAsyncPager: - """A pager for iterating through ``list_purchasable_skus`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListPurchasableSkusResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``purchasable_skus`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListPurchasableSkus`` requests and continue to iterate - through the ``purchasable_skus`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListPurchasableSkusResponse` - 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.ListPurchasableSkusResponse]], - request: service.ListPurchasableSkusRequest, - response: service.ListPurchasableSkusResponse, - *, - 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.channel_v1.types.ListPurchasableSkusRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListPurchasableSkusResponse): - 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.ListPurchasableSkusRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[service.ListPurchasableSkusResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[service.PurchasableSku]: - async def async_generator(): - async for page in self.pages: - for response in page.purchasable_skus: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPurchasableOffersPager: - """A pager for iterating through ``list_purchasable_offers`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListPurchasableOffersResponse` object, and - provides an ``__iter__`` method to iterate through its - ``purchasable_offers`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListPurchasableOffers`` requests and continue to iterate - through the ``purchasable_offers`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListPurchasableOffersResponse` - 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.ListPurchasableOffersResponse], - request: service.ListPurchasableOffersRequest, - response: service.ListPurchasableOffersResponse, - *, - 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.channel_v1.types.ListPurchasableOffersRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListPurchasableOffersResponse): - 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.ListPurchasableOffersRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[service.ListPurchasableOffersResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[service.PurchasableOffer]: - for page in self.pages: - yield from page.purchasable_offers - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPurchasableOffersAsyncPager: - """A pager for iterating through ``list_purchasable_offers`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListPurchasableOffersResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``purchasable_offers`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListPurchasableOffers`` requests and continue to iterate - through the ``purchasable_offers`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListPurchasableOffersResponse` - 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.ListPurchasableOffersResponse]], - request: service.ListPurchasableOffersRequest, - response: service.ListPurchasableOffersResponse, - *, - 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.channel_v1.types.ListPurchasableOffersRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListPurchasableOffersResponse): - 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.ListPurchasableOffersRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[service.ListPurchasableOffersResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[service.PurchasableOffer]: - async def async_generator(): - async for page in self.pages: - for response in page.purchasable_offers: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListSubscribersPager: - """A pager for iterating through ``list_subscribers`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListSubscribersResponse` object, and - provides an ``__iter__`` method to iterate through its - ``service_accounts`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListSubscribers`` requests and continue to iterate - through the ``service_accounts`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListSubscribersResponse` - 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.ListSubscribersResponse], - request: service.ListSubscribersRequest, - response: service.ListSubscribersResponse, - *, - 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.channel_v1.types.ListSubscribersRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListSubscribersResponse): - 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.ListSubscribersRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[service.ListSubscribersResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[str]: - for page in self.pages: - yield from page.service_accounts - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListSubscribersAsyncPager: - """A pager for iterating through ``list_subscribers`` requests. - - This class thinly wraps an initial - :class:`google.cloud.channel_v1.types.ListSubscribersResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``service_accounts`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListSubscribers`` requests and continue to iterate - through the ``service_accounts`` field on the - corresponding responses. - - All the usual :class:`google.cloud.channel_v1.types.ListSubscribersResponse` - 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.ListSubscribersResponse]], - request: service.ListSubscribersRequest, - response: service.ListSubscribersResponse, - *, - 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.channel_v1.types.ListSubscribersRequest): - The initial request object. - response (google.cloud.channel_v1.types.ListSubscribersResponse): - 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.ListSubscribersRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[service.ListSubscribersResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[str]: - async def async_generator(): - async for page in self.pages: - for response in page.service_accounts: - 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/channel_v1/services/cloud_channel_service/transports/__init__.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/__init__.py deleted file mode 100644 index 7fd5b80..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_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 CloudChannelServiceTransport -from .grpc import CloudChannelServiceGrpcTransport -from .grpc_asyncio import CloudChannelServiceGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[CloudChannelServiceTransport]] -_transport_registry['grpc'] = CloudChannelServiceGrpcTransport -_transport_registry['grpc_asyncio'] = CloudChannelServiceGrpcAsyncIOTransport - -__all__ = ( - 'CloudChannelServiceTransport', - 'CloudChannelServiceGrpcTransport', - 'CloudChannelServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/base.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/base.py deleted file mode 100644 index a1dd62c..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/base.py +++ /dev/null @@ -1,665 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version -import pkg_resources - -import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.channel_v1.types import channel_partner_links -from google.cloud.channel_v1.types import customers -from google.cloud.channel_v1.types import entitlements -from google.cloud.channel_v1.types import offers -from google.cloud.channel_v1.types import service -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-cloud-channel', - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - - -class CloudChannelServiceTransport(abc.ABC): - """Abstract transport class for CloudChannelService.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/apps.order', - ) - - DEFAULT_HOST: str = 'cloudchannel.googleapis.com' - def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - """ - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' - self._host = host - - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) - - # Save the scopes. - self._scopes = scopes - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") - - if credentials_file is not None: - credentials, _ = google.auth.load_credentials_from_file( - credentials_file, - **scopes_kwargs, - quota_project_id=quota_project_id - ) - - elif credentials is None: - credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) - - # If the credentials are service account credentials, then always try to use self signed JWT. - if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): - credentials = credentials.with_always_use_jwt_access(True) - - # Save the credentials. - self._credentials = credentials - - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.list_customers: gapic_v1.method.wrap_method( - self.list_customers, - default_timeout=None, - client_info=client_info, - ), - self.get_customer: gapic_v1.method.wrap_method( - self.get_customer, - default_timeout=None, - client_info=client_info, - ), - self.check_cloud_identity_accounts_exist: gapic_v1.method.wrap_method( - self.check_cloud_identity_accounts_exist, - default_timeout=None, - client_info=client_info, - ), - self.create_customer: gapic_v1.method.wrap_method( - self.create_customer, - default_timeout=None, - client_info=client_info, - ), - self.update_customer: gapic_v1.method.wrap_method( - self.update_customer, - default_timeout=None, - client_info=client_info, - ), - self.delete_customer: gapic_v1.method.wrap_method( - self.delete_customer, - default_timeout=None, - client_info=client_info, - ), - self.import_customer: gapic_v1.method.wrap_method( - self.import_customer, - default_timeout=None, - client_info=client_info, - ), - self.provision_cloud_identity: gapic_v1.method.wrap_method( - self.provision_cloud_identity, - default_timeout=60.0, - client_info=client_info, - ), - self.list_entitlements: gapic_v1.method.wrap_method( - self.list_entitlements, - default_timeout=None, - client_info=client_info, - ), - self.list_transferable_skus: gapic_v1.method.wrap_method( - self.list_transferable_skus, - default_timeout=None, - client_info=client_info, - ), - self.list_transferable_offers: gapic_v1.method.wrap_method( - self.list_transferable_offers, - default_timeout=None, - client_info=client_info, - ), - self.get_entitlement: gapic_v1.method.wrap_method( - self.get_entitlement, - default_timeout=None, - client_info=client_info, - ), - self.create_entitlement: gapic_v1.method.wrap_method( - self.create_entitlement, - default_timeout=60.0, - client_info=client_info, - ), - self.change_parameters: gapic_v1.method.wrap_method( - self.change_parameters, - default_timeout=60.0, - client_info=client_info, - ), - self.change_renewal_settings: gapic_v1.method.wrap_method( - self.change_renewal_settings, - default_timeout=60.0, - client_info=client_info, - ), - self.change_offer: gapic_v1.method.wrap_method( - self.change_offer, - default_timeout=60.0, - client_info=client_info, - ), - self.start_paid_service: gapic_v1.method.wrap_method( - self.start_paid_service, - default_timeout=60.0, - client_info=client_info, - ), - self.suspend_entitlement: gapic_v1.method.wrap_method( - self.suspend_entitlement, - default_timeout=60.0, - client_info=client_info, - ), - self.cancel_entitlement: gapic_v1.method.wrap_method( - self.cancel_entitlement, - default_timeout=60.0, - client_info=client_info, - ), - self.activate_entitlement: gapic_v1.method.wrap_method( - self.activate_entitlement, - default_timeout=60.0, - client_info=client_info, - ), - self.transfer_entitlements: gapic_v1.method.wrap_method( - self.transfer_entitlements, - default_timeout=60.0, - client_info=client_info, - ), - self.transfer_entitlements_to_google: gapic_v1.method.wrap_method( - self.transfer_entitlements_to_google, - default_timeout=60.0, - client_info=client_info, - ), - self.list_channel_partner_links: gapic_v1.method.wrap_method( - self.list_channel_partner_links, - default_timeout=None, - client_info=client_info, - ), - self.get_channel_partner_link: gapic_v1.method.wrap_method( - self.get_channel_partner_link, - default_timeout=None, - client_info=client_info, - ), - self.create_channel_partner_link: gapic_v1.method.wrap_method( - self.create_channel_partner_link, - default_timeout=None, - client_info=client_info, - ), - self.update_channel_partner_link: gapic_v1.method.wrap_method( - self.update_channel_partner_link, - default_timeout=None, - client_info=client_info, - ), - self.lookup_offer: gapic_v1.method.wrap_method( - self.lookup_offer, - default_timeout=None, - client_info=client_info, - ), - self.list_products: gapic_v1.method.wrap_method( - self.list_products, - default_timeout=None, - client_info=client_info, - ), - self.list_skus: gapic_v1.method.wrap_method( - self.list_skus, - default_timeout=None, - client_info=client_info, - ), - self.list_offers: gapic_v1.method.wrap_method( - self.list_offers, - default_timeout=None, - client_info=client_info, - ), - self.list_purchasable_skus: gapic_v1.method.wrap_method( - self.list_purchasable_skus, - default_timeout=None, - client_info=client_info, - ), - self.list_purchasable_offers: gapic_v1.method.wrap_method( - self.list_purchasable_offers, - default_timeout=None, - client_info=client_info, - ), - self.register_subscriber: gapic_v1.method.wrap_method( - self.register_subscriber, - default_timeout=None, - client_info=client_info, - ), - self.unregister_subscriber: gapic_v1.method.wrap_method( - self.unregister_subscriber, - default_timeout=None, - client_info=client_info, - ), - self.list_subscribers: gapic_v1.method.wrap_method( - self.list_subscribers, - default_timeout=None, - client_info=client_info, - ), - } - - def close(self): - """Closes resources associated with the transport. - - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! - """ - raise NotImplementedError() - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def list_customers(self) -> Callable[ - [service.ListCustomersRequest], - Union[ - service.ListCustomersResponse, - Awaitable[service.ListCustomersResponse] - ]]: - raise NotImplementedError() - - @property - def get_customer(self) -> Callable[ - [service.GetCustomerRequest], - Union[ - customers.Customer, - Awaitable[customers.Customer] - ]]: - raise NotImplementedError() - - @property - def check_cloud_identity_accounts_exist(self) -> Callable[ - [service.CheckCloudIdentityAccountsExistRequest], - Union[ - service.CheckCloudIdentityAccountsExistResponse, - Awaitable[service.CheckCloudIdentityAccountsExistResponse] - ]]: - raise NotImplementedError() - - @property - def create_customer(self) -> Callable[ - [service.CreateCustomerRequest], - Union[ - customers.Customer, - Awaitable[customers.Customer] - ]]: - raise NotImplementedError() - - @property - def update_customer(self) -> Callable[ - [service.UpdateCustomerRequest], - Union[ - customers.Customer, - Awaitable[customers.Customer] - ]]: - raise NotImplementedError() - - @property - def delete_customer(self) -> Callable[ - [service.DeleteCustomerRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def import_customer(self) -> Callable[ - [service.ImportCustomerRequest], - Union[ - customers.Customer, - Awaitable[customers.Customer] - ]]: - raise NotImplementedError() - - @property - def provision_cloud_identity(self) -> Callable[ - [service.ProvisionCloudIdentityRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_entitlements(self) -> Callable[ - [service.ListEntitlementsRequest], - Union[ - service.ListEntitlementsResponse, - Awaitable[service.ListEntitlementsResponse] - ]]: - raise NotImplementedError() - - @property - def list_transferable_skus(self) -> Callable[ - [service.ListTransferableSkusRequest], - Union[ - service.ListTransferableSkusResponse, - Awaitable[service.ListTransferableSkusResponse] - ]]: - raise NotImplementedError() - - @property - def list_transferable_offers(self) -> Callable[ - [service.ListTransferableOffersRequest], - Union[ - service.ListTransferableOffersResponse, - Awaitable[service.ListTransferableOffersResponse] - ]]: - raise NotImplementedError() - - @property - def get_entitlement(self) -> Callable[ - [service.GetEntitlementRequest], - Union[ - entitlements.Entitlement, - Awaitable[entitlements.Entitlement] - ]]: - raise NotImplementedError() - - @property - def create_entitlement(self) -> Callable[ - [service.CreateEntitlementRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def change_parameters(self) -> Callable[ - [service.ChangeParametersRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def change_renewal_settings(self) -> Callable[ - [service.ChangeRenewalSettingsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def change_offer(self) -> Callable[ - [service.ChangeOfferRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def start_paid_service(self) -> Callable[ - [service.StartPaidServiceRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def suspend_entitlement(self) -> Callable[ - [service.SuspendEntitlementRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def cancel_entitlement(self) -> Callable[ - [service.CancelEntitlementRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def activate_entitlement(self) -> Callable[ - [service.ActivateEntitlementRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def transfer_entitlements(self) -> Callable[ - [service.TransferEntitlementsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def transfer_entitlements_to_google(self) -> Callable[ - [service.TransferEntitlementsToGoogleRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_channel_partner_links(self) -> Callable[ - [service.ListChannelPartnerLinksRequest], - Union[ - service.ListChannelPartnerLinksResponse, - Awaitable[service.ListChannelPartnerLinksResponse] - ]]: - raise NotImplementedError() - - @property - def get_channel_partner_link(self) -> Callable[ - [service.GetChannelPartnerLinkRequest], - Union[ - channel_partner_links.ChannelPartnerLink, - Awaitable[channel_partner_links.ChannelPartnerLink] - ]]: - raise NotImplementedError() - - @property - def create_channel_partner_link(self) -> Callable[ - [service.CreateChannelPartnerLinkRequest], - Union[ - channel_partner_links.ChannelPartnerLink, - Awaitable[channel_partner_links.ChannelPartnerLink] - ]]: - raise NotImplementedError() - - @property - def update_channel_partner_link(self) -> Callable[ - [service.UpdateChannelPartnerLinkRequest], - Union[ - channel_partner_links.ChannelPartnerLink, - Awaitable[channel_partner_links.ChannelPartnerLink] - ]]: - raise NotImplementedError() - - @property - def lookup_offer(self) -> Callable[ - [service.LookupOfferRequest], - Union[ - offers.Offer, - Awaitable[offers.Offer] - ]]: - raise NotImplementedError() - - @property - def list_products(self) -> Callable[ - [service.ListProductsRequest], - Union[ - service.ListProductsResponse, - Awaitable[service.ListProductsResponse] - ]]: - raise NotImplementedError() - - @property - def list_skus(self) -> Callable[ - [service.ListSkusRequest], - Union[ - service.ListSkusResponse, - Awaitable[service.ListSkusResponse] - ]]: - raise NotImplementedError() - - @property - def list_offers(self) -> Callable[ - [service.ListOffersRequest], - Union[ - service.ListOffersResponse, - Awaitable[service.ListOffersResponse] - ]]: - raise NotImplementedError() - - @property - def list_purchasable_skus(self) -> Callable[ - [service.ListPurchasableSkusRequest], - Union[ - service.ListPurchasableSkusResponse, - Awaitable[service.ListPurchasableSkusResponse] - ]]: - raise NotImplementedError() - - @property - def list_purchasable_offers(self) -> Callable[ - [service.ListPurchasableOffersRequest], - Union[ - service.ListPurchasableOffersResponse, - Awaitable[service.ListPurchasableOffersResponse] - ]]: - raise NotImplementedError() - - @property - def register_subscriber(self) -> Callable[ - [service.RegisterSubscriberRequest], - Union[ - service.RegisterSubscriberResponse, - Awaitable[service.RegisterSubscriberResponse] - ]]: - raise NotImplementedError() - - @property - def unregister_subscriber(self) -> Callable[ - [service.UnregisterSubscriberRequest], - Union[ - service.UnregisterSubscriberResponse, - Awaitable[service.UnregisterSubscriberResponse] - ]]: - raise NotImplementedError() - - @property - def list_subscribers(self) -> Callable[ - [service.ListSubscribersRequest], - Union[ - service.ListSubscribersResponse, - Awaitable[service.ListSubscribersResponse] - ]]: - raise NotImplementedError() - - -__all__ = ( - 'CloudChannelServiceTransport', -) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc.py deleted file mode 100644 index 6c9c7e8..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc.py +++ /dev/null @@ -1,1841 +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.channel_v1.types import channel_partner_links -from google.cloud.channel_v1.types import customers -from google.cloud.channel_v1.types import entitlements -from google.cloud.channel_v1.types import offers -from google.cloud.channel_v1.types import service -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import CloudChannelServiceTransport, DEFAULT_CLIENT_INFO - - -class CloudChannelServiceGrpcTransport(CloudChannelServiceTransport): - """gRPC backend transport for CloudChannelService. - - CloudChannelService lets Google cloud resellers and distributors - manage their customers, channel partners, entitlements, and reports. - - Using this service: - - 1. Resellers and distributors can manage a customer entity. - 2. Distributors can register an authorized reseller in their channel - and provide them with delegated admin access. - 3. Resellers and distributors can manage customer entitlements. - - CloudChannelService exposes the following resources: - - - [Customer][google.cloud.channel.v1.Customer]s: An entity—usually - an enterprise—managed by a reseller or distributor. - - - [Entitlement][google.cloud.channel.v1.Entitlement]s: An entity - that provides a customer with the means to use a service. - Entitlements are created or updated as a result of a successful - fulfillment. - - - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s: - An entity that identifies links between distributors and their - indirect resellers in a channel. - - 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 = 'cloudchannel.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, - always_use_jwt_access: Optional[bool] = False, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - ) - - 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 = 'cloudchannel.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def list_customers(self) -> Callable[ - [service.ListCustomersRequest], - service.ListCustomersResponse]: - r"""Return a callable for the list customers method over gRPC. - - List [Customer][google.cloud.channel.v1.Customer]s. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: List of - [Customer][google.cloud.channel.v1.Customer]s, or an empty list - if there are no customers. - - Returns: - Callable[[~.ListCustomersRequest], - ~.ListCustomersResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_customers' not in self._stubs: - self._stubs['list_customers'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListCustomers', - request_serializer=service.ListCustomersRequest.serialize, - response_deserializer=service.ListCustomersResponse.deserialize, - ) - return self._stubs['list_customers'] - - @property - def get_customer(self) -> Callable[ - [service.GetCustomerRequest], - customers.Customer]: - r"""Return a callable for the get customer method over gRPC. - - Returns the requested - [Customer][google.cloud.channel.v1.Customer] resource. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer resource doesn't exist. Usually the - result of an invalid name parameter. - - Return value: The [Customer][google.cloud.channel.v1.Customer] - resource. - - Returns: - Callable[[~.GetCustomerRequest], - ~.Customer]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_customer' not in self._stubs: - self._stubs['get_customer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/GetCustomer', - request_serializer=service.GetCustomerRequest.serialize, - response_deserializer=customers.Customer.deserialize, - ) - return self._stubs['get_customer'] - - @property - def check_cloud_identity_accounts_exist(self) -> Callable[ - [service.CheckCloudIdentityAccountsExistRequest], - service.CheckCloudIdentityAccountsExistResponse]: - r"""Return a callable for the check cloud identity accounts - exist method over gRPC. - - Confirms the existence of Cloud Identity accounts based on the - domain and if the Cloud Identity accounts are owned by the - reseller. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - INVALID_VALUE: Invalid domain value in the request. - - Return value: A list of - [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] - resources for the domain (may be empty) - - Note: in the v1alpha1 version of the API, a NOT_FOUND error - returns if no - [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] - resources match the domain. - - Returns: - Callable[[~.CheckCloudIdentityAccountsExistRequest], - ~.CheckCloudIdentityAccountsExistResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'check_cloud_identity_accounts_exist' not in self._stubs: - self._stubs['check_cloud_identity_accounts_exist'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/CheckCloudIdentityAccountsExist', - request_serializer=service.CheckCloudIdentityAccountsExistRequest.serialize, - response_deserializer=service.CheckCloudIdentityAccountsExistResponse.deserialize, - ) - return self._stubs['check_cloud_identity_accounts_exist'] - - @property - def create_customer(self) -> Callable[ - [service.CreateCustomerRequest], - customers.Customer]: - r"""Return a callable for the create customer method over gRPC. - - Creates a new [Customer][google.cloud.channel.v1.Customer] - resource under the reseller or distributor account. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: - - - Required request parameters are missing or invalid. - - Domain field value doesn't match the primary email domain. - - Return value: The newly created - [Customer][google.cloud.channel.v1.Customer] resource. - - Returns: - Callable[[~.CreateCustomerRequest], - ~.Customer]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_customer' not in self._stubs: - self._stubs['create_customer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/CreateCustomer', - request_serializer=service.CreateCustomerRequest.serialize, - response_deserializer=customers.Customer.deserialize, - ) - return self._stubs['create_customer'] - - @property - def update_customer(self) -> Callable[ - [service.UpdateCustomerRequest], - customers.Customer]: - r"""Return a callable for the update customer method over gRPC. - - Updates an existing [Customer][google.cloud.channel.v1.Customer] - resource for the reseller or distributor. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] - resource found for the name in the request. - - Return value: The updated - [Customer][google.cloud.channel.v1.Customer] resource. - - Returns: - Callable[[~.UpdateCustomerRequest], - ~.Customer]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_customer' not in self._stubs: - self._stubs['update_customer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/UpdateCustomer', - request_serializer=service.UpdateCustomerRequest.serialize, - response_deserializer=customers.Customer.deserialize, - ) - return self._stubs['update_customer'] - - @property - def delete_customer(self) -> Callable[ - [service.DeleteCustomerRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete customer method over gRPC. - - Deletes the given [Customer][google.cloud.channel.v1.Customer] - permanently. - - Possible error codes: - - - PERMISSION_DENIED: The account making the request does not - own this customer. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - FAILED_PRECONDITION: The customer has existing entitlements. - - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] - resource found for the name in the request. - - Returns: - Callable[[~.DeleteCustomerRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_customer' not in self._stubs: - self._stubs['delete_customer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/DeleteCustomer', - request_serializer=service.DeleteCustomerRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_customer'] - - @property - def import_customer(self) -> Callable[ - [service.ImportCustomerRequest], - customers.Customer]: - r"""Return a callable for the import customer method over gRPC. - - Imports a [Customer][google.cloud.channel.v1.Customer] from the - Cloud Identity associated with the provided Cloud Identity ID or - domain before a TransferEntitlements call. If a linked Customer - already exists and overwrite_if_exists is true, it will update - that Customer's data. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - NOT_FOUND: Cloud Identity doesn't exist or was deleted. - - INVALID_ARGUMENT: Required parameters are missing, or the - auth_token is expired or invalid. - - ALREADY_EXISTS: A customer already exists and has conflicting - critical fields. Requires an overwrite. - - Return value: The [Customer][google.cloud.channel.v1.Customer]. - - Returns: - Callable[[~.ImportCustomerRequest], - ~.Customer]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'import_customer' not in self._stubs: - self._stubs['import_customer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ImportCustomer', - request_serializer=service.ImportCustomerRequest.serialize, - response_deserializer=customers.Customer.deserialize, - ) - return self._stubs['import_customer'] - - @property - def provision_cloud_identity(self) -> Callable[ - [service.ProvisionCloudIdentityRequest], - operations_pb2.Operation]: - r"""Return a callable for the provision cloud identity method over gRPC. - - Creates a Cloud Identity for the given customer using the - customer's information, or the information provided here. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer was not found. - - ALREADY_EXISTS: The customer's primary email already exists. - Retry after changing the customer's primary contact email. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - contains an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.ProvisionCloudIdentityRequest], - ~.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 'provision_cloud_identity' not in self._stubs: - self._stubs['provision_cloud_identity'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ProvisionCloudIdentity', - request_serializer=service.ProvisionCloudIdentityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['provision_cloud_identity'] - - @property - def list_entitlements(self) -> Callable[ - [service.ListEntitlementsRequest], - service.ListEntitlementsResponse]: - r"""Return a callable for the list entitlements method over gRPC. - - Lists [Entitlement][google.cloud.channel.v1.Entitlement]s - belonging to a customer. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: A list of the customer's - [Entitlement][google.cloud.channel.v1.Entitlement]s. - - Returns: - Callable[[~.ListEntitlementsRequest], - ~.ListEntitlementsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_entitlements' not in self._stubs: - self._stubs['list_entitlements'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListEntitlements', - request_serializer=service.ListEntitlementsRequest.serialize, - response_deserializer=service.ListEntitlementsResponse.deserialize, - ) - return self._stubs['list_entitlements'] - - @property - def list_transferable_skus(self) -> Callable[ - [service.ListTransferableSkusRequest], - service.ListTransferableSkusResponse]: - r"""Return a callable for the list transferable skus method over gRPC. - - List [TransferableSku][google.cloud.channel.v1.TransferableSku]s - of a customer based on the Cloud Identity ID or Customer Name in - the request. - - Use this method to list the entitlements information of an - unowned customer. You should provide the customer's Cloud - Identity ID or Customer Name. - - Possible error codes: - - - PERMISSION_DENIED: - - - The customer doesn't belong to the reseller and has no - auth token. - - The supplied auth token is invalid. - - The reseller account making the request is different from - the reseller account in the query. - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: A list of the customer's - [TransferableSku][google.cloud.channel.v1.TransferableSku]. - - Returns: - Callable[[~.ListTransferableSkusRequest], - ~.ListTransferableSkusResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_transferable_skus' not in self._stubs: - self._stubs['list_transferable_skus'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListTransferableSkus', - request_serializer=service.ListTransferableSkusRequest.serialize, - response_deserializer=service.ListTransferableSkusResponse.deserialize, - ) - return self._stubs['list_transferable_skus'] - - @property - def list_transferable_offers(self) -> Callable[ - [service.ListTransferableOffersRequest], - service.ListTransferableOffersResponse]: - r"""Return a callable for the list transferable offers method over gRPC. - - List - [TransferableOffer][google.cloud.channel.v1.TransferableOffer]s - of a customer based on Cloud Identity ID or Customer Name in the - request. - - Use this method when a reseller gets the entitlement information - of an unowned customer. The reseller should provide the - customer's Cloud Identity ID or Customer Name. - - Possible error codes: - - - PERMISSION_DENIED: - - - The customer doesn't belong to the reseller and has no - auth token. - - The supplied auth token is invalid. - - The reseller account making the request is different from - the reseller account in the query. - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: List of - [TransferableOffer][google.cloud.channel.v1.TransferableOffer] - for the given customer and SKU. - - Returns: - Callable[[~.ListTransferableOffersRequest], - ~.ListTransferableOffersResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_transferable_offers' not in self._stubs: - self._stubs['list_transferable_offers'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListTransferableOffers', - request_serializer=service.ListTransferableOffersRequest.serialize, - response_deserializer=service.ListTransferableOffersResponse.deserialize, - ) - return self._stubs['list_transferable_offers'] - - @property - def get_entitlement(self) -> Callable[ - [service.GetEntitlementRequest], - entitlements.Entitlement]: - r"""Return a callable for the get entitlement method over gRPC. - - Returns the requested - [Entitlement][google.cloud.channel.v1.Entitlement] resource. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer entitlement was not found. - - Return value: The requested - [Entitlement][google.cloud.channel.v1.Entitlement] resource. - - Returns: - Callable[[~.GetEntitlementRequest], - ~.Entitlement]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_entitlement' not in self._stubs: - self._stubs['get_entitlement'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/GetEntitlement', - request_serializer=service.GetEntitlementRequest.serialize, - response_deserializer=entitlements.Entitlement.deserialize, - ) - return self._stubs['get_entitlement'] - - @property - def create_entitlement(self) -> Callable[ - [service.CreateEntitlementRequest], - operations_pb2.Operation]: - r"""Return a callable for the create entitlement method over gRPC. - - Creates an entitlement for a customer. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: - - - Required request parameters are missing or invalid. - - There is already a customer entitlement for a SKU from the - same product family. - - - INVALID_VALUE: Make sure the OfferId is valid. If it is, - contact Google Channel support for further troubleshooting. - - NOT_FOUND: The customer or offer resource was not found. - - ALREADY_EXISTS: - - - The SKU was already purchased for the customer. - - The customer's primary email already exists. Retry after - changing the customer's primary contact email. - - - CONDITION_NOT_MET or FAILED_PRECONDITION: - - - The domain required for purchasing a SKU has not been - verified. - - A pre-requisite SKU required to purchase an Add-On SKU is - missing. For example, Google Workspace Business Starter is - required to purchase Vault or Drive. - - (Developer accounts only) Reseller and resold domain must - meet the following naming requirements: - - - Domain names must start with goog-test. - - Domain names must include the reseller domain. - - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.CreateEntitlementRequest], - ~.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_entitlement' not in self._stubs: - self._stubs['create_entitlement'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/CreateEntitlement', - request_serializer=service.CreateEntitlementRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_entitlement'] - - @property - def change_parameters(self) -> Callable[ - [service.ChangeParametersRequest], - operations_pb2.Operation]: - r"""Return a callable for the change parameters method over gRPC. - - Change parameters of the entitlement. - - An entitlement update is a long-running operation and it updates - the entitlement as a result of fulfillment. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. For example, the number of seats being changed is - greater than the allowed number of max seats, or decreasing - seats for a commitment based plan. - - NOT_FOUND: Entitlement resource not found. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.ChangeParametersRequest], - ~.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 'change_parameters' not in self._stubs: - self._stubs['change_parameters'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ChangeParameters', - request_serializer=service.ChangeParametersRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['change_parameters'] - - @property - def change_renewal_settings(self) -> Callable[ - [service.ChangeRenewalSettingsRequest], - operations_pb2.Operation]: - r"""Return a callable for the change renewal settings method over gRPC. - - Updates the renewal settings for an existing customer - entitlement. - - An entitlement update is a long-running operation and it updates - the entitlement as a result of fulfillment. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - NOT_COMMITMENT_PLAN: Renewal Settings are only applicable for - a commitment plan. Can't enable or disable renewals for - non-commitment plans. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.ChangeRenewalSettingsRequest], - ~.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 'change_renewal_settings' not in self._stubs: - self._stubs['change_renewal_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ChangeRenewalSettings', - request_serializer=service.ChangeRenewalSettingsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['change_renewal_settings'] - - @property - def change_offer(self) -> Callable[ - [service.ChangeOfferRequest], - operations_pb2.Operation]: - r"""Return a callable for the change offer method over gRPC. - - Updates the Offer for an existing customer entitlement. - - An entitlement update is a long-running operation and it updates - the entitlement as a result of fulfillment. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Offer or Entitlement resource not found. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.ChangeOfferRequest], - ~.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 'change_offer' not in self._stubs: - self._stubs['change_offer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ChangeOffer', - request_serializer=service.ChangeOfferRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['change_offer'] - - @property - def start_paid_service(self) -> Callable[ - [service.StartPaidServiceRequest], - operations_pb2.Operation]: - r"""Return a callable for the start paid service method over gRPC. - - Starts paid service for a trial entitlement. - - Starts paid service for a trial entitlement immediately. This - method is only applicable if a plan is set up for a trial - entitlement but has some trial days remaining. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - FAILED_PRECONDITION/NOT_IN_TRIAL: This method only works for - entitlement on trial plans. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.StartPaidServiceRequest], - ~.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 'start_paid_service' not in self._stubs: - self._stubs['start_paid_service'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/StartPaidService', - request_serializer=service.StartPaidServiceRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['start_paid_service'] - - @property - def suspend_entitlement(self) -> Callable[ - [service.SuspendEntitlementRequest], - operations_pb2.Operation]: - r"""Return a callable for the suspend entitlement method over gRPC. - - Suspends a previously fulfilled entitlement. - - An entitlement suspension is a long-running operation. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - NOT_ACTIVE: Entitlement is not active. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.SuspendEntitlementRequest], - ~.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 'suspend_entitlement' not in self._stubs: - self._stubs['suspend_entitlement'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/SuspendEntitlement', - request_serializer=service.SuspendEntitlementRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['suspend_entitlement'] - - @property - def cancel_entitlement(self) -> Callable[ - [service.CancelEntitlementRequest], - operations_pb2.Operation]: - r"""Return a callable for the cancel entitlement method over gRPC. - - Cancels a previously fulfilled entitlement. - - An entitlement cancellation is a long-running operation. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - FAILED_PRECONDITION: There are Google Cloud projects linked - to the Google Cloud entitlement's Cloud Billing subaccount. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - DELETION_TYPE_NOT_ALLOWED: Cancel is only allowed for Google - Workspace add-ons, or entitlements for Google Cloud's - development platform. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The response will - contain google.protobuf.Empty on success. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.CancelEntitlementRequest], - ~.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 'cancel_entitlement' not in self._stubs: - self._stubs['cancel_entitlement'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/CancelEntitlement', - request_serializer=service.CancelEntitlementRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['cancel_entitlement'] - - @property - def activate_entitlement(self) -> Callable[ - [service.ActivateEntitlementRequest], - operations_pb2.Operation]: - r"""Return a callable for the activate entitlement method over gRPC. - - Activates a previously suspended entitlement. Entitlements - suspended for pending ToS acceptance can't be activated using - this method. - - An entitlement activation is a long-running operation and it - updates the state of the customer entitlement. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - SUSPENSION_NOT_RESELLER_INITIATED: Can only activate - reseller-initiated suspensions and entitlements that have - accepted the TOS. - - NOT_SUSPENDED: Can only activate suspended entitlements not - in an ACTIVE state. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.ActivateEntitlementRequest], - ~.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_entitlement' not in self._stubs: - self._stubs['activate_entitlement'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ActivateEntitlement', - request_serializer=service.ActivateEntitlementRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['activate_entitlement'] - - @property - def transfer_entitlements(self) -> Callable[ - [service.TransferEntitlementsRequest], - operations_pb2.Operation]: - r"""Return a callable for the transfer entitlements method over gRPC. - - Transfers customer entitlements to new reseller. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer or offer resource was not found. - - ALREADY_EXISTS: The SKU was already transferred for the - customer. - - CONDITION_NOT_MET or FAILED_PRECONDITION: - - - The SKU requires domain verification to transfer, but the - domain is not verified. - - An Add-On SKU (example, Vault or Drive) is missing the - pre-requisite SKU (example, G Suite Basic). - - (Developer accounts only) Reseller and resold domain must - meet the following naming requirements: - - - Domain names must start with goog-test. - - Domain names must include the reseller domain. - - - Specify all transferring entitlements. - - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.TransferEntitlementsRequest], - ~.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 'transfer_entitlements' not in self._stubs: - self._stubs['transfer_entitlements'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/TransferEntitlements', - request_serializer=service.TransferEntitlementsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['transfer_entitlements'] - - @property - def transfer_entitlements_to_google(self) -> Callable[ - [service.TransferEntitlementsToGoogleRequest], - operations_pb2.Operation]: - r"""Return a callable for the transfer entitlements to - google method over gRPC. - - Transfers customer entitlements from their current reseller to - Google. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer or offer resource was not found. - - ALREADY_EXISTS: The SKU was already transferred for the - customer. - - CONDITION_NOT_MET or FAILED_PRECONDITION: - - - The SKU requires domain verification to transfer, but the - domain is not verified. - - An Add-On SKU (example, Vault or Drive) is missing the - pre-requisite SKU (example, G Suite Basic). - - (Developer accounts only) Reseller and resold domain must - meet the following naming requirements: - - - Domain names must start with goog-test. - - Domain names must include the reseller domain. - - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The response will - contain google.protobuf.Empty on success. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.TransferEntitlementsToGoogleRequest], - ~.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 'transfer_entitlements_to_google' not in self._stubs: - self._stubs['transfer_entitlements_to_google'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/TransferEntitlementsToGoogle', - request_serializer=service.TransferEntitlementsToGoogleRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['transfer_entitlements_to_google'] - - @property - def list_channel_partner_links(self) -> Callable[ - [service.ListChannelPartnerLinksRequest], - service.ListChannelPartnerLinksResponse]: - r"""Return a callable for the list channel partner links method over gRPC. - - List - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s - belonging to a distributor. You must be a distributor to call - this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: The list of the distributor account's - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resources. - - Returns: - Callable[[~.ListChannelPartnerLinksRequest], - ~.ListChannelPartnerLinksResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_channel_partner_links' not in self._stubs: - self._stubs['list_channel_partner_links'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListChannelPartnerLinks', - request_serializer=service.ListChannelPartnerLinksRequest.serialize, - response_deserializer=service.ListChannelPartnerLinksResponse.deserialize, - ) - return self._stubs['list_channel_partner_links'] - - @property - def get_channel_partner_link(self) -> Callable[ - [service.GetChannelPartnerLinkRequest], - channel_partner_links.ChannelPartnerLink]: - r"""Return a callable for the get channel partner link method over gRPC. - - Returns the requested - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. You must be a distributor to call this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: ChannelPartnerLink resource not found because of - an invalid channel partner link name. - - Return value: The - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. - - Returns: - Callable[[~.GetChannelPartnerLinkRequest], - ~.ChannelPartnerLink]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_channel_partner_link' not in self._stubs: - self._stubs['get_channel_partner_link'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/GetChannelPartnerLink', - request_serializer=service.GetChannelPartnerLinkRequest.serialize, - response_deserializer=channel_partner_links.ChannelPartnerLink.deserialize, - ) - return self._stubs['get_channel_partner_link'] - - @property - def create_channel_partner_link(self) -> Callable[ - [service.CreateChannelPartnerLinkRequest], - channel_partner_links.ChannelPartnerLink]: - r"""Return a callable for the create channel partner link method over gRPC. - - Initiates a channel partner link between a distributor and a - reseller, or between resellers in an n-tier reseller channel. - Invited partners need to follow the invite_link_uri provided in - the response to accept. After accepting the invitation, a link - is set up between the two parties. You must be a distributor to - call this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - ALREADY_EXISTS: The ChannelPartnerLink sent in the request - already exists. - - NOT_FOUND: No Cloud Identity customer exists for provided - domain. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The new - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. - - Returns: - Callable[[~.CreateChannelPartnerLinkRequest], - ~.ChannelPartnerLink]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_channel_partner_link' not in self._stubs: - self._stubs['create_channel_partner_link'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/CreateChannelPartnerLink', - request_serializer=service.CreateChannelPartnerLinkRequest.serialize, - response_deserializer=channel_partner_links.ChannelPartnerLink.deserialize, - ) - return self._stubs['create_channel_partner_link'] - - @property - def update_channel_partner_link(self) -> Callable[ - [service.UpdateChannelPartnerLinkRequest], - channel_partner_links.ChannelPartnerLink]: - r"""Return a callable for the update channel partner link method over gRPC. - - Updates a channel partner link. Distributors call this method to - change a link's status. For example, to suspend a partner link. - You must be a distributor to call this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: - - - Required request parameters are missing or invalid. - - Link state cannot change from invited to active or - suspended. - - Cannot send reseller_cloud_identity_id, invite_url, or - name in update mask. - - - NOT_FOUND: ChannelPartnerLink resource not found. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The updated - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. - - Returns: - Callable[[~.UpdateChannelPartnerLinkRequest], - ~.ChannelPartnerLink]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_channel_partner_link' not in self._stubs: - self._stubs['update_channel_partner_link'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/UpdateChannelPartnerLink', - request_serializer=service.UpdateChannelPartnerLinkRequest.serialize, - response_deserializer=channel_partner_links.ChannelPartnerLink.deserialize, - ) - return self._stubs['update_channel_partner_link'] - - @property - def lookup_offer(self) -> Callable[ - [service.LookupOfferRequest], - offers.Offer]: - r"""Return a callable for the lookup offer method over gRPC. - - Returns the requested [Offer][google.cloud.channel.v1.Offer] - resource. - - Possible error codes: - - - PERMISSION_DENIED: The entitlement doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement or offer was not found. - - Return value: The [Offer][google.cloud.channel.v1.Offer] - resource. - - Returns: - Callable[[~.LookupOfferRequest], - ~.Offer]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'lookup_offer' not in self._stubs: - self._stubs['lookup_offer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/LookupOffer', - request_serializer=service.LookupOfferRequest.serialize, - response_deserializer=offers.Offer.deserialize, - ) - return self._stubs['lookup_offer'] - - @property - def list_products(self) -> Callable[ - [service.ListProductsRequest], - service.ListProductsResponse]: - r"""Return a callable for the list products method over gRPC. - - Lists the Products the reseller is authorized to sell. - - Possible error codes: - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Returns: - Callable[[~.ListProductsRequest], - ~.ListProductsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_products' not in self._stubs: - self._stubs['list_products'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListProducts', - request_serializer=service.ListProductsRequest.serialize, - response_deserializer=service.ListProductsResponse.deserialize, - ) - return self._stubs['list_products'] - - @property - def list_skus(self) -> Callable[ - [service.ListSkusRequest], - service.ListSkusResponse]: - r"""Return a callable for the list skus method over gRPC. - - Lists the SKUs for a product the reseller is authorized to sell. - - Possible error codes: - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Returns: - Callable[[~.ListSkusRequest], - ~.ListSkusResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_skus' not in self._stubs: - self._stubs['list_skus'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListSkus', - request_serializer=service.ListSkusRequest.serialize, - response_deserializer=service.ListSkusResponse.deserialize, - ) - return self._stubs['list_skus'] - - @property - def list_offers(self) -> Callable[ - [service.ListOffersRequest], - service.ListOffersResponse]: - r"""Return a callable for the list offers method over gRPC. - - Lists the Offers the reseller can sell. - - Possible error codes: - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Returns: - Callable[[~.ListOffersRequest], - ~.ListOffersResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_offers' not in self._stubs: - self._stubs['list_offers'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListOffers', - request_serializer=service.ListOffersRequest.serialize, - response_deserializer=service.ListOffersResponse.deserialize, - ) - return self._stubs['list_offers'] - - @property - def list_purchasable_skus(self) -> Callable[ - [service.ListPurchasableSkusRequest], - service.ListPurchasableSkusResponse]: - r"""Return a callable for the list purchasable skus method over gRPC. - - Lists the following: - - - SKUs that you can purchase for a customer - - SKUs that you can upgrade or downgrade for an entitlement. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Returns: - Callable[[~.ListPurchasableSkusRequest], - ~.ListPurchasableSkusResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_purchasable_skus' not in self._stubs: - self._stubs['list_purchasable_skus'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListPurchasableSkus', - request_serializer=service.ListPurchasableSkusRequest.serialize, - response_deserializer=service.ListPurchasableSkusResponse.deserialize, - ) - return self._stubs['list_purchasable_skus'] - - @property - def list_purchasable_offers(self) -> Callable[ - [service.ListPurchasableOffersRequest], - service.ListPurchasableOffersResponse]: - r"""Return a callable for the list purchasable offers method over gRPC. - - Lists the following: - - - Offers that you can purchase for a customer. - - Offers that you can change for an entitlement. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Returns: - Callable[[~.ListPurchasableOffersRequest], - ~.ListPurchasableOffersResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_purchasable_offers' not in self._stubs: - self._stubs['list_purchasable_offers'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListPurchasableOffers', - request_serializer=service.ListPurchasableOffersRequest.serialize, - response_deserializer=service.ListPurchasableOffersResponse.deserialize, - ) - return self._stubs['list_purchasable_offers'] - - @property - def register_subscriber(self) -> Callable[ - [service.RegisterSubscriberRequest], - service.RegisterSubscriberResponse]: - r"""Return a callable for the register subscriber method over gRPC. - - Registers a service account with subscriber privileges on the - Cloud Pub/Sub topic for this Channel Services account. After you - create a subscriber, you get the events through - [SubscriberEvent][google.cloud.channel.v1.SubscriberEvent] - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request - and the provided reseller account are different, or the - impersonated user is not a super admin. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The topic name with the registered service email - address. - - Returns: - Callable[[~.RegisterSubscriberRequest], - ~.RegisterSubscriberResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'register_subscriber' not in self._stubs: - self._stubs['register_subscriber'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/RegisterSubscriber', - request_serializer=service.RegisterSubscriberRequest.serialize, - response_deserializer=service.RegisterSubscriberResponse.deserialize, - ) - return self._stubs['register_subscriber'] - - @property - def unregister_subscriber(self) -> Callable[ - [service.UnregisterSubscriberRequest], - service.UnregisterSubscriberResponse]: - r"""Return a callable for the unregister subscriber method over gRPC. - - Unregisters a service account with subscriber privileges on the - Cloud Pub/Sub topic created for this Channel Services account. - If there are no service accounts left with subscriber - privileges, this deletes the topic. You can call ListSubscribers - to check for these accounts. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request - and the provided reseller account are different, or the - impersonated user is not a super admin. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The topic resource doesn't exist. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The topic name that unregistered the service email - address. Returns a success response if the service email address - wasn't registered with the topic. - - Returns: - Callable[[~.UnregisterSubscriberRequest], - ~.UnregisterSubscriberResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'unregister_subscriber' not in self._stubs: - self._stubs['unregister_subscriber'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/UnregisterSubscriber', - request_serializer=service.UnregisterSubscriberRequest.serialize, - response_deserializer=service.UnregisterSubscriberResponse.deserialize, - ) - return self._stubs['unregister_subscriber'] - - @property - def list_subscribers(self) -> Callable[ - [service.ListSubscribersRequest], - service.ListSubscribersResponse]: - r"""Return a callable for the list subscribers method over gRPC. - - Lists service accounts with subscriber privileges on the Cloud - Pub/Sub topic created for this Channel Services account. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request - and the provided reseller account are different, or the - impersonated user is not a super admin. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The topic resource doesn't exist. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: A list of service email addresses. - - Returns: - Callable[[~.ListSubscribersRequest], - ~.ListSubscribersResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_subscribers' not in self._stubs: - self._stubs['list_subscribers'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListSubscribers', - request_serializer=service.ListSubscribersRequest.serialize, - response_deserializer=service.ListSubscribersResponse.deserialize, - ) - return self._stubs['list_subscribers'] - - def close(self): - self.grpc_channel.close() - -__all__ = ( - 'CloudChannelServiceGrpcTransport', -) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc_asyncio.py b/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc_asyncio.py deleted file mode 100644 index 742f943..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/services/cloud_channel_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,1846 +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.channel_v1.types import channel_partner_links -from google.cloud.channel_v1.types import customers -from google.cloud.channel_v1.types import entitlements -from google.cloud.channel_v1.types import offers -from google.cloud.channel_v1.types import service -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import CloudChannelServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import CloudChannelServiceGrpcTransport - - -class CloudChannelServiceGrpcAsyncIOTransport(CloudChannelServiceTransport): - """gRPC AsyncIO backend transport for CloudChannelService. - - CloudChannelService lets Google cloud resellers and distributors - manage their customers, channel partners, entitlements, and reports. - - Using this service: - - 1. Resellers and distributors can manage a customer entity. - 2. Distributors can register an authorized reseller in their channel - and provide them with delegated admin access. - 3. Resellers and distributors can manage customer entitlements. - - CloudChannelService exposes the following resources: - - - [Customer][google.cloud.channel.v1.Customer]s: An entity—usually - an enterprise—managed by a reseller or distributor. - - - [Entitlement][google.cloud.channel.v1.Entitlement]s: An entity - that provides a customer with the means to use a service. - Entitlements are created or updated as a result of a successful - fulfillment. - - - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s: - An entity that identifies links between distributors and their - indirect resellers in a channel. - - 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 = 'cloudchannel.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - def __init__(self, *, - host: str = 'cloudchannel.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, - always_use_jwt_access: Optional[bool] = False, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - credentials=self._credentials, - credentials_file=credentials_file, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsAsyncClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def list_customers(self) -> Callable[ - [service.ListCustomersRequest], - Awaitable[service.ListCustomersResponse]]: - r"""Return a callable for the list customers method over gRPC. - - List [Customer][google.cloud.channel.v1.Customer]s. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: List of - [Customer][google.cloud.channel.v1.Customer]s, or an empty list - if there are no customers. - - Returns: - Callable[[~.ListCustomersRequest], - Awaitable[~.ListCustomersResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_customers' not in self._stubs: - self._stubs['list_customers'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListCustomers', - request_serializer=service.ListCustomersRequest.serialize, - response_deserializer=service.ListCustomersResponse.deserialize, - ) - return self._stubs['list_customers'] - - @property - def get_customer(self) -> Callable[ - [service.GetCustomerRequest], - Awaitable[customers.Customer]]: - r"""Return a callable for the get customer method over gRPC. - - Returns the requested - [Customer][google.cloud.channel.v1.Customer] resource. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer resource doesn't exist. Usually the - result of an invalid name parameter. - - Return value: The [Customer][google.cloud.channel.v1.Customer] - resource. - - Returns: - Callable[[~.GetCustomerRequest], - Awaitable[~.Customer]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_customer' not in self._stubs: - self._stubs['get_customer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/GetCustomer', - request_serializer=service.GetCustomerRequest.serialize, - response_deserializer=customers.Customer.deserialize, - ) - return self._stubs['get_customer'] - - @property - def check_cloud_identity_accounts_exist(self) -> Callable[ - [service.CheckCloudIdentityAccountsExistRequest], - Awaitable[service.CheckCloudIdentityAccountsExistResponse]]: - r"""Return a callable for the check cloud identity accounts - exist method over gRPC. - - Confirms the existence of Cloud Identity accounts based on the - domain and if the Cloud Identity accounts are owned by the - reseller. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - INVALID_VALUE: Invalid domain value in the request. - - Return value: A list of - [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] - resources for the domain (may be empty) - - Note: in the v1alpha1 version of the API, a NOT_FOUND error - returns if no - [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] - resources match the domain. - - Returns: - Callable[[~.CheckCloudIdentityAccountsExistRequest], - Awaitable[~.CheckCloudIdentityAccountsExistResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'check_cloud_identity_accounts_exist' not in self._stubs: - self._stubs['check_cloud_identity_accounts_exist'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/CheckCloudIdentityAccountsExist', - request_serializer=service.CheckCloudIdentityAccountsExistRequest.serialize, - response_deserializer=service.CheckCloudIdentityAccountsExistResponse.deserialize, - ) - return self._stubs['check_cloud_identity_accounts_exist'] - - @property - def create_customer(self) -> Callable[ - [service.CreateCustomerRequest], - Awaitable[customers.Customer]]: - r"""Return a callable for the create customer method over gRPC. - - Creates a new [Customer][google.cloud.channel.v1.Customer] - resource under the reseller or distributor account. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: - - - Required request parameters are missing or invalid. - - Domain field value doesn't match the primary email domain. - - Return value: The newly created - [Customer][google.cloud.channel.v1.Customer] resource. - - Returns: - Callable[[~.CreateCustomerRequest], - Awaitable[~.Customer]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_customer' not in self._stubs: - self._stubs['create_customer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/CreateCustomer', - request_serializer=service.CreateCustomerRequest.serialize, - response_deserializer=customers.Customer.deserialize, - ) - return self._stubs['create_customer'] - - @property - def update_customer(self) -> Callable[ - [service.UpdateCustomerRequest], - Awaitable[customers.Customer]]: - r"""Return a callable for the update customer method over gRPC. - - Updates an existing [Customer][google.cloud.channel.v1.Customer] - resource for the reseller or distributor. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] - resource found for the name in the request. - - Return value: The updated - [Customer][google.cloud.channel.v1.Customer] resource. - - Returns: - Callable[[~.UpdateCustomerRequest], - Awaitable[~.Customer]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_customer' not in self._stubs: - self._stubs['update_customer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/UpdateCustomer', - request_serializer=service.UpdateCustomerRequest.serialize, - response_deserializer=customers.Customer.deserialize, - ) - return self._stubs['update_customer'] - - @property - def delete_customer(self) -> Callable[ - [service.DeleteCustomerRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete customer method over gRPC. - - Deletes the given [Customer][google.cloud.channel.v1.Customer] - permanently. - - Possible error codes: - - - PERMISSION_DENIED: The account making the request does not - own this customer. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - FAILED_PRECONDITION: The customer has existing entitlements. - - NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] - resource found for the name in the request. - - Returns: - Callable[[~.DeleteCustomerRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_customer' not in self._stubs: - self._stubs['delete_customer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/DeleteCustomer', - request_serializer=service.DeleteCustomerRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_customer'] - - @property - def import_customer(self) -> Callable[ - [service.ImportCustomerRequest], - Awaitable[customers.Customer]]: - r"""Return a callable for the import customer method over gRPC. - - Imports a [Customer][google.cloud.channel.v1.Customer] from the - Cloud Identity associated with the provided Cloud Identity ID or - domain before a TransferEntitlements call. If a linked Customer - already exists and overwrite_if_exists is true, it will update - that Customer's data. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - NOT_FOUND: Cloud Identity doesn't exist or was deleted. - - INVALID_ARGUMENT: Required parameters are missing, or the - auth_token is expired or invalid. - - ALREADY_EXISTS: A customer already exists and has conflicting - critical fields. Requires an overwrite. - - Return value: The [Customer][google.cloud.channel.v1.Customer]. - - Returns: - Callable[[~.ImportCustomerRequest], - Awaitable[~.Customer]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'import_customer' not in self._stubs: - self._stubs['import_customer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ImportCustomer', - request_serializer=service.ImportCustomerRequest.serialize, - response_deserializer=customers.Customer.deserialize, - ) - return self._stubs['import_customer'] - - @property - def provision_cloud_identity(self) -> Callable[ - [service.ProvisionCloudIdentityRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the provision cloud identity method over gRPC. - - Creates a Cloud Identity for the given customer using the - customer's information, or the information provided here. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer was not found. - - ALREADY_EXISTS: The customer's primary email already exists. - Retry after changing the customer's primary contact email. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - contains an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.ProvisionCloudIdentityRequest], - 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 'provision_cloud_identity' not in self._stubs: - self._stubs['provision_cloud_identity'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ProvisionCloudIdentity', - request_serializer=service.ProvisionCloudIdentityRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['provision_cloud_identity'] - - @property - def list_entitlements(self) -> Callable[ - [service.ListEntitlementsRequest], - Awaitable[service.ListEntitlementsResponse]]: - r"""Return a callable for the list entitlements method over gRPC. - - Lists [Entitlement][google.cloud.channel.v1.Entitlement]s - belonging to a customer. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: A list of the customer's - [Entitlement][google.cloud.channel.v1.Entitlement]s. - - Returns: - Callable[[~.ListEntitlementsRequest], - Awaitable[~.ListEntitlementsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_entitlements' not in self._stubs: - self._stubs['list_entitlements'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListEntitlements', - request_serializer=service.ListEntitlementsRequest.serialize, - response_deserializer=service.ListEntitlementsResponse.deserialize, - ) - return self._stubs['list_entitlements'] - - @property - def list_transferable_skus(self) -> Callable[ - [service.ListTransferableSkusRequest], - Awaitable[service.ListTransferableSkusResponse]]: - r"""Return a callable for the list transferable skus method over gRPC. - - List [TransferableSku][google.cloud.channel.v1.TransferableSku]s - of a customer based on the Cloud Identity ID or Customer Name in - the request. - - Use this method to list the entitlements information of an - unowned customer. You should provide the customer's Cloud - Identity ID or Customer Name. - - Possible error codes: - - - PERMISSION_DENIED: - - - The customer doesn't belong to the reseller and has no - auth token. - - The supplied auth token is invalid. - - The reseller account making the request is different from - the reseller account in the query. - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: A list of the customer's - [TransferableSku][google.cloud.channel.v1.TransferableSku]. - - Returns: - Callable[[~.ListTransferableSkusRequest], - Awaitable[~.ListTransferableSkusResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_transferable_skus' not in self._stubs: - self._stubs['list_transferable_skus'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListTransferableSkus', - request_serializer=service.ListTransferableSkusRequest.serialize, - response_deserializer=service.ListTransferableSkusResponse.deserialize, - ) - return self._stubs['list_transferable_skus'] - - @property - def list_transferable_offers(self) -> Callable[ - [service.ListTransferableOffersRequest], - Awaitable[service.ListTransferableOffersResponse]]: - r"""Return a callable for the list transferable offers method over gRPC. - - List - [TransferableOffer][google.cloud.channel.v1.TransferableOffer]s - of a customer based on Cloud Identity ID or Customer Name in the - request. - - Use this method when a reseller gets the entitlement information - of an unowned customer. The reseller should provide the - customer's Cloud Identity ID or Customer Name. - - Possible error codes: - - - PERMISSION_DENIED: - - - The customer doesn't belong to the reseller and has no - auth token. - - The supplied auth token is invalid. - - The reseller account making the request is different from - the reseller account in the query. - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: List of - [TransferableOffer][google.cloud.channel.v1.TransferableOffer] - for the given customer and SKU. - - Returns: - Callable[[~.ListTransferableOffersRequest], - Awaitable[~.ListTransferableOffersResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_transferable_offers' not in self._stubs: - self._stubs['list_transferable_offers'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListTransferableOffers', - request_serializer=service.ListTransferableOffersRequest.serialize, - response_deserializer=service.ListTransferableOffersResponse.deserialize, - ) - return self._stubs['list_transferable_offers'] - - @property - def get_entitlement(self) -> Callable[ - [service.GetEntitlementRequest], - Awaitable[entitlements.Entitlement]]: - r"""Return a callable for the get entitlement method over gRPC. - - Returns the requested - [Entitlement][google.cloud.channel.v1.Entitlement] resource. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer entitlement was not found. - - Return value: The requested - [Entitlement][google.cloud.channel.v1.Entitlement] resource. - - Returns: - Callable[[~.GetEntitlementRequest], - Awaitable[~.Entitlement]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_entitlement' not in self._stubs: - self._stubs['get_entitlement'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/GetEntitlement', - request_serializer=service.GetEntitlementRequest.serialize, - response_deserializer=entitlements.Entitlement.deserialize, - ) - return self._stubs['get_entitlement'] - - @property - def create_entitlement(self) -> Callable[ - [service.CreateEntitlementRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create entitlement method over gRPC. - - Creates an entitlement for a customer. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: - - - Required request parameters are missing or invalid. - - There is already a customer entitlement for a SKU from the - same product family. - - - INVALID_VALUE: Make sure the OfferId is valid. If it is, - contact Google Channel support for further troubleshooting. - - NOT_FOUND: The customer or offer resource was not found. - - ALREADY_EXISTS: - - - The SKU was already purchased for the customer. - - The customer's primary email already exists. Retry after - changing the customer's primary contact email. - - - CONDITION_NOT_MET or FAILED_PRECONDITION: - - - The domain required for purchasing a SKU has not been - verified. - - A pre-requisite SKU required to purchase an Add-On SKU is - missing. For example, Google Workspace Business Starter is - required to purchase Vault or Drive. - - (Developer accounts only) Reseller and resold domain must - meet the following naming requirements: - - - Domain names must start with goog-test. - - Domain names must include the reseller domain. - - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.CreateEntitlementRequest], - 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_entitlement' not in self._stubs: - self._stubs['create_entitlement'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/CreateEntitlement', - request_serializer=service.CreateEntitlementRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_entitlement'] - - @property - def change_parameters(self) -> Callable[ - [service.ChangeParametersRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the change parameters method over gRPC. - - Change parameters of the entitlement. - - An entitlement update is a long-running operation and it updates - the entitlement as a result of fulfillment. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. For example, the number of seats being changed is - greater than the allowed number of max seats, or decreasing - seats for a commitment based plan. - - NOT_FOUND: Entitlement resource not found. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.ChangeParametersRequest], - 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 'change_parameters' not in self._stubs: - self._stubs['change_parameters'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ChangeParameters', - request_serializer=service.ChangeParametersRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['change_parameters'] - - @property - def change_renewal_settings(self) -> Callable[ - [service.ChangeRenewalSettingsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the change renewal settings method over gRPC. - - Updates the renewal settings for an existing customer - entitlement. - - An entitlement update is a long-running operation and it updates - the entitlement as a result of fulfillment. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - NOT_COMMITMENT_PLAN: Renewal Settings are only applicable for - a commitment plan. Can't enable or disable renewals for - non-commitment plans. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.ChangeRenewalSettingsRequest], - 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 'change_renewal_settings' not in self._stubs: - self._stubs['change_renewal_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ChangeRenewalSettings', - request_serializer=service.ChangeRenewalSettingsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['change_renewal_settings'] - - @property - def change_offer(self) -> Callable[ - [service.ChangeOfferRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the change offer method over gRPC. - - Updates the Offer for an existing customer entitlement. - - An entitlement update is a long-running operation and it updates - the entitlement as a result of fulfillment. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Offer or Entitlement resource not found. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.ChangeOfferRequest], - 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 'change_offer' not in self._stubs: - self._stubs['change_offer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ChangeOffer', - request_serializer=service.ChangeOfferRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['change_offer'] - - @property - def start_paid_service(self) -> Callable[ - [service.StartPaidServiceRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the start paid service method over gRPC. - - Starts paid service for a trial entitlement. - - Starts paid service for a trial entitlement immediately. This - method is only applicable if a plan is set up for a trial - entitlement but has some trial days remaining. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - FAILED_PRECONDITION/NOT_IN_TRIAL: This method only works for - entitlement on trial plans. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.StartPaidServiceRequest], - 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 'start_paid_service' not in self._stubs: - self._stubs['start_paid_service'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/StartPaidService', - request_serializer=service.StartPaidServiceRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['start_paid_service'] - - @property - def suspend_entitlement(self) -> Callable[ - [service.SuspendEntitlementRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the suspend entitlement method over gRPC. - - Suspends a previously fulfilled entitlement. - - An entitlement suspension is a long-running operation. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - NOT_ACTIVE: Entitlement is not active. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.SuspendEntitlementRequest], - 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 'suspend_entitlement' not in self._stubs: - self._stubs['suspend_entitlement'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/SuspendEntitlement', - request_serializer=service.SuspendEntitlementRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['suspend_entitlement'] - - @property - def cancel_entitlement(self) -> Callable[ - [service.CancelEntitlementRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the cancel entitlement method over gRPC. - - Cancels a previously fulfilled entitlement. - - An entitlement cancellation is a long-running operation. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - FAILED_PRECONDITION: There are Google Cloud projects linked - to the Google Cloud entitlement's Cloud Billing subaccount. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - DELETION_TYPE_NOT_ALLOWED: Cancel is only allowed for Google - Workspace add-ons, or entitlements for Google Cloud's - development platform. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The response will - contain google.protobuf.Empty on success. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.CancelEntitlementRequest], - 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 'cancel_entitlement' not in self._stubs: - self._stubs['cancel_entitlement'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/CancelEntitlement', - request_serializer=service.CancelEntitlementRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['cancel_entitlement'] - - @property - def activate_entitlement(self) -> Callable[ - [service.ActivateEntitlementRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the activate entitlement method over gRPC. - - Activates a previously suspended entitlement. Entitlements - suspended for pending ToS acceptance can't be activated using - this method. - - An entitlement activation is a long-running operation and it - updates the state of the customer entitlement. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement resource not found. - - SUSPENSION_NOT_RESELLER_INITIATED: Can only activate - reseller-initiated suspensions and entitlements that have - accepted the TOS. - - NOT_SUSPENDED: Can only activate suspended entitlements not - in an ACTIVE state. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.ActivateEntitlementRequest], - 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_entitlement' not in self._stubs: - self._stubs['activate_entitlement'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ActivateEntitlement', - request_serializer=service.ActivateEntitlementRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['activate_entitlement'] - - @property - def transfer_entitlements(self) -> Callable[ - [service.TransferEntitlementsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the transfer entitlements method over gRPC. - - Transfers customer entitlements to new reseller. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer or offer resource was not found. - - ALREADY_EXISTS: The SKU was already transferred for the - customer. - - CONDITION_NOT_MET or FAILED_PRECONDITION: - - - The SKU requires domain verification to transfer, but the - domain is not verified. - - An Add-On SKU (example, Vault or Drive) is missing the - pre-requisite SKU (example, G Suite Basic). - - (Developer accounts only) Reseller and resold domain must - meet the following naming requirements: - - - Domain names must start with goog-test. - - Domain names must include the reseller domain. - - - Specify all transferring entitlements. - - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.TransferEntitlementsRequest], - 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 'transfer_entitlements' not in self._stubs: - self._stubs['transfer_entitlements'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/TransferEntitlements', - request_serializer=service.TransferEntitlementsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['transfer_entitlements'] - - @property - def transfer_entitlements_to_google(self) -> Callable[ - [service.TransferEntitlementsToGoogleRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the transfer entitlements to - google method over gRPC. - - Transfers customer entitlements from their current reseller to - Google. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The customer or offer resource was not found. - - ALREADY_EXISTS: The SKU was already transferred for the - customer. - - CONDITION_NOT_MET or FAILED_PRECONDITION: - - - The SKU requires domain verification to transfer, but the - domain is not verified. - - An Add-On SKU (example, Vault or Drive) is missing the - pre-requisite SKU (example, G Suite Basic). - - (Developer accounts only) Reseller and resold domain must - meet the following naming requirements: - - - Domain names must start with goog-test. - - Domain names must include the reseller domain. - - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The ID of a long-running operation. - - To get the results of the operation, call the GetOperation - method of CloudChannelOperationsService. The response will - contain google.protobuf.Empty on success. The Operation metadata - will contain an instance of - [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - - Returns: - Callable[[~.TransferEntitlementsToGoogleRequest], - 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 'transfer_entitlements_to_google' not in self._stubs: - self._stubs['transfer_entitlements_to_google'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/TransferEntitlementsToGoogle', - request_serializer=service.TransferEntitlementsToGoogleRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['transfer_entitlements_to_google'] - - @property - def list_channel_partner_links(self) -> Callable[ - [service.ListChannelPartnerLinksRequest], - Awaitable[service.ListChannelPartnerLinksResponse]]: - r"""Return a callable for the list channel partner links method over gRPC. - - List - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s - belonging to a distributor. You must be a distributor to call - this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Return value: The list of the distributor account's - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resources. - - Returns: - Callable[[~.ListChannelPartnerLinksRequest], - Awaitable[~.ListChannelPartnerLinksResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_channel_partner_links' not in self._stubs: - self._stubs['list_channel_partner_links'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListChannelPartnerLinks', - request_serializer=service.ListChannelPartnerLinksRequest.serialize, - response_deserializer=service.ListChannelPartnerLinksResponse.deserialize, - ) - return self._stubs['list_channel_partner_links'] - - @property - def get_channel_partner_link(self) -> Callable[ - [service.GetChannelPartnerLinkRequest], - Awaitable[channel_partner_links.ChannelPartnerLink]]: - r"""Return a callable for the get channel partner link method over gRPC. - - Returns the requested - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. You must be a distributor to call this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: ChannelPartnerLink resource not found because of - an invalid channel partner link name. - - Return value: The - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. - - Returns: - Callable[[~.GetChannelPartnerLinkRequest], - Awaitable[~.ChannelPartnerLink]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_channel_partner_link' not in self._stubs: - self._stubs['get_channel_partner_link'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/GetChannelPartnerLink', - request_serializer=service.GetChannelPartnerLinkRequest.serialize, - response_deserializer=channel_partner_links.ChannelPartnerLink.deserialize, - ) - return self._stubs['get_channel_partner_link'] - - @property - def create_channel_partner_link(self) -> Callable[ - [service.CreateChannelPartnerLinkRequest], - Awaitable[channel_partner_links.ChannelPartnerLink]]: - r"""Return a callable for the create channel partner link method over gRPC. - - Initiates a channel partner link between a distributor and a - reseller, or between resellers in an n-tier reseller channel. - Invited partners need to follow the invite_link_uri provided in - the response to accept. After accepting the invitation, a link - is set up between the two parties. You must be a distributor to - call this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - ALREADY_EXISTS: The ChannelPartnerLink sent in the request - already exists. - - NOT_FOUND: No Cloud Identity customer exists for provided - domain. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The new - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. - - Returns: - Callable[[~.CreateChannelPartnerLinkRequest], - Awaitable[~.ChannelPartnerLink]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_channel_partner_link' not in self._stubs: - self._stubs['create_channel_partner_link'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/CreateChannelPartnerLink', - request_serializer=service.CreateChannelPartnerLinkRequest.serialize, - response_deserializer=channel_partner_links.ChannelPartnerLink.deserialize, - ) - return self._stubs['create_channel_partner_link'] - - @property - def update_channel_partner_link(self) -> Callable[ - [service.UpdateChannelPartnerLinkRequest], - Awaitable[channel_partner_links.ChannelPartnerLink]]: - r"""Return a callable for the update channel partner link method over gRPC. - - Updates a channel partner link. Distributors call this method to - change a link's status. For example, to suspend a partner link. - You must be a distributor to call this method. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request is - different from the reseller account in the API request. - - INVALID_ARGUMENT: - - - Required request parameters are missing or invalid. - - Link state cannot change from invited to active or - suspended. - - Cannot send reseller_cloud_identity_id, invite_url, or - name in update mask. - - - NOT_FOUND: ChannelPartnerLink resource not found. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The updated - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - resource. - - Returns: - Callable[[~.UpdateChannelPartnerLinkRequest], - Awaitable[~.ChannelPartnerLink]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_channel_partner_link' not in self._stubs: - self._stubs['update_channel_partner_link'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/UpdateChannelPartnerLink', - request_serializer=service.UpdateChannelPartnerLinkRequest.serialize, - response_deserializer=channel_partner_links.ChannelPartnerLink.deserialize, - ) - return self._stubs['update_channel_partner_link'] - - @property - def lookup_offer(self) -> Callable[ - [service.LookupOfferRequest], - Awaitable[offers.Offer]]: - r"""Return a callable for the lookup offer method over gRPC. - - Returns the requested [Offer][google.cloud.channel.v1.Offer] - resource. - - Possible error codes: - - - PERMISSION_DENIED: The entitlement doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: Entitlement or offer was not found. - - Return value: The [Offer][google.cloud.channel.v1.Offer] - resource. - - Returns: - Callable[[~.LookupOfferRequest], - Awaitable[~.Offer]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'lookup_offer' not in self._stubs: - self._stubs['lookup_offer'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/LookupOffer', - request_serializer=service.LookupOfferRequest.serialize, - response_deserializer=offers.Offer.deserialize, - ) - return self._stubs['lookup_offer'] - - @property - def list_products(self) -> Callable[ - [service.ListProductsRequest], - Awaitable[service.ListProductsResponse]]: - r"""Return a callable for the list products method over gRPC. - - Lists the Products the reseller is authorized to sell. - - Possible error codes: - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Returns: - Callable[[~.ListProductsRequest], - Awaitable[~.ListProductsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_products' not in self._stubs: - self._stubs['list_products'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListProducts', - request_serializer=service.ListProductsRequest.serialize, - response_deserializer=service.ListProductsResponse.deserialize, - ) - return self._stubs['list_products'] - - @property - def list_skus(self) -> Callable[ - [service.ListSkusRequest], - Awaitable[service.ListSkusResponse]]: - r"""Return a callable for the list skus method over gRPC. - - Lists the SKUs for a product the reseller is authorized to sell. - - Possible error codes: - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Returns: - Callable[[~.ListSkusRequest], - Awaitable[~.ListSkusResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_skus' not in self._stubs: - self._stubs['list_skus'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListSkus', - request_serializer=service.ListSkusRequest.serialize, - response_deserializer=service.ListSkusResponse.deserialize, - ) - return self._stubs['list_skus'] - - @property - def list_offers(self) -> Callable[ - [service.ListOffersRequest], - Awaitable[service.ListOffersResponse]]: - r"""Return a callable for the list offers method over gRPC. - - Lists the Offers the reseller can sell. - - Possible error codes: - - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Returns: - Callable[[~.ListOffersRequest], - Awaitable[~.ListOffersResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_offers' not in self._stubs: - self._stubs['list_offers'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListOffers', - request_serializer=service.ListOffersRequest.serialize, - response_deserializer=service.ListOffersResponse.deserialize, - ) - return self._stubs['list_offers'] - - @property - def list_purchasable_skus(self) -> Callable[ - [service.ListPurchasableSkusRequest], - Awaitable[service.ListPurchasableSkusResponse]]: - r"""Return a callable for the list purchasable skus method over gRPC. - - Lists the following: - - - SKUs that you can purchase for a customer - - SKUs that you can upgrade or downgrade for an entitlement. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Returns: - Callable[[~.ListPurchasableSkusRequest], - Awaitable[~.ListPurchasableSkusResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_purchasable_skus' not in self._stubs: - self._stubs['list_purchasable_skus'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListPurchasableSkus', - request_serializer=service.ListPurchasableSkusRequest.serialize, - response_deserializer=service.ListPurchasableSkusResponse.deserialize, - ) - return self._stubs['list_purchasable_skus'] - - @property - def list_purchasable_offers(self) -> Callable[ - [service.ListPurchasableOffersRequest], - Awaitable[service.ListPurchasableOffersResponse]]: - r"""Return a callable for the list purchasable offers method over gRPC. - - Lists the following: - - - Offers that you can purchase for a customer. - - Offers that you can change for an entitlement. - - Possible error codes: - - - PERMISSION_DENIED: The customer doesn't belong to the - reseller - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - Returns: - Callable[[~.ListPurchasableOffersRequest], - Awaitable[~.ListPurchasableOffersResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_purchasable_offers' not in self._stubs: - self._stubs['list_purchasable_offers'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListPurchasableOffers', - request_serializer=service.ListPurchasableOffersRequest.serialize, - response_deserializer=service.ListPurchasableOffersResponse.deserialize, - ) - return self._stubs['list_purchasable_offers'] - - @property - def register_subscriber(self) -> Callable[ - [service.RegisterSubscriberRequest], - Awaitable[service.RegisterSubscriberResponse]]: - r"""Return a callable for the register subscriber method over gRPC. - - Registers a service account with subscriber privileges on the - Cloud Pub/Sub topic for this Channel Services account. After you - create a subscriber, you get the events through - [SubscriberEvent][google.cloud.channel.v1.SubscriberEvent] - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request - and the provided reseller account are different, or the - impersonated user is not a super admin. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The topic name with the registered service email - address. - - Returns: - Callable[[~.RegisterSubscriberRequest], - Awaitable[~.RegisterSubscriberResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'register_subscriber' not in self._stubs: - self._stubs['register_subscriber'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/RegisterSubscriber', - request_serializer=service.RegisterSubscriberRequest.serialize, - response_deserializer=service.RegisterSubscriberResponse.deserialize, - ) - return self._stubs['register_subscriber'] - - @property - def unregister_subscriber(self) -> Callable[ - [service.UnregisterSubscriberRequest], - Awaitable[service.UnregisterSubscriberResponse]]: - r"""Return a callable for the unregister subscriber method over gRPC. - - Unregisters a service account with subscriber privileges on the - Cloud Pub/Sub topic created for this Channel Services account. - If there are no service accounts left with subscriber - privileges, this deletes the topic. You can call ListSubscribers - to check for these accounts. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request - and the provided reseller account are different, or the - impersonated user is not a super admin. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The topic resource doesn't exist. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: The topic name that unregistered the service email - address. Returns a success response if the service email address - wasn't registered with the topic. - - Returns: - Callable[[~.UnregisterSubscriberRequest], - Awaitable[~.UnregisterSubscriberResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'unregister_subscriber' not in self._stubs: - self._stubs['unregister_subscriber'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/UnregisterSubscriber', - request_serializer=service.UnregisterSubscriberRequest.serialize, - response_deserializer=service.UnregisterSubscriberResponse.deserialize, - ) - return self._stubs['unregister_subscriber'] - - @property - def list_subscribers(self) -> Callable[ - [service.ListSubscribersRequest], - Awaitable[service.ListSubscribersResponse]]: - r"""Return a callable for the list subscribers method over gRPC. - - Lists service accounts with subscriber privileges on the Cloud - Pub/Sub topic created for this Channel Services account. - - Possible error codes: - - - PERMISSION_DENIED: The reseller account making the request - and the provided reseller account are different, or the - impersonated user is not a super admin. - - INVALID_ARGUMENT: Required request parameters are missing or - invalid. - - NOT_FOUND: The topic resource doesn't exist. - - INTERNAL: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - UNKNOWN: Any non-user error related to a technical issue in - the backend. Contact Cloud Channel support. - - Return value: A list of service email addresses. - - Returns: - Callable[[~.ListSubscribersRequest], - Awaitable[~.ListSubscribersResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_subscribers' not in self._stubs: - self._stubs['list_subscribers'] = self.grpc_channel.unary_unary( - '/google.cloud.channel.v1.CloudChannelService/ListSubscribers', - request_serializer=service.ListSubscribersRequest.serialize, - response_deserializer=service.ListSubscribersResponse.deserialize, - ) - return self._stubs['list_subscribers'] - - def close(self): - return self.grpc_channel.close() - - -__all__ = ( - 'CloudChannelServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/__init__.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/__init__.py deleted file mode 100644 index a3bf276..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/types/__init__.py +++ /dev/null @@ -1,228 +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 .channel_partner_links import ( - ChannelPartnerLink, - ChannelPartnerLinkState, - ChannelPartnerLinkView, -) -from .common import ( - AdminUser, - CloudIdentityInfo, - EduData, - Value, -) -from .customers import ( - ContactInfo, - Customer, -) -from .entitlements import ( - AssociationInfo, - CommitmentSettings, - Entitlement, - Parameter, - ProvisionedService, - RenewalSettings, - TransferableSku, - TransferEligibility, - TrialSettings, -) -from .offers import ( - Constraints, - CustomerConstraints, - Offer, - ParameterDefinition, - Period, - Plan, - Price, - PriceByResource, - PricePhase, - PriceTier, - PaymentPlan, - PaymentType, - PeriodType, - PromotionalOrderType, - ResourceType, -) -from .operations import ( - OperationMetadata, -) -from .products import ( - MarketingInfo, - Media, - Product, - Sku, - MediaType, -) -from .service import ( - ActivateEntitlementRequest, - CancelEntitlementRequest, - ChangeOfferRequest, - ChangeParametersRequest, - ChangeRenewalSettingsRequest, - CheckCloudIdentityAccountsExistRequest, - CheckCloudIdentityAccountsExistResponse, - CloudIdentityCustomerAccount, - CreateChannelPartnerLinkRequest, - CreateCustomerRequest, - CreateEntitlementRequest, - DeleteCustomerRequest, - GetChannelPartnerLinkRequest, - GetCustomerRequest, - GetEntitlementRequest, - ImportCustomerRequest, - ListChannelPartnerLinksRequest, - ListChannelPartnerLinksResponse, - ListCustomersRequest, - ListCustomersResponse, - ListEntitlementsRequest, - ListEntitlementsResponse, - ListOffersRequest, - ListOffersResponse, - ListProductsRequest, - ListProductsResponse, - ListPurchasableOffersRequest, - ListPurchasableOffersResponse, - ListPurchasableSkusRequest, - ListPurchasableSkusResponse, - ListSkusRequest, - ListSkusResponse, - ListSubscribersRequest, - ListSubscribersResponse, - ListTransferableOffersRequest, - ListTransferableOffersResponse, - ListTransferableSkusRequest, - ListTransferableSkusResponse, - LookupOfferRequest, - ProvisionCloudIdentityRequest, - PurchasableOffer, - PurchasableSku, - RegisterSubscriberRequest, - RegisterSubscriberResponse, - StartPaidServiceRequest, - SuspendEntitlementRequest, - TransferableOffer, - TransferEntitlementsRequest, - TransferEntitlementsResponse, - TransferEntitlementsToGoogleRequest, - UnregisterSubscriberRequest, - UnregisterSubscriberResponse, - UpdateChannelPartnerLinkRequest, - UpdateCustomerRequest, -) -from .subscriber_event import ( - CustomerEvent, - EntitlementEvent, - SubscriberEvent, -) - -__all__ = ( - 'ChannelPartnerLink', - 'ChannelPartnerLinkState', - 'ChannelPartnerLinkView', - 'AdminUser', - 'CloudIdentityInfo', - 'EduData', - 'Value', - 'ContactInfo', - 'Customer', - 'AssociationInfo', - 'CommitmentSettings', - 'Entitlement', - 'Parameter', - 'ProvisionedService', - 'RenewalSettings', - 'TransferableSku', - 'TransferEligibility', - 'TrialSettings', - 'Constraints', - 'CustomerConstraints', - 'Offer', - 'ParameterDefinition', - 'Period', - 'Plan', - 'Price', - 'PriceByResource', - 'PricePhase', - 'PriceTier', - 'PaymentPlan', - 'PaymentType', - 'PeriodType', - 'PromotionalOrderType', - 'ResourceType', - 'OperationMetadata', - 'MarketingInfo', - 'Media', - 'Product', - 'Sku', - 'MediaType', - 'ActivateEntitlementRequest', - 'CancelEntitlementRequest', - 'ChangeOfferRequest', - 'ChangeParametersRequest', - 'ChangeRenewalSettingsRequest', - 'CheckCloudIdentityAccountsExistRequest', - 'CheckCloudIdentityAccountsExistResponse', - 'CloudIdentityCustomerAccount', - 'CreateChannelPartnerLinkRequest', - 'CreateCustomerRequest', - 'CreateEntitlementRequest', - 'DeleteCustomerRequest', - 'GetChannelPartnerLinkRequest', - 'GetCustomerRequest', - 'GetEntitlementRequest', - 'ImportCustomerRequest', - 'ListChannelPartnerLinksRequest', - 'ListChannelPartnerLinksResponse', - 'ListCustomersRequest', - 'ListCustomersResponse', - 'ListEntitlementsRequest', - 'ListEntitlementsResponse', - 'ListOffersRequest', - 'ListOffersResponse', - 'ListProductsRequest', - 'ListProductsResponse', - 'ListPurchasableOffersRequest', - 'ListPurchasableOffersResponse', - 'ListPurchasableSkusRequest', - 'ListPurchasableSkusResponse', - 'ListSkusRequest', - 'ListSkusResponse', - 'ListSubscribersRequest', - 'ListSubscribersResponse', - 'ListTransferableOffersRequest', - 'ListTransferableOffersResponse', - 'ListTransferableSkusRequest', - 'ListTransferableSkusResponse', - 'LookupOfferRequest', - 'ProvisionCloudIdentityRequest', - 'PurchasableOffer', - 'PurchasableSku', - 'RegisterSubscriberRequest', - 'RegisterSubscriberResponse', - 'StartPaidServiceRequest', - 'SuspendEntitlementRequest', - 'TransferableOffer', - 'TransferEntitlementsRequest', - 'TransferEntitlementsResponse', - 'TransferEntitlementsToGoogleRequest', - 'UnregisterSubscriberRequest', - 'UnregisterSubscriberResponse', - 'UpdateChannelPartnerLinkRequest', - 'UpdateCustomerRequest', - 'CustomerEvent', - 'EntitlementEvent', - 'SubscriberEvent', -) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/channel_partner_links.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/channel_partner_links.py deleted file mode 100644 index dbd464d..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/types/channel_partner_links.py +++ /dev/null @@ -1,123 +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.channel_v1.types import common -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.channel.v1', - manifest={ - 'ChannelPartnerLinkView', - 'ChannelPartnerLinkState', - 'ChannelPartnerLink', - }, -) - - -class ChannelPartnerLinkView(proto.Enum): - r"""The level of granularity the - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - will display. - """ - UNSPECIFIED = 0 - BASIC = 1 - FULL = 2 - - -class ChannelPartnerLinkState(proto.Enum): - r"""ChannelPartnerLinkState represents state of a channel partner - link. - """ - CHANNEL_PARTNER_LINK_STATE_UNSPECIFIED = 0 - INVITED = 1 - ACTIVE = 2 - REVOKED = 3 - SUSPENDED = 4 - - -class ChannelPartnerLink(proto.Message): - r"""Entity representing a link between distributors and their - indirect resellers in an n-tier resale channel. - - Attributes: - name (str): - Output only. Resource name for the channel partner link, in - the format accounts/{account_id}/channelPartnerLinks/{id}. - reseller_cloud_identity_id (str): - Required. Cloud Identity ID of the linked - reseller. - link_state (google.cloud.channel_v1.types.ChannelPartnerLinkState): - Required. State of the channel partner link. - invite_link_uri (str): - Output only. URI of the web page where - partner accepts the link invitation. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Timestamp of when the channel - partner link is created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Timestamp of when the channel - partner link is updated. - public_id (str): - Output only. Public identifier that a - customer must use to generate a transfer token - to move to this distributor-reseller - combination. - channel_partner_cloud_identity_info (google.cloud.channel_v1.types.CloudIdentityInfo): - Output only. Cloud Identity info of the - channel partner (IR). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - reseller_cloud_identity_id = proto.Field( - proto.STRING, - number=2, - ) - link_state = proto.Field( - proto.ENUM, - number=3, - enum='ChannelPartnerLinkState', - ) - invite_link_uri = proto.Field( - proto.STRING, - number=4, - ) - create_time = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - public_id = proto.Field( - proto.STRING, - number=7, - ) - channel_partner_cloud_identity_info = proto.Field( - proto.MESSAGE, - number=8, - message=common.CloudIdentityInfo, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/common.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/common.py deleted file mode 100644 index 931c263..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/types/common.py +++ /dev/null @@ -1,219 +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 any_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.channel.v1', - manifest={ - 'EduData', - 'CloudIdentityInfo', - 'Value', - 'AdminUser', - }, -) - - -class EduData(proto.Message): - r"""Required Edu Attributes - - Attributes: - institute_type (google.cloud.channel_v1.types.EduData.InstituteType): - Designated institute type of customer. - institute_size (google.cloud.channel_v1.types.EduData.InstituteSize): - Size of the institute. - website (str): - Web address for the edu customer's - institution. - """ - class InstituteType(proto.Enum): - r"""Enum to specify the institute type.""" - INSTITUTE_TYPE_UNSPECIFIED = 0 - K12 = 1 - UNIVERSITY = 2 - - class InstituteSize(proto.Enum): - r"""Number of students and staff the institute has.""" - INSTITUTE_SIZE_UNSPECIFIED = 0 - SIZE_1_100 = 1 - SIZE_101_500 = 2 - SIZE_501_1000 = 3 - SIZE_1001_2000 = 4 - SIZE_2001_5000 = 5 - SIZE_5001_10000 = 6 - SIZE_10001_OR_MORE = 7 - - institute_type = proto.Field( - proto.ENUM, - number=1, - enum=InstituteType, - ) - institute_size = proto.Field( - proto.ENUM, - number=2, - enum=InstituteSize, - ) - website = proto.Field( - proto.STRING, - number=3, - ) - - -class CloudIdentityInfo(proto.Message): - r"""Cloud Identity information for the Cloud Channel Customer. - - Attributes: - customer_type (google.cloud.channel_v1.types.CloudIdentityInfo.CustomerType): - CustomerType indicates verification type - needed for using services. - primary_domain (str): - Output only. The primary domain name. - is_domain_verified (bool): - Output only. Whether the domain is verified. This field is - not returned for a Customer's cloud_identity_info resource. - Partners can use the domains.get() method of the Workspace - SDK's Directory API, or listen to the - PRIMARY_DOMAIN_VERIFIED Pub/Sub event in to track domain - verification of their resolve Workspace customers. - alternate_email (str): - The alternate email. - phone_number (str): - Phone number associated with the Cloud - Identity. - language_code (str): - Language code. - admin_console_uri (str): - Output only. URI of Customer's Admin console - dashboard. - edu_data (google.cloud.channel_v1.types.EduData): - Edu information about the customer. - """ - class CustomerType(proto.Enum): - r"""CustomerType of the customer""" - CUSTOMER_TYPE_UNSPECIFIED = 0 - DOMAIN = 1 - TEAM = 2 - - customer_type = proto.Field( - proto.ENUM, - number=1, - enum=CustomerType, - ) - primary_domain = proto.Field( - proto.STRING, - number=9, - ) - is_domain_verified = proto.Field( - proto.BOOL, - number=4, - ) - alternate_email = proto.Field( - proto.STRING, - number=6, - ) - phone_number = proto.Field( - proto.STRING, - number=7, - ) - language_code = proto.Field( - proto.STRING, - number=8, - ) - admin_console_uri = proto.Field( - proto.STRING, - number=10, - ) - edu_data = proto.Field( - proto.MESSAGE, - number=22, - message='EduData', - ) - - -class Value(proto.Message): - r"""Data type and value of a parameter. - - Attributes: - int64_value (int): - Represents an int64 value. - string_value (str): - Represents a string value. - double_value (float): - Represents a double value. - proto_value (google.protobuf.any_pb2.Any): - Represents an 'Any' proto value. - bool_value (bool): - Represents a boolean value. - """ - - int64_value = proto.Field( - proto.INT64, - number=1, - oneof='kind', - ) - string_value = proto.Field( - proto.STRING, - number=2, - oneof='kind', - ) - double_value = proto.Field( - proto.DOUBLE, - number=3, - oneof='kind', - ) - proto_value = proto.Field( - proto.MESSAGE, - number=4, - oneof='kind', - message=any_pb2.Any, - ) - bool_value = proto.Field( - proto.BOOL, - number=5, - oneof='kind', - ) - - -class AdminUser(proto.Message): - r"""Information needed to create an Admin User for Google - Workspace. - - Attributes: - email (str): - Primary email of the admin user. - given_name (str): - Given name of the admin user. - family_name (str): - Family name of the admin user. - """ - - email = proto.Field( - proto.STRING, - number=1, - ) - given_name = proto.Field( - proto.STRING, - number=2, - ) - family_name = proto.Field( - proto.STRING, - number=3, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/customers.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/customers.py deleted file mode 100644 index 7e2d7a6..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/types/customers.py +++ /dev/null @@ -1,194 +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.channel_v1.types import common -from google.protobuf import timestamp_pb2 # type: ignore -from google.type import postal_address_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.channel.v1', - manifest={ - 'Customer', - 'ContactInfo', - }, -) - - -class Customer(proto.Message): - r"""Entity representing a customer of a reseller or distributor. - - Attributes: - name (str): - Output only. Resource name of the customer. Format: - accounts/{account_id}/customers/{customer_id} - org_display_name (str): - Required. Name of the organization that the - customer entity represents. - org_postal_address (google.type.postal_address_pb2.PostalAddress): - Required. The organization address for the - customer. To enforce US laws and embargoes, we - require a region and zip code. You must provide - valid addresses for every customer. To set the - customer's language, use the Customer-level - language code. - primary_contact_info (google.cloud.channel_v1.types.ContactInfo): - Primary contact info. - alternate_email (str): - Secondary contact email. You need to provide - an alternate email to create different domains - if a primary contact email already exists. Users - will receive a notification with credentials - when you create an admin.google.com account. - Secondary emails are also recovery email - addresses. Alternate emails are optional when - you create Team customers. - domain (str): - Required. The customer's primary domain. Must - match the primary contact email's domain. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when the customer was - created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Time when the customer was - updated. - cloud_identity_id (str): - Output only. The customer's Cloud Identity ID - if the customer has a Cloud Identity resource. - language_code (str): - Optional. The BCP-47 language code, such as "en-US" or - "sr-Latn". For more information, see - https://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - cloud_identity_info (google.cloud.channel_v1.types.CloudIdentityInfo): - Output only. Cloud Identity information for - the customer. Populated only if a Cloud Identity - account exists for this customer. - channel_partner_id (str): - Cloud Identity ID of the customer's channel - partner. Populated only if a channel partner - exists for this customer. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - org_display_name = proto.Field( - proto.STRING, - number=2, - ) - org_postal_address = proto.Field( - proto.MESSAGE, - number=3, - message=postal_address_pb2.PostalAddress, - ) - primary_contact_info = proto.Field( - proto.MESSAGE, - number=4, - message='ContactInfo', - ) - alternate_email = proto.Field( - proto.STRING, - number=5, - ) - domain = proto.Field( - proto.STRING, - number=6, - ) - create_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - cloud_identity_id = proto.Field( - proto.STRING, - number=9, - ) - language_code = proto.Field( - proto.STRING, - number=10, - ) - cloud_identity_info = proto.Field( - proto.MESSAGE, - number=12, - message=common.CloudIdentityInfo, - ) - channel_partner_id = proto.Field( - proto.STRING, - number=13, - ) - - -class ContactInfo(proto.Message): - r"""Contact information for a customer account. - - Attributes: - first_name (str): - The customer account contact's first name. - Optional for Team customers. - last_name (str): - The customer account contact's last name. - Optional for Team customers. - display_name (str): - Output only. The customer account contact's - display name, formatted as a combination of the - customer's first and last name. - email (str): - The customer account's contact email. - Required for entitlements that create - admin.google.com accounts, and serves as the - customer's username for those accounts. Use this - email to invite Team customers. - title (str): - Optional. The customer account contact's job - title. - phone (str): - The customer account's contact phone number. - """ - - first_name = proto.Field( - proto.STRING, - number=1, - ) - last_name = proto.Field( - proto.STRING, - number=2, - ) - display_name = proto.Field( - proto.STRING, - number=4, - ) - email = proto.Field( - proto.STRING, - number=5, - ) - title = proto.Field( - proto.STRING, - number=6, - ) - phone = proto.Field( - proto.STRING, - number=7, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/entitlements.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/entitlements.py deleted file mode 100644 index bd87901..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/types/entitlements.py +++ /dev/null @@ -1,403 +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.channel_v1.types import common -from google.cloud.channel_v1.types import offers -from google.cloud.channel_v1.types import products -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.channel.v1', - manifest={ - 'Entitlement', - 'Parameter', - 'AssociationInfo', - 'ProvisionedService', - 'CommitmentSettings', - 'RenewalSettings', - 'TrialSettings', - 'TransferableSku', - 'TransferEligibility', - }, -) - - -class Entitlement(proto.Message): - r"""An entitlement is a representation of a customer's ability to - use a service. - - Attributes: - name (str): - Output only. Resource name of an entitlement in the form: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id}. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which the - entitlement is created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which the - entitlement is updated. - offer (str): - Required. The offer resource name for which the entitlement - is to be created. Takes the form: - accounts/{account_id}/offers/{offer_id}. - commitment_settings (google.cloud.channel_v1.types.CommitmentSettings): - Commitment settings for a commitment-based - Offer. Required for commitment based offers. - provisioning_state (google.cloud.channel_v1.types.Entitlement.ProvisioningState): - Output only. Current provisioning state of - the entitlement. - provisioned_service (google.cloud.channel_v1.types.ProvisionedService): - Output only. Service provisioning details for - the entitlement. - suspension_reasons (Sequence[google.cloud.channel_v1.types.Entitlement.SuspensionReason]): - Output only. Enumerable of all current - suspension reasons for an entitlement. - purchase_order_id (str): - Optional. This purchase order (PO) - information is for resellers to use for their - company tracking usage. If a purchaseOrderId - value is given, it appears in the API responses - and shows up in the invoice. The property - accepts up to 80 plain text characters. - trial_settings (google.cloud.channel_v1.types.TrialSettings): - Output only. Settings for trial offers. - association_info (google.cloud.channel_v1.types.AssociationInfo): - Association information to other - entitlements. - parameters (Sequence[google.cloud.channel_v1.types.Parameter]): - Extended entitlement parameters. When - creating an entitlement, valid parameters' names - and values are defined in the offer's parameter - definitions. - """ - class ProvisioningState(proto.Enum): - r"""Indicates the current provisioning state of the entitlement.""" - PROVISIONING_STATE_UNSPECIFIED = 0 - ACTIVE = 1 - SUSPENDED = 5 - - class SuspensionReason(proto.Enum): - r"""Suspension reason for an entitlement if - [provisioning_state][google.cloud.channel.v1.Entitlement.provisioning_state] - = SUSPENDED. - """ - SUSPENSION_REASON_UNSPECIFIED = 0 - RESELLER_INITIATED = 1 - TRIAL_ENDED = 2 - RENEWAL_WITH_TYPE_CANCEL = 3 - PENDING_TOS_ACCEPTANCE = 4 - OTHER = 100 - - name = proto.Field( - proto.STRING, - number=1, - ) - create_time = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - offer = proto.Field( - proto.STRING, - number=8, - ) - commitment_settings = proto.Field( - proto.MESSAGE, - number=12, - message='CommitmentSettings', - ) - provisioning_state = proto.Field( - proto.ENUM, - number=13, - enum=ProvisioningState, - ) - provisioned_service = proto.Field( - proto.MESSAGE, - number=16, - message='ProvisionedService', - ) - suspension_reasons = proto.RepeatedField( - proto.ENUM, - number=18, - enum=SuspensionReason, - ) - purchase_order_id = proto.Field( - proto.STRING, - number=19, - ) - trial_settings = proto.Field( - proto.MESSAGE, - number=21, - message='TrialSettings', - ) - association_info = proto.Field( - proto.MESSAGE, - number=23, - message='AssociationInfo', - ) - parameters = proto.RepeatedField( - proto.MESSAGE, - number=26, - message='Parameter', - ) - - -class Parameter(proto.Message): - r"""Definition for extended entitlement parameters. - - Attributes: - name (str): - Name of the parameter. - value (google.cloud.channel_v1.types.Value): - Value of the parameter. - editable (bool): - Output only. Specifies whether this parameter is allowed to - be changed. For example, for a Google Workspace Business - Starter entitlement in commitment plan, num_units is - editable when entitlement is active. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - value = proto.Field( - proto.MESSAGE, - number=2, - message=common.Value, - ) - editable = proto.Field( - proto.BOOL, - number=3, - ) - - -class AssociationInfo(proto.Message): - r"""Association links that an entitlement has to other - entitlements. - - Attributes: - base_entitlement (str): - The name of the base entitlement, for which - this entitlement is an add-on. - """ - - base_entitlement = proto.Field( - proto.STRING, - number=1, - ) - - -class ProvisionedService(proto.Message): - r"""Service provisioned for an entitlement. - - Attributes: - provisioning_id (str): - Output only. Provisioning ID of the - entitlement. For Google Workspace, this would be - the underlying Subscription ID. - product_id (str): - Output only. The product pertaining to the - provisioning resource as specified in the Offer. - sku_id (str): - Output only. The SKU pertaining to the - provisioning resource as specified in the Offer. - """ - - provisioning_id = proto.Field( - proto.STRING, - number=1, - ) - product_id = proto.Field( - proto.STRING, - number=2, - ) - sku_id = proto.Field( - proto.STRING, - number=3, - ) - - -class CommitmentSettings(proto.Message): - r"""Commitment settings for commitment-based offers. - - Attributes: - start_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Commitment start timestamp. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Commitment end timestamp. - renewal_settings (google.cloud.channel_v1.types.RenewalSettings): - Optional. Renewal settings applicable for a - commitment-based Offer. - """ - - start_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - renewal_settings = proto.Field( - proto.MESSAGE, - number=4, - message='RenewalSettings', - ) - - -class RenewalSettings(proto.Message): - r"""Renewal settings for renewable Offers. - - Attributes: - enable_renewal (bool): - If false, the plan will be completed at the - end date. - resize_unit_count (bool): - If true and enable_renewal = true, the unit (for example - seats or licenses) will be set to the number of active units - at renewal time. - payment_plan (google.cloud.channel_v1.types.PaymentPlan): - Describes how a reseller will be billed. - payment_cycle (google.cloud.channel_v1.types.Period): - Describes how frequently the reseller will be - billed, such as once per month. - """ - - enable_renewal = proto.Field( - proto.BOOL, - number=1, - ) - resize_unit_count = proto.Field( - proto.BOOL, - number=2, - ) - payment_plan = proto.Field( - proto.ENUM, - number=5, - enum=offers.PaymentPlan, - ) - payment_cycle = proto.Field( - proto.MESSAGE, - number=6, - message=offers.Period, - ) - - -class TrialSettings(proto.Message): - r"""Settings for trial offers. - - Attributes: - trial (bool): - Determines if the entitlement is in a trial or not: - - - ``true`` - The entitlement is in trial. - - ``false`` - The entitlement is not in trial. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Date when the trial ends. The value is in milliseconds using - the UNIX Epoch format. See an example `Epoch - converter `__. - """ - - trial = proto.Field( - proto.BOOL, - number=1, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - - -class TransferableSku(proto.Message): - r"""TransferableSku represents information a reseller needs to - view existing provisioned services for a customer that they do - not own. Read-only. - - Attributes: - transfer_eligibility (google.cloud.channel_v1.types.TransferEligibility): - Describes the transfer eligibility of a SKU. - sku (google.cloud.channel_v1.types.Sku): - The SKU pertaining to the provisioning - resource as specified in the Offer. - legacy_sku (google.cloud.channel_v1.types.Sku): - Optional. The customer to transfer has an - entitlement with the populated legacy SKU. - """ - - transfer_eligibility = proto.Field( - proto.MESSAGE, - number=9, - message='TransferEligibility', - ) - sku = proto.Field( - proto.MESSAGE, - number=11, - message=products.Sku, - ) - legacy_sku = proto.Field( - proto.MESSAGE, - number=12, - message=products.Sku, - ) - - -class TransferEligibility(proto.Message): - r"""Specifies transfer eligibility of a SKU. - - Attributes: - is_eligible (bool): - Whether reseller is eligible to transfer the - SKU. - description (str): - Localized description if reseller is not - eligible to transfer the SKU. - ineligibility_reason (google.cloud.channel_v1.types.TransferEligibility.Reason): - Specified the reason for ineligibility. - """ - class Reason(proto.Enum): - r"""Reason of ineligibility.""" - REASON_UNSPECIFIED = 0 - PENDING_TOS_ACCEPTANCE = 1 - SKU_NOT_ELIGIBLE = 2 - SKU_SUSPENDED = 3 - - is_eligible = proto.Field( - proto.BOOL, - number=1, - ) - description = proto.Field( - proto.STRING, - number=2, - ) - ineligibility_reason = proto.Field( - proto.ENUM, - number=3, - enum=Reason, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/offers.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/offers.py deleted file mode 100644 index 9a6bea1..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/types/offers.py +++ /dev/null @@ -1,503 +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.channel_v1.types import common -from google.cloud.channel_v1.types import products -from google.protobuf import timestamp_pb2 # type: ignore -from google.type import money_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.channel.v1', - manifest={ - 'PromotionalOrderType', - 'PaymentPlan', - 'PaymentType', - 'ResourceType', - 'PeriodType', - 'Offer', - 'ParameterDefinition', - 'Constraints', - 'CustomerConstraints', - 'Plan', - 'PriceByResource', - 'Price', - 'PricePhase', - 'PriceTier', - 'Period', - }, -) - - -class PromotionalOrderType(proto.Enum): - r"""Constraints type for Promotional offers.""" - PROMOTIONAL_TYPE_UNSPECIFIED = 0 - NEW_UPGRADE = 1 - TRANSFER = 2 - PROMOTION_SWITCH = 3 - - -class PaymentPlan(proto.Enum): - r"""Describes how the reseller will be billed.""" - PAYMENT_PLAN_UNSPECIFIED = 0 - COMMITMENT = 1 - FLEXIBLE = 2 - FREE = 3 - TRIAL = 4 - OFFLINE = 5 - - -class PaymentType(proto.Enum): - r"""Specifies when the payment needs to happen.""" - PAYMENT_TYPE_UNSPECIFIED = 0 - PREPAY = 1 - POSTPAY = 2 - - -class ResourceType(proto.Enum): - r"""Represents the type for a monetizable resource(any entity on - which billing happens). For example, this could be MINUTES for - Google Voice and GB for Google Drive. One SKU can map to - multiple monetizable resources. - """ - RESOURCE_TYPE_UNSPECIFIED = 0 - SEAT = 1 - MAU = 2 - GB = 3 - LICENSED_USER = 4 - MINUTES = 5 - IAAS_USAGE = 6 - SUBSCRIPTION = 7 - - -class PeriodType(proto.Enum): - r"""Period Type.""" - PERIOD_TYPE_UNSPECIFIED = 0 - DAY = 1 - MONTH = 2 - YEAR = 3 - - -class Offer(proto.Message): - r"""Represents an offer made to resellers for purchase. An offer is - associated with a [Sku][google.cloud.channel.v1.Sku], has a plan for - payment, a price, and defines the constraints for buying. - - Attributes: - name (str): - Resource Name of the Offer. Format: - accounts/{account_id}/offers/{offer_id} - marketing_info (google.cloud.channel_v1.types.MarketingInfo): - Marketing information for the Offer. - sku (google.cloud.channel_v1.types.Sku): - SKU the offer is associated with. - plan (google.cloud.channel_v1.types.Plan): - Describes the payment plan for the Offer. - constraints (google.cloud.channel_v1.types.Constraints): - Constraints on transacting the Offer. - price_by_resources (Sequence[google.cloud.channel_v1.types.PriceByResource]): - Price for each monetizable resource type. - start_time (google.protobuf.timestamp_pb2.Timestamp): - Start of the Offer validity time. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. End of the Offer validity time. - parameter_definitions (Sequence[google.cloud.channel_v1.types.ParameterDefinition]): - Parameters required to use current Offer to - purchase. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - marketing_info = proto.Field( - proto.MESSAGE, - number=2, - message=products.MarketingInfo, - ) - sku = proto.Field( - proto.MESSAGE, - number=3, - message=products.Sku, - ) - plan = proto.Field( - proto.MESSAGE, - number=4, - message='Plan', - ) - constraints = proto.Field( - proto.MESSAGE, - number=5, - message='Constraints', - ) - price_by_resources = proto.RepeatedField( - proto.MESSAGE, - number=6, - message='PriceByResource', - ) - start_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - parameter_definitions = proto.RepeatedField( - proto.MESSAGE, - number=9, - message='ParameterDefinition', - ) - - -class ParameterDefinition(proto.Message): - r"""Parameter's definition. Specifies what parameter is required - to use the current Offer to purchase. - - Attributes: - name (str): - Name of the parameter. - parameter_type (google.cloud.channel_v1.types.ParameterDefinition.ParameterType): - Data type of the parameter. Minimal value, - Maximum value and allowed values will use - specified data type here. - min_value (google.cloud.channel_v1.types.Value): - Minimal value of the parameter, if - applicable. Inclusive. For example, minimal - commitment when purchasing Anthos is 0.01. - Applicable to INT64 and DOUBLE parameter types. - max_value (google.cloud.channel_v1.types.Value): - Maximum value of the parameter, if - applicable. Inclusive. For example, maximum - seats when purchasing Google Workspace Business - Standard. Applicable to INT64 and DOUBLE - parameter types. - allowed_values (Sequence[google.cloud.channel_v1.types.Value]): - If not empty, parameter values must be drawn from this list. - For example, [us-west1, us-west2, ...] Applicable to STRING - parameter type. - optional (bool): - If set to true, parameter is optional to - purchase this Offer. - """ - class ParameterType(proto.Enum): - r"""Data type of the parameter.""" - PARAMETER_TYPE_UNSPECIFIED = 0 - INT64 = 1 - STRING = 2 - DOUBLE = 3 - - name = proto.Field( - proto.STRING, - number=1, - ) - parameter_type = proto.Field( - proto.ENUM, - number=2, - enum=ParameterType, - ) - min_value = proto.Field( - proto.MESSAGE, - number=3, - message=common.Value, - ) - max_value = proto.Field( - proto.MESSAGE, - number=4, - message=common.Value, - ) - allowed_values = proto.RepeatedField( - proto.MESSAGE, - number=5, - message=common.Value, - ) - optional = proto.Field( - proto.BOOL, - number=6, - ) - - -class Constraints(proto.Message): - r"""Represents the constraints for buying the Offer. - - Attributes: - customer_constraints (google.cloud.channel_v1.types.CustomerConstraints): - Represents constraints required to purchase - the Offer for a customer. - """ - - customer_constraints = proto.Field( - proto.MESSAGE, - number=1, - message='CustomerConstraints', - ) - - -class CustomerConstraints(proto.Message): - r"""Represents constraints required to purchase the Offer for a - customer. - - Attributes: - allowed_regions (Sequence[str]): - Allowed geographical regions of the customer. - allowed_customer_types (Sequence[google.cloud.channel_v1.types.CloudIdentityInfo.CustomerType]): - Allowed Customer Type. - promotional_order_types (Sequence[google.cloud.channel_v1.types.PromotionalOrderType]): - Allowed Promotional Order Type. Present for - Promotional offers. - """ - - allowed_regions = proto.RepeatedField( - proto.STRING, - number=1, - ) - allowed_customer_types = proto.RepeatedField( - proto.ENUM, - number=2, - enum=common.CloudIdentityInfo.CustomerType, - ) - promotional_order_types = proto.RepeatedField( - proto.ENUM, - number=3, - enum='PromotionalOrderType', - ) - - -class Plan(proto.Message): - r"""The payment plan for the Offer. Describes how to make a - payment. - - Attributes: - payment_plan (google.cloud.channel_v1.types.PaymentPlan): - Describes how a reseller will be billed. - payment_type (google.cloud.channel_v1.types.PaymentType): - Specifies when the payment needs to happen. - payment_cycle (google.cloud.channel_v1.types.Period): - Describes how frequently the reseller will be - billed, such as once per month. - trial_period (google.cloud.channel_v1.types.Period): - Present for Offers with a trial period. - For trial-only Offers, a paid service needs to - start before the trial period ends for continued - service. - For Regular Offers with a trial period, the - regular pricing goes into effect when trial - period ends, or if paid service is started - before the end of the trial period. - billing_account (str): - Reseller Billing account to charge after an - offer transaction. Only present for Google Cloud - Platform offers. - """ - - payment_plan = proto.Field( - proto.ENUM, - number=1, - enum='PaymentPlan', - ) - payment_type = proto.Field( - proto.ENUM, - number=2, - enum='PaymentType', - ) - payment_cycle = proto.Field( - proto.MESSAGE, - number=3, - message='Period', - ) - trial_period = proto.Field( - proto.MESSAGE, - number=4, - message='Period', - ) - billing_account = proto.Field( - proto.STRING, - number=5, - ) - - -class PriceByResource(proto.Message): - r"""Represents price by resource type. - - Attributes: - resource_type (google.cloud.channel_v1.types.ResourceType): - Resource Type. Example: SEAT - price (google.cloud.channel_v1.types.Price): - Price of the Offer. Present if there are no - price phases. - price_phases (Sequence[google.cloud.channel_v1.types.PricePhase]): - Specifies the price by time range. - """ - - resource_type = proto.Field( - proto.ENUM, - number=1, - enum='ResourceType', - ) - price = proto.Field( - proto.MESSAGE, - number=2, - message='Price', - ) - price_phases = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='PricePhase', - ) - - -class Price(proto.Message): - r"""Represents the price of the Offer. - - Attributes: - base_price (google.type.money_pb2.Money): - Base price. - discount (float): - Discount percentage, represented as decimal. - For example, a 20% discount will be represent as - 0.2. - effective_price (google.type.money_pb2.Money): - Effective Price after applying the discounts. - external_price_uri (str): - Link to external price list, such as link to - Google Voice rate card. - """ - - base_price = proto.Field( - proto.MESSAGE, - number=1, - message=money_pb2.Money, - ) - discount = proto.Field( - proto.DOUBLE, - number=2, - ) - effective_price = proto.Field( - proto.MESSAGE, - number=3, - message=money_pb2.Money, - ) - external_price_uri = proto.Field( - proto.STRING, - number=4, - ) - - -class PricePhase(proto.Message): - r"""Specifies the price by the duration of months. - For example, a 20% discount for the first six months, then a 10% - discount starting on the seventh month. - - Attributes: - period_type (google.cloud.channel_v1.types.PeriodType): - Defines the phase period type. - first_period (int): - Defines first period for the phase. - last_period (int): - Defines first period for the phase. - price (google.cloud.channel_v1.types.Price): - Price of the phase. Present if there are no - price tiers. - price_tiers (Sequence[google.cloud.channel_v1.types.PriceTier]): - Price by the resource tiers. - """ - - period_type = proto.Field( - proto.ENUM, - number=1, - enum='PeriodType', - ) - first_period = proto.Field( - proto.INT32, - number=2, - ) - last_period = proto.Field( - proto.INT32, - number=3, - ) - price = proto.Field( - proto.MESSAGE, - number=4, - message='Price', - ) - price_tiers = proto.RepeatedField( - proto.MESSAGE, - number=5, - message='PriceTier', - ) - - -class PriceTier(proto.Message): - r"""Defines price at resource tier level. For example, an offer with - following definition : - - - Tier 1: Provide 25% discount for all seats between 1 and 25. - - Tier 2: Provide 10% discount for all seats between 26 and 100. - - Tier 3: Provide flat 15% discount for all seats above 100. - - Each of these tiers is represented as a PriceTier. - - Attributes: - first_resource (int): - First resource for which the tier price - applies. - last_resource (int): - Last resource for which the tier price - applies. - price (google.cloud.channel_v1.types.Price): - Price of the tier. - """ - - first_resource = proto.Field( - proto.INT32, - number=1, - ) - last_resource = proto.Field( - proto.INT32, - number=2, - ) - price = proto.Field( - proto.MESSAGE, - number=3, - message='Price', - ) - - -class Period(proto.Message): - r"""Represents period in days/months/years. - - Attributes: - duration (int): - Total duration of Period Type defined. - period_type (google.cloud.channel_v1.types.PeriodType): - Period Type. - """ - - duration = proto.Field( - proto.INT32, - number=1, - ) - period_type = proto.Field( - proto.ENUM, - number=2, - enum='PeriodType', - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/operations.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/operations.py deleted file mode 100644 index e561f46..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/types/operations.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import proto # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.channel.v1', - manifest={ - 'OperationMetadata', - }, -) - - -class OperationMetadata(proto.Message): - r"""Provides contextual information about a - [google.longrunning.Operation][google.longrunning.Operation]. - - Attributes: - operation_type (google.cloud.channel_v1.types.OperationMetadata.OperationType): - The RPC that initiated this Long Running - Operation. - """ - class OperationType(proto.Enum): - r"""RPCs that return a Long Running Operation.""" - OPERATION_TYPE_UNSPECIFIED = 0 - CREATE_ENTITLEMENT = 1 - CHANGE_RENEWAL_SETTINGS = 3 - START_PAID_SERVICE = 5 - ACTIVATE_ENTITLEMENT = 7 - SUSPEND_ENTITLEMENT = 8 - CANCEL_ENTITLEMENT = 9 - TRANSFER_ENTITLEMENTS = 10 - TRANSFER_ENTITLEMENTS_TO_GOOGLE = 11 - CHANGE_OFFER = 14 - CHANGE_PARAMETERS = 15 - PROVISION_CLOUD_IDENTITY = 16 - - operation_type = proto.Field( - proto.ENUM, - number=1, - enum=OperationType, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/products.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/products.py deleted file mode 100644 index f4fe721..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/types/products.py +++ /dev/null @@ -1,147 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import proto # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.channel.v1', - manifest={ - 'MediaType', - 'Product', - 'Sku', - 'MarketingInfo', - 'Media', - }, -) - - -class MediaType(proto.Enum): - r"""Type of media used.""" - MEDIA_TYPE_UNSPECIFIED = 0 - MEDIA_TYPE_IMAGE = 1 - - -class Product(proto.Message): - r"""A Product is the entity a customer uses when placing an - order. For example, Google Workspace, Google Voice, etc. - - Attributes: - name (str): - Resource Name of the Product. Format: products/{product_id} - marketing_info (google.cloud.channel_v1.types.MarketingInfo): - Marketing information for the product. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - marketing_info = proto.Field( - proto.MESSAGE, - number=2, - message='MarketingInfo', - ) - - -class Sku(proto.Message): - r"""Represents a product's purchasable Stock Keeping Unit (SKU). - SKUs represent the different variations of the product. For - example, Google Workspace Business Standard and Google Workspace - Business Plus are Google Workspace product SKUs. - - Attributes: - name (str): - Resource Name of the SKU. Format: - products/{product_id}/skus/{sku_id} - marketing_info (google.cloud.channel_v1.types.MarketingInfo): - Marketing information for the SKU. - product (google.cloud.channel_v1.types.Product): - Product the SKU is associated with. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - marketing_info = proto.Field( - proto.MESSAGE, - number=2, - message='MarketingInfo', - ) - product = proto.Field( - proto.MESSAGE, - number=3, - message='Product', - ) - - -class MarketingInfo(proto.Message): - r"""Represents the marketing information for a Product, SKU or - Offer. - - Attributes: - display_name (str): - Human readable name. - description (str): - Human readable description. Description can - contain HTML. - default_logo (google.cloud.channel_v1.types.Media): - Default logo. - """ - - display_name = proto.Field( - proto.STRING, - number=1, - ) - description = proto.Field( - proto.STRING, - number=2, - ) - default_logo = proto.Field( - proto.MESSAGE, - number=3, - message='Media', - ) - - -class Media(proto.Message): - r"""Represents media information. - - Attributes: - title (str): - Title of the media. - content (str): - URL of the media. - type_ (google.cloud.channel_v1.types.MediaType): - Type of the media. - """ - - title = proto.Field( - proto.STRING, - number=1, - ) - content = proto.Field( - proto.STRING, - number=2, - ) - type_ = proto.Field( - proto.ENUM, - number=3, - enum='MediaType', - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/service.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/service.py deleted file mode 100644 index d078f46..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/types/service.py +++ /dev/null @@ -1,1991 +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.channel_v1.types import channel_partner_links as gcc_channel_partner_links -from google.cloud.channel_v1.types import common -from google.cloud.channel_v1.types import customers as gcc_customers -from google.cloud.channel_v1.types import entitlements as gcc_entitlements -from google.cloud.channel_v1.types import offers as gcc_offers -from google.cloud.channel_v1.types import products as gcc_products -from google.protobuf import field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.channel.v1', - manifest={ - 'CheckCloudIdentityAccountsExistRequest', - 'CloudIdentityCustomerAccount', - 'CheckCloudIdentityAccountsExistResponse', - 'ListCustomersRequest', - 'ListCustomersResponse', - 'GetCustomerRequest', - 'CreateCustomerRequest', - 'UpdateCustomerRequest', - 'DeleteCustomerRequest', - 'ImportCustomerRequest', - 'ProvisionCloudIdentityRequest', - 'ListEntitlementsRequest', - 'ListEntitlementsResponse', - 'ListTransferableSkusRequest', - 'ListTransferableSkusResponse', - 'ListTransferableOffersRequest', - 'ListTransferableOffersResponse', - 'TransferableOffer', - 'GetEntitlementRequest', - 'ListChannelPartnerLinksRequest', - 'ListChannelPartnerLinksResponse', - 'GetChannelPartnerLinkRequest', - 'CreateChannelPartnerLinkRequest', - 'UpdateChannelPartnerLinkRequest', - 'CreateEntitlementRequest', - 'TransferEntitlementsRequest', - 'TransferEntitlementsResponse', - 'TransferEntitlementsToGoogleRequest', - 'ChangeParametersRequest', - 'ChangeRenewalSettingsRequest', - 'ChangeOfferRequest', - 'StartPaidServiceRequest', - 'CancelEntitlementRequest', - 'SuspendEntitlementRequest', - 'ActivateEntitlementRequest', - 'LookupOfferRequest', - 'ListProductsRequest', - 'ListProductsResponse', - 'ListSkusRequest', - 'ListSkusResponse', - 'ListOffersRequest', - 'ListOffersResponse', - 'ListPurchasableSkusRequest', - 'ListPurchasableSkusResponse', - 'PurchasableSku', - 'ListPurchasableOffersRequest', - 'ListPurchasableOffersResponse', - 'PurchasableOffer', - 'RegisterSubscriberRequest', - 'RegisterSubscriberResponse', - 'UnregisterSubscriberRequest', - 'UnregisterSubscriberResponse', - 'ListSubscribersRequest', - 'ListSubscribersResponse', - }, -) - - -class CheckCloudIdentityAccountsExistRequest(proto.Message): - r"""Request message for - [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist]. - - Attributes: - parent (str): - Required. The reseller account's resource name. Parent uses - the format: accounts/{account_id} - domain (str): - Required. Domain to fetch for Cloud Identity - account customer. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - domain = proto.Field( - proto.STRING, - number=2, - ) - - -class CloudIdentityCustomerAccount(proto.Message): - r"""Entity representing a Cloud Identity account that may be - associated with a Channel Services API partner. - - Attributes: - existing (bool): - Returns true if a Cloud Identity account - exists for a specific domain. - owned (bool): - Returns true if the Cloud Identity account is - associated with a customer of the Channel - Services partner. - customer_name (str): - If owned = true, the name of the customer that owns the - Cloud Identity account. Customer_name uses the format: - accounts/{account_id}/customers/{customer_id} - customer_cloud_identity_id (str): - If existing = true, the Cloud Identity ID of - the customer. - """ - - existing = proto.Field( - proto.BOOL, - number=1, - ) - owned = proto.Field( - proto.BOOL, - number=2, - ) - customer_name = proto.Field( - proto.STRING, - number=3, - ) - customer_cloud_identity_id = proto.Field( - proto.STRING, - number=4, - ) - - -class CheckCloudIdentityAccountsExistResponse(proto.Message): - r"""Response message for - [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist]. - - Attributes: - cloud_identity_accounts (Sequence[google.cloud.channel_v1.types.CloudIdentityCustomerAccount]): - The Cloud Identity accounts associated with - the domain. - """ - - cloud_identity_accounts = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='CloudIdentityCustomerAccount', - ) - - -class ListCustomersRequest(proto.Message): - r"""Request message for - [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers] - - Attributes: - parent (str): - Required. The resource name of the reseller account to list - customers from. Parent uses the format: - accounts/{account_id}. - page_size (int): - Optional. The maximum number of customers to - return. The service may return fewer than this - value. If unspecified, returns at most 10 - customers. The maximum value is 50. - page_token (str): - Optional. A token identifying a page of results other than - the first page. Obtained through - [ListCustomersResponse.next_page_token][google.cloud.channel.v1.ListCustomersResponse.next_page_token] - of the previous - [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers] - call. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - - -class ListCustomersResponse(proto.Message): - r"""Response message for - [CloudChannelService.ListCustomers][google.cloud.channel.v1.CloudChannelService.ListCustomers]. - - Attributes: - customers (Sequence[google.cloud.channel_v1.types.Customer]): - The customers belonging to a reseller or - distributor. - next_page_token (str): - A token to retrieve the next page of results. Pass to - [ListCustomersRequest.page_token][google.cloud.channel.v1.ListCustomersRequest.page_token] - to obtain that page. - """ - - @property - def raw_page(self): - return self - - customers = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gcc_customers.Customer, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class GetCustomerRequest(proto.Message): - r"""Request message for - [CloudChannelService.GetCustomer][google.cloud.channel.v1.CloudChannelService.GetCustomer]. - - Attributes: - name (str): - Required. The resource name of the customer to retrieve. - Name uses the format: - accounts/{account_id}/customers/{customer_id} - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateCustomerRequest(proto.Message): - r"""Request message for - [CloudChannelService.CreateCustomer][google.cloud.channel.v1.CloudChannelService.CreateCustomer] - - Attributes: - parent (str): - Required. The resource name of reseller account in which to - create the customer. Parent uses the format: - accounts/{account_id} - customer (google.cloud.channel_v1.types.Customer): - Required. The customer to create. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - customer = proto.Field( - proto.MESSAGE, - number=2, - message=gcc_customers.Customer, - ) - - -class UpdateCustomerRequest(proto.Message): - r"""Request message for - [CloudChannelService.UpdateCustomer][google.cloud.channel.v1.CloudChannelService.UpdateCustomer]. - - Attributes: - customer (google.cloud.channel_v1.types.Customer): - Required. New contents of the customer. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask that applies to the resource. - Optional. - """ - - customer = proto.Field( - proto.MESSAGE, - number=2, - message=gcc_customers.Customer, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteCustomerRequest(proto.Message): - r"""Request message for - [CloudChannelService.DeleteCustomer][google.cloud.channel.v1.CloudChannelService.DeleteCustomer]. - - Attributes: - name (str): - Required. The resource name of the customer - to delete. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ImportCustomerRequest(proto.Message): - r"""Request message for - [CloudChannelService.ImportCustomer][google.cloud.channel.v1.CloudChannelService.ImportCustomer] - - Attributes: - domain (str): - Required. Customer domain. - cloud_identity_id (str): - Required. Customer's Cloud Identity ID - parent (str): - Required. The resource name of the reseller's account. - Parent takes the format: accounts/{account_id} or - accounts/{account_id}/channelPartnerLinks/{channel_partner_id} - auth_token (str): - Optional. The super admin of the resold - customer generates this token to authorize a - reseller to access their Cloud Identity and - purchase entitlements on their behalf. You can - omit this token after authorization. See - https://support.google.com/a/answer/7643790 for - more details. - overwrite_if_exists (bool): - Required. Choose to overwrite an existing - customer if found. This must be set to true if - there is an existing customer with a conflicting - region code or domain. - channel_partner_id (str): - Optional. Cloud Identity ID of a channel - partner who will be the direct reseller for the - customer's order. This field is required for - 2-tier transfer scenarios and can be provided - via the request Parent binding as well. - customer (str): - Optional. Specifies the customer that will receive imported - Cloud Identity information. Format: - accounts/{account_id}/customers/{customer_id} - """ - - domain = proto.Field( - proto.STRING, - number=2, - oneof='customer_identity', - ) - cloud_identity_id = proto.Field( - proto.STRING, - number=3, - oneof='customer_identity', - ) - parent = proto.Field( - proto.STRING, - number=1, - ) - auth_token = proto.Field( - proto.STRING, - number=4, - ) - overwrite_if_exists = proto.Field( - proto.BOOL, - number=5, - ) - channel_partner_id = proto.Field( - proto.STRING, - number=6, - ) - customer = proto.Field( - proto.STRING, - number=7, - ) - - -class ProvisionCloudIdentityRequest(proto.Message): - r"""Request message for - [CloudChannelService.ProvisionCloudIdentity][google.cloud.channel.v1.CloudChannelService.ProvisionCloudIdentity] - - Attributes: - customer (str): - Required. Resource name of the customer. Format: - accounts/{account_id}/customers/{customer_id} - cloud_identity_info (google.cloud.channel_v1.types.CloudIdentityInfo): - CloudIdentity-specific customer information. - user (google.cloud.channel_v1.types.AdminUser): - Admin user information. - validate_only (bool): - Validate the request and preview the review, - but do not post it. - """ - - customer = proto.Field( - proto.STRING, - number=1, - ) - cloud_identity_info = proto.Field( - proto.MESSAGE, - number=2, - message=common.CloudIdentityInfo, - ) - user = proto.Field( - proto.MESSAGE, - number=3, - message=common.AdminUser, - ) - validate_only = proto.Field( - proto.BOOL, - number=4, - ) - - -class ListEntitlementsRequest(proto.Message): - r"""Request message for - [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements] - - Attributes: - parent (str): - Required. The resource name of the reseller's customer - account to list entitlements for. Parent uses the format: - accounts/{account_id}/customers/{customer_id} - page_size (int): - Optional. Requested page size. Server might - return fewer results than requested. If - unspecified, return at most 50 entitlements. The - maximum value is 100; the server will coerce - values above 100. - page_token (str): - Optional. A token for a page of results other than the first - page. Obtained using - [ListEntitlementsResponse.next_page_token][google.cloud.channel.v1.ListEntitlementsResponse.next_page_token] - of the previous - [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements] - call. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - - -class ListEntitlementsResponse(proto.Message): - r"""Response message for - [CloudChannelService.ListEntitlements][google.cloud.channel.v1.CloudChannelService.ListEntitlements]. - - Attributes: - entitlements (Sequence[google.cloud.channel_v1.types.Entitlement]): - The reseller customer's entitlements. - next_page_token (str): - A token to list the next page of results. Pass to - [ListEntitlementsRequest.page_token][google.cloud.channel.v1.ListEntitlementsRequest.page_token] - to obtain that page. - """ - - @property - def raw_page(self): - return self - - entitlements = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gcc_entitlements.Entitlement, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class ListTransferableSkusRequest(proto.Message): - r"""Request message for - [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus] - - Attributes: - cloud_identity_id (str): - Customer's Cloud Identity ID - customer_name (str): - A reseller is required to create a customer and use the - resource name of the created customer here. Customer_name - uses the format: - accounts/{account_id}/customers/{customer_id} - parent (str): - Required. The reseller account's resource name. Parent uses - the format: accounts/{account_id} - page_size (int): - The requested page size. Server might return - fewer results than requested. If unspecified, - returns at most 100 SKUs. The maximum value is - 1000; the server will coerce values above 1000. - Optional. - page_token (str): - A token for a page of results other than the first page. - Obtained using - [ListTransferableSkusResponse.next_page_token][google.cloud.channel.v1.ListTransferableSkusResponse.next_page_token] - of the previous - [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus] - call. Optional. - auth_token (str): - The super admin of the resold customer - generates this token to authorize a reseller to - access their Cloud Identity and purchase - entitlements on their behalf. You can omit this - token after authorization. See - https://support.google.com/a/answer/7643790 for - more details. - language_code (str): - The BCP-47 language code. For example, "en- - S". The response will localize in the - corresponding language code, if specified. The - default value is "en-US". - Optional. - """ - - cloud_identity_id = proto.Field( - proto.STRING, - number=4, - oneof='transferred_customer_identity', - ) - customer_name = proto.Field( - proto.STRING, - number=7, - oneof='transferred_customer_identity', - ) - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - auth_token = proto.Field( - proto.STRING, - number=5, - ) - language_code = proto.Field( - proto.STRING, - number=6, - ) - - -class ListTransferableSkusResponse(proto.Message): - r"""Response message for - [CloudChannelService.ListTransferableSkus][google.cloud.channel.v1.CloudChannelService.ListTransferableSkus]. - - Attributes: - transferable_skus (Sequence[google.cloud.channel_v1.types.TransferableSku]): - Information about existing SKUs for a - customer that needs a transfer. - next_page_token (str): - A token to retrieve the next page of results. Pass to - [ListTransferableSkusRequest.page_token][google.cloud.channel.v1.ListTransferableSkusRequest.page_token] - to obtain that page. - """ - - @property - def raw_page(self): - return self - - transferable_skus = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gcc_entitlements.TransferableSku, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class ListTransferableOffersRequest(proto.Message): - r"""Request message for - [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers] - - Attributes: - cloud_identity_id (str): - Customer's Cloud Identity ID - customer_name (str): - A reseller should create a customer and use - the resource name of that customer here. - parent (str): - Required. The resource name of the reseller's - account. - page_size (int): - Requested page size. Server might return - fewer results than requested. If unspecified, - returns at most 100 offers. The maximum value is - 1000; the server will coerce values above 1000. - page_token (str): - A token for a page of results other than the first page. - Obtained using - [ListTransferableOffersResponse.next_page_token][google.cloud.channel.v1.ListTransferableOffersResponse.next_page_token] - of the previous - [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers] - call. - sku (str): - Required. The SKU to look up Offers for. - language_code (str): - The BCP-47 language code. For example, "en- - S". The response will localize in the - corresponding language code, if specified. The - default value is "en-US". - """ - - cloud_identity_id = proto.Field( - proto.STRING, - number=4, - oneof='transferred_customer_identity', - ) - customer_name = proto.Field( - proto.STRING, - number=5, - oneof='transferred_customer_identity', - ) - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - sku = proto.Field( - proto.STRING, - number=6, - ) - language_code = proto.Field( - proto.STRING, - number=7, - ) - - -class ListTransferableOffersResponse(proto.Message): - r"""Response message for - [CloudChannelService.ListTransferableOffers][google.cloud.channel.v1.CloudChannelService.ListTransferableOffers]. - - Attributes: - transferable_offers (Sequence[google.cloud.channel_v1.types.TransferableOffer]): - Information about Offers for a customer that - can be used for transfer. - next_page_token (str): - A token to retrieve the next page of results. Pass to - [ListTransferableOffersRequest.page_token][google.cloud.channel.v1.ListTransferableOffersRequest.page_token] - to obtain that page. - """ - - @property - def raw_page(self): - return self - - transferable_offers = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='TransferableOffer', - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class TransferableOffer(proto.Message): - r"""TransferableOffer represents an Offer that can be used in - Transfer. Read-only. - - Attributes: - offer (google.cloud.channel_v1.types.Offer): - Offer with parameter constraints updated to - allow the Transfer. - """ - - offer = proto.Field( - proto.MESSAGE, - number=1, - message=gcc_offers.Offer, - ) - - -class GetEntitlementRequest(proto.Message): - r"""Request message for - [CloudChannelService.GetEntitlement][google.cloud.channel.v1.CloudChannelService.GetEntitlement]. - - Attributes: - name (str): - Required. The resource name of the entitlement to retrieve. - Name uses the format: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class ListChannelPartnerLinksRequest(proto.Message): - r"""Request message for - [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks] - - Attributes: - parent (str): - Required. The resource name of the reseller account for - listing channel partner links. Parent uses the format: - accounts/{account_id} - page_size (int): - Optional. Requested page size. Server might - return fewer results than requested. If - unspecified, server will pick a default size - (25). The maximum value is 200; the server will - coerce values above 200. - page_token (str): - Optional. A token for a page of results other than the first - page. Obtained using - [ListChannelPartnerLinksResponse.next_page_token][google.cloud.channel.v1.ListChannelPartnerLinksResponse.next_page_token] - of the previous - [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks] - call. - view (google.cloud.channel_v1.types.ChannelPartnerLinkView): - Optional. The level of granularity the - ChannelPartnerLink will display. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - view = proto.Field( - proto.ENUM, - number=4, - enum=gcc_channel_partner_links.ChannelPartnerLinkView, - ) - - -class ListChannelPartnerLinksResponse(proto.Message): - r"""Response message for - [CloudChannelService.ListChannelPartnerLinks][google.cloud.channel.v1.CloudChannelService.ListChannelPartnerLinks]. - - Attributes: - channel_partner_links (Sequence[google.cloud.channel_v1.types.ChannelPartnerLink]): - The Channel partner links for a reseller. - next_page_token (str): - A token to retrieve the next page of results. Pass to - [ListChannelPartnerLinksRequest.page_token][google.cloud.channel.v1.ListChannelPartnerLinksRequest.page_token] - to obtain that page. - """ - - @property - def raw_page(self): - return self - - channel_partner_links = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gcc_channel_partner_links.ChannelPartnerLink, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class GetChannelPartnerLinkRequest(proto.Message): - r"""Request message for - [CloudChannelService.GetChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.GetChannelPartnerLink]. - - Attributes: - name (str): - Required. The resource name of the channel partner link to - retrieve. Name uses the format: - accounts/{account_id}/channelPartnerLinks/{id} where {id} is - the Cloud Identity ID of the partner. - view (google.cloud.channel_v1.types.ChannelPartnerLinkView): - Optional. The level of granularity the - ChannelPartnerLink will display. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - view = proto.Field( - proto.ENUM, - number=2, - enum=gcc_channel_partner_links.ChannelPartnerLinkView, - ) - - -class CreateChannelPartnerLinkRequest(proto.Message): - r"""Request message for - [CloudChannelService.CreateChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.CreateChannelPartnerLink] - - Attributes: - parent (str): - Required. Create a channel partner link for the provided - reseller account's resource name. Parent uses the format: - accounts/{account_id} - channel_partner_link (google.cloud.channel_v1.types.ChannelPartnerLink): - Required. The channel partner link to create. Either - channel_partner_link.reseller_cloud_identity_id or domain - can be used to create a link. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - channel_partner_link = proto.Field( - proto.MESSAGE, - number=2, - message=gcc_channel_partner_links.ChannelPartnerLink, - ) - - -class UpdateChannelPartnerLinkRequest(proto.Message): - r"""Request message for - [CloudChannelService.UpdateChannelPartnerLink][google.cloud.channel.v1.CloudChannelService.UpdateChannelPartnerLink] - - Attributes: - name (str): - Required. The resource name of the channel partner link to - cancel. Name uses the format: - accounts/{account_id}/channelPartnerLinks/{id} where {id} is - the Cloud Identity ID of the partner. - channel_partner_link (google.cloud.channel_v1.types.ChannelPartnerLink): - Required. The channel partner link to update. Only - channel_partner_link.link_state is allowed for updates. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask that applies to the resource. The - only allowable value for an update mask is - channel_partner_link.link_state. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - channel_partner_link = proto.Field( - proto.MESSAGE, - number=2, - message=gcc_channel_partner_links.ChannelPartnerLink, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) - - -class CreateEntitlementRequest(proto.Message): - r"""Request message for - [CloudChannelService.CreateEntitlement][google.cloud.channel.v1.CloudChannelService.CreateEntitlement] - - Attributes: - parent (str): - Required. The resource name of the reseller's customer - account in which to create the entitlement. Parent uses the - format: accounts/{account_id}/customers/{customer_id} - entitlement (google.cloud.channel_v1.types.Entitlement): - Required. The entitlement to create. - request_id (str): - Optional. You can specify an optional unique request ID, and - if you need to retry your request, the server will know to - ignore the request if it's complete. - - For example, you make an initial request and the request - times out. If you make the request again with the same - request ID, the server can check if it received the original - operation with the same request ID. If it did, it will - ignore the second request. - - 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, - ) - entitlement = proto.Field( - proto.MESSAGE, - number=2, - message=gcc_entitlements.Entitlement, - ) - request_id = proto.Field( - proto.STRING, - number=5, - ) - - -class TransferEntitlementsRequest(proto.Message): - r"""Request message for - [CloudChannelService.TransferEntitlements][google.cloud.channel.v1.CloudChannelService.TransferEntitlements]. - - Attributes: - parent (str): - Required. The resource name of the reseller's customer - account that will receive transferred entitlements. Parent - uses the format: - accounts/{account_id}/customers/{customer_id} - entitlements (Sequence[google.cloud.channel_v1.types.Entitlement]): - Required. The new entitlements to create or - transfer. - auth_token (str): - The super admin of the resold customer - generates this token to authorize a reseller to - access their Cloud Identity and purchase - entitlements on their behalf. You can omit this - token after authorization. See - https://support.google.com/a/answer/7643790 for - more details. - request_id (str): - Optional. You can specify an optional unique request ID, and - if you need to retry your request, the server will know to - ignore the request if it's complete. - - For example, you make an initial request and the request - times out. If you make the request again with the same - request ID, the server can check if it received the original - operation with the same request ID. If it did, it will - ignore the second request. - - 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, - ) - entitlements = proto.RepeatedField( - proto.MESSAGE, - number=2, - message=gcc_entitlements.Entitlement, - ) - auth_token = proto.Field( - proto.STRING, - number=4, - ) - request_id = proto.Field( - proto.STRING, - number=6, - ) - - -class TransferEntitlementsResponse(proto.Message): - r"""Response message for - [CloudChannelService.TransferEntitlements][google.cloud.channel.v1.CloudChannelService.TransferEntitlements]. - This is put in the response field of google.longrunning.Operation. - - Attributes: - entitlements (Sequence[google.cloud.channel_v1.types.Entitlement]): - The transferred entitlements. - """ - - entitlements = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gcc_entitlements.Entitlement, - ) - - -class TransferEntitlementsToGoogleRequest(proto.Message): - r"""Request message for - [CloudChannelService.TransferEntitlementsToGoogle][google.cloud.channel.v1.CloudChannelService.TransferEntitlementsToGoogle]. - - Attributes: - parent (str): - Required. The resource name of the reseller's customer - account where the entitlements transfer from. Parent uses - the format: accounts/{account_id}/customers/{customer_id} - entitlements (Sequence[google.cloud.channel_v1.types.Entitlement]): - Required. The entitlements to transfer to - Google. - request_id (str): - Optional. You can specify an optional unique request ID, and - if you need to retry your request, the server will know to - ignore the request if it's complete. - - For example, you make an initial request and the request - times out. If you make the request again with the same - request ID, the server can check if it received the original - operation with the same request ID. If it did, it will - ignore the second request. - - 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, - ) - entitlements = proto.RepeatedField( - proto.MESSAGE, - number=2, - message=gcc_entitlements.Entitlement, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - - -class ChangeParametersRequest(proto.Message): - r"""Request message for [CloudChannelService.ChangeParametersRequest][]. - - Attributes: - name (str): - Required. The name of the entitlement to update. Name uses - the format: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} - parameters (Sequence[google.cloud.channel_v1.types.Parameter]): - Required. Entitlement parameters to update. - You can only change editable parameters. - request_id (str): - Optional. You can specify an optional unique request ID, and - if you need to retry your request, the server will know to - ignore the request if it's complete. - - For example, you make an initial request and the request - times out. If you make the request again with the same - request ID, the server can check if it received the original - operation with the same request ID. If it did, it will - ignore the second request. - - The request ID must be a valid - `UUID `__ with the - exception that zero UUID is not supported - (``00000000-0000-0000-0000-000000000000``). - purchase_order_id (str): - Optional. Purchase order ID provided by the - reseller. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - parameters = proto.RepeatedField( - proto.MESSAGE, - number=2, - message=gcc_entitlements.Parameter, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - purchase_order_id = proto.Field( - proto.STRING, - number=5, - ) - - -class ChangeRenewalSettingsRequest(proto.Message): - r"""Request message for - [CloudChannelService.ChangeRenewalSettings][google.cloud.channel.v1.CloudChannelService.ChangeRenewalSettings]. - - Attributes: - name (str): - Required. The name of the entitlement to update. Name uses - the format: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} - renewal_settings (google.cloud.channel_v1.types.RenewalSettings): - Required. New renewal settings. - request_id (str): - Optional. You can specify an optional unique request ID, and - if you need to retry your request, the server will know to - ignore the request if it's complete. - - For example, you make an initial request and the request - times out. If you make the request again with the same - request ID, the server can check if it received the original - operation with the same request ID. If it did, it will - ignore the second request. - - 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, - ) - renewal_settings = proto.Field( - proto.MESSAGE, - number=4, - message=gcc_entitlements.RenewalSettings, - ) - request_id = proto.Field( - proto.STRING, - number=5, - ) - - -class ChangeOfferRequest(proto.Message): - r"""Request message for - [CloudChannelService.ChangeOffer][google.cloud.channel.v1.CloudChannelService.ChangeOffer]. - - Attributes: - name (str): - Required. The resource name of the entitlement to update. - Name uses the format: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} - offer (str): - Required. New Offer. Format: - accounts/{account_id}/offers/{offer_id}. - parameters (Sequence[google.cloud.channel_v1.types.Parameter]): - Optional. Parameters needed to purchase the - Offer. - purchase_order_id (str): - Optional. Purchase order id provided by the - reseller. - request_id (str): - Optional. You can specify an optional unique request ID, and - if you need to retry your request, the server will know to - ignore the request if it's complete. - - For example, you make an initial request and the request - times out. If you make the request again with the same - request ID, the server can check if it received the original - operation with the same request ID. If it did, it will - ignore the second request. - - 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, - ) - offer = proto.Field( - proto.STRING, - number=2, - ) - parameters = proto.RepeatedField( - proto.MESSAGE, - number=3, - message=gcc_entitlements.Parameter, - ) - purchase_order_id = proto.Field( - proto.STRING, - number=5, - ) - request_id = proto.Field( - proto.STRING, - number=6, - ) - - -class StartPaidServiceRequest(proto.Message): - r"""Request message for - [CloudChannelService.StartPaidService][google.cloud.channel.v1.CloudChannelService.StartPaidService]. - - Attributes: - name (str): - Required. The name of the entitlement to start a paid - service for. Name uses the format: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} - request_id (str): - Optional. You can specify an optional unique request ID, and - if you need to retry your request, the server will know to - ignore the request if it's complete. - - For example, you make an initial request and the request - times out. If you make the request again with the same - request ID, the server can check if it received the original - operation with the same request ID. If it did, it will - ignore the second request. - - 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=3, - ) - - -class CancelEntitlementRequest(proto.Message): - r"""Request message for - [CloudChannelService.CancelEntitlement][google.cloud.channel.v1.CloudChannelService.CancelEntitlement]. - - Attributes: - name (str): - Required. The resource name of the entitlement to cancel. - Name uses the format: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} - request_id (str): - Optional. You can specify an optional unique request ID, and - if you need to retry your request, the server will know to - ignore the request if it's complete. - - For example, you make an initial request and the request - times out. If you make the request again with the same - request ID, the server can check if it received the original - operation with the same request ID. If it did, it will - ignore the second request. - - 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=3, - ) - - -class SuspendEntitlementRequest(proto.Message): - r"""Request message for - [CloudChannelService.SuspendEntitlement][google.cloud.channel.v1.CloudChannelService.SuspendEntitlement]. - - Attributes: - name (str): - Required. The resource name of the entitlement to suspend. - Name uses the format: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} - request_id (str): - Optional. You can specify an optional unique request ID, and - if you need to retry your request, the server will know to - ignore the request if it's complete. - - For example, you make an initial request and the request - times out. If you make the request again with the same - request ID, the server can check if it received the original - operation with the same request ID. If it did, it will - ignore the second request. - - 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=3, - ) - - -class ActivateEntitlementRequest(proto.Message): - r"""Request message for - [CloudChannelService.ActivateEntitlement][google.cloud.channel.v1.CloudChannelService.ActivateEntitlement]. - - Attributes: - name (str): - Required. The resource name of the entitlement to activate. - Name uses the format: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} - request_id (str): - Optional. You can specify an optional unique request ID, and - if you need to retry your request, the server will know to - ignore the request if it's complete. - - For example, you make an initial request and the request - times out. If you make the request again with the same - request ID, the server can check if it received the original - operation with the same request ID. If it did, it will - ignore the second request. - - 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=3, - ) - - -class LookupOfferRequest(proto.Message): - r"""Request message for LookupOffer. - - Attributes: - entitlement (str): - Required. The resource name of the entitlement to retrieve - the Offer. Entitlement uses the format: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} - """ - - entitlement = proto.Field( - proto.STRING, - number=1, - ) - - -class ListProductsRequest(proto.Message): - r"""Request message for ListProducts. - - Attributes: - account (str): - Required. The resource name of the reseller account. Format: - accounts/{account_id}. - page_size (int): - Optional. Requested page size. Server might - return fewer results than requested. If - unspecified, returns at most 100 Products. The - maximum value is 1000; the server will coerce - values above 1000. - page_token (str): - Optional. A token for a page of results other - than the first page. - language_code (str): - Optional. The BCP-47 language code. For - example, "en-US". The response will localize in - the corresponding language code, if specified. - The default value is "en-US". - """ - - account = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - language_code = proto.Field( - proto.STRING, - number=4, - ) - - -class ListProductsResponse(proto.Message): - r"""Response message for ListProducts. - - Attributes: - products (Sequence[google.cloud.channel_v1.types.Product]): - List of Products requested. - next_page_token (str): - A token to retrieve the next page of results. - """ - - @property - def raw_page(self): - return self - - products = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gcc_products.Product, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class ListSkusRequest(proto.Message): - r"""Request message for ListSkus. - - Attributes: - parent (str): - Required. The resource name of the Product to list SKUs for. - Parent uses the format: products/{product_id}. Supports - products/- to retrieve SKUs for all products. - account (str): - Required. Resource name of the reseller. Format: - accounts/{account_id}. - page_size (int): - Optional. Requested page size. Server might - return fewer results than requested. If - unspecified, returns at most 100 SKUs. The - maximum value is 1000; the server will coerce - values above 1000. - page_token (str): - Optional. A token for a page of results other - than the first page. Optional. - language_code (str): - Optional. The BCP-47 language code. For - example, "en-US". The response will localize in - the corresponding language code, if specified. - The default value is "en-US". - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - account = proto.Field( - proto.STRING, - number=2, - ) - page_size = proto.Field( - proto.INT32, - number=3, - ) - page_token = proto.Field( - proto.STRING, - number=4, - ) - language_code = proto.Field( - proto.STRING, - number=5, - ) - - -class ListSkusResponse(proto.Message): - r"""Response message for ListSkus. - - Attributes: - skus (Sequence[google.cloud.channel_v1.types.Sku]): - The list of SKUs requested. - next_page_token (str): - A token to retrieve the next page of results. - """ - - @property - def raw_page(self): - return self - - skus = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gcc_products.Sku, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class ListOffersRequest(proto.Message): - r"""Request message for ListOffers. - - Attributes: - parent (str): - Required. The resource name of the reseller account from - which to list Offers. Parent uses the format: - accounts/{account_id}. - page_size (int): - Optional. Requested page size. Server might - return fewer results than requested. If - unspecified, returns at most 500 Offers. The - maximum value is 1000; the server will coerce - values above 1000. - page_token (str): - Optional. A token for a page of results other - than the first page. - filter (str): - Optional. The expression to filter results by - name (name of the Offer), sku.name (name of the - SKU), or sku.product.name (name of the Product). - Example 1: sku.product.name=products/p1 AND - sku.name!=products/p1/skus/s1 Example 2: - name=accounts/a1/offers/o1 - language_code (str): - Optional. The BCP-47 language code. For - example, "en-US". The response will localize in - the corresponding language code, if specified. - The default value is "en-US". - """ - - 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, - ) - language_code = proto.Field( - proto.STRING, - number=5, - ) - - -class ListOffersResponse(proto.Message): - r"""Response message for ListOffers. - - Attributes: - offers (Sequence[google.cloud.channel_v1.types.Offer]): - The list of Offers requested. - next_page_token (str): - A token to retrieve the next page of results. - """ - - @property - def raw_page(self): - return self - - offers = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gcc_offers.Offer, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class ListPurchasableSkusRequest(proto.Message): - r"""Request message for ListPurchasableSkus. - - Attributes: - create_entitlement_purchase (google.cloud.channel_v1.types.ListPurchasableSkusRequest.CreateEntitlementPurchase): - List SKUs for CreateEntitlement purchase. - change_offer_purchase (google.cloud.channel_v1.types.ListPurchasableSkusRequest.ChangeOfferPurchase): - List SKUs for ChangeOffer purchase with a new - SKU. - customer (str): - Required. The resource name of the customer to list SKUs - for. Format: accounts/{account_id}/customers/{customer_id}. - page_size (int): - Optional. Requested page size. Server might - return fewer results than requested. If - unspecified, returns at most 100 SKUs. The - maximum value is 1000; the server will coerce - values above 1000. - page_token (str): - Optional. A token for a page of results other - than the first page. - language_code (str): - Optional. The BCP-47 language code. For - example, "en-US". The response will localize in - the corresponding language code, if specified. - The default value is "en-US". - """ - - class CreateEntitlementPurchase(proto.Message): - r"""List SKUs for a new entitlement. Make the purchase using - [CloudChannelService.CreateEntitlement][google.cloud.channel.v1.CloudChannelService.CreateEntitlement]. - - Attributes: - product (str): - Required. List SKUs belonging to this Product. Format: - products/{product_id}. Supports products/- to retrieve SKUs - for all products. - """ - - product = proto.Field( - proto.STRING, - number=1, - ) - - class ChangeOfferPurchase(proto.Message): - r"""List SKUs for upgrading or downgrading an entitlement. Make the - purchase using - [CloudChannelService.ChangeOffer][google.cloud.channel.v1.CloudChannelService.ChangeOffer]. - - Attributes: - entitlement (str): - Required. Resource name of the entitlement. Format: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} - change_type (google.cloud.channel_v1.types.ListPurchasableSkusRequest.ChangeOfferPurchase.ChangeType): - Required. Change Type for the entitlement. - """ - class ChangeType(proto.Enum): - r"""Change Type enum.""" - CHANGE_TYPE_UNSPECIFIED = 0 - UPGRADE = 1 - DOWNGRADE = 2 - - entitlement = proto.Field( - proto.STRING, - number=1, - ) - change_type = proto.Field( - proto.ENUM, - number=2, - enum='ListPurchasableSkusRequest.ChangeOfferPurchase.ChangeType', - ) - - create_entitlement_purchase = proto.Field( - proto.MESSAGE, - number=2, - oneof='purchase_option', - message=CreateEntitlementPurchase, - ) - change_offer_purchase = proto.Field( - proto.MESSAGE, - number=3, - oneof='purchase_option', - message=ChangeOfferPurchase, - ) - customer = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=4, - ) - page_token = proto.Field( - proto.STRING, - number=5, - ) - language_code = proto.Field( - proto.STRING, - number=6, - ) - - -class ListPurchasableSkusResponse(proto.Message): - r"""Response message for ListPurchasableSkus. - - Attributes: - purchasable_skus (Sequence[google.cloud.channel_v1.types.PurchasableSku]): - The list of SKUs requested. - next_page_token (str): - A token to retrieve the next page of results. - """ - - @property - def raw_page(self): - return self - - purchasable_skus = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='PurchasableSku', - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class PurchasableSku(proto.Message): - r"""SKU that you can purchase. This is used in ListPurchasableSku - API response. - - Attributes: - sku (google.cloud.channel_v1.types.Sku): - SKU - """ - - sku = proto.Field( - proto.MESSAGE, - number=1, - message=gcc_products.Sku, - ) - - -class ListPurchasableOffersRequest(proto.Message): - r"""Request message for ListPurchasableOffers. - - Attributes: - create_entitlement_purchase (google.cloud.channel_v1.types.ListPurchasableOffersRequest.CreateEntitlementPurchase): - List Offers for CreateEntitlement purchase. - change_offer_purchase (google.cloud.channel_v1.types.ListPurchasableOffersRequest.ChangeOfferPurchase): - List Offers for ChangeOffer purchase. - customer (str): - Required. The resource name of the customer to list Offers - for. Format: accounts/{account_id}/customers/{customer_id}. - page_size (int): - Optional. Requested page size. Server might - return fewer results than requested. If - unspecified, returns at most 100 Offers. The - maximum value is 1000; the server will coerce - values above 1000. - page_token (str): - Optional. A token for a page of results other - than the first page. - language_code (str): - Optional. The BCP-47 language code. For - example, "en-US". The response will localize in - the corresponding language code, if specified. - The default value is "en-US". - """ - - class CreateEntitlementPurchase(proto.Message): - r"""List Offers for CreateEntitlement purchase. - - Attributes: - sku (str): - Required. SKU that the result should be restricted to. - Format: products/{product_id}/skus/{sku_id}. - """ - - sku = proto.Field( - proto.STRING, - number=1, - ) - - class ChangeOfferPurchase(proto.Message): - r"""List Offers for ChangeOffer purchase. - - Attributes: - entitlement (str): - Required. Resource name of the entitlement. Format: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} - new_sku (str): - Optional. Resource name of the new target SKU. Provide this - SKU when upgrading or downgrading an entitlement. Format: - products/{product_id}/skus/{sku_id} - """ - - entitlement = proto.Field( - proto.STRING, - number=1, - ) - new_sku = proto.Field( - proto.STRING, - number=2, - ) - - create_entitlement_purchase = proto.Field( - proto.MESSAGE, - number=2, - oneof='purchase_option', - message=CreateEntitlementPurchase, - ) - change_offer_purchase = proto.Field( - proto.MESSAGE, - number=3, - oneof='purchase_option', - message=ChangeOfferPurchase, - ) - customer = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=4, - ) - page_token = proto.Field( - proto.STRING, - number=5, - ) - language_code = proto.Field( - proto.STRING, - number=6, - ) - - -class ListPurchasableOffersResponse(proto.Message): - r"""Response message for ListPurchasableOffers. - - Attributes: - purchasable_offers (Sequence[google.cloud.channel_v1.types.PurchasableOffer]): - The list of Offers requested. - next_page_token (str): - A token to retrieve the next page of results. - """ - - @property - def raw_page(self): - return self - - purchasable_offers = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='PurchasableOffer', - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class PurchasableOffer(proto.Message): - r"""Offer that you can purchase for a customer. This is used in - the ListPurchasableOffer API response. - - Attributes: - offer (google.cloud.channel_v1.types.Offer): - Offer. - """ - - offer = proto.Field( - proto.MESSAGE, - number=1, - message=gcc_offers.Offer, - ) - - -class RegisterSubscriberRequest(proto.Message): - r"""Request Message for RegisterSubscriber. - - Attributes: - account (str): - Required. Resource name of the account. - service_account (str): - Required. Service account that provides - subscriber access to the registered topic. - """ - - account = proto.Field( - proto.STRING, - number=1, - ) - service_account = proto.Field( - proto.STRING, - number=2, - ) - - -class RegisterSubscriberResponse(proto.Message): - r"""Response Message for RegisterSubscriber. - - Attributes: - topic (str): - Name of the topic the subscriber will listen - to. - """ - - topic = proto.Field( - proto.STRING, - number=1, - ) - - -class UnregisterSubscriberRequest(proto.Message): - r"""Request Message for UnregisterSubscriber. - - Attributes: - account (str): - Required. Resource name of the account. - service_account (str): - Required. Service account to unregister from - subscriber access to the topic. - """ - - account = proto.Field( - proto.STRING, - number=1, - ) - service_account = proto.Field( - proto.STRING, - number=2, - ) - - -class UnregisterSubscriberResponse(proto.Message): - r"""Response Message for UnregisterSubscriber. - - Attributes: - topic (str): - Name of the topic the service account - subscriber access was removed from. - """ - - topic = proto.Field( - proto.STRING, - number=1, - ) - - -class ListSubscribersRequest(proto.Message): - r"""Request Message for ListSubscribers. - - Attributes: - account (str): - Required. Resource name of the account. - page_size (int): - Optional. The maximum number of service - accounts to return. The service may return fewer - than this value. If unspecified, returns at most - 100 service accounts. The maximum value is 1000; - the server will coerce values above 1000. - page_token (str): - Optional. A page token, received from a previous - ``ListSubscribers`` call. Provide this to retrieve the - subsequent page. - - When paginating, all other parameters provided to - ``ListSubscribers`` must match the call that provided the - page token. - """ - - account = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - - -class ListSubscribersResponse(proto.Message): - r"""Response Message for ListSubscribers. - - Attributes: - topic (str): - Name of the topic registered with the - reseller. - service_accounts (Sequence[str]): - List of service accounts which have - subscriber access to the topic. - next_page_token (str): - A token that can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - topic = proto.Field( - proto.STRING, - number=1, - ) - service_accounts = proto.RepeatedField( - proto.STRING, - number=2, - ) - next_page_token = proto.Field( - proto.STRING, - number=3, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/channel_v1/types/subscriber_event.py b/owl-bot-staging/v1/google/cloud/channel_v1/types/subscriber_event.py deleted file mode 100644 index fc32682..0000000 --- a/owl-bot-staging/v1/google/cloud/channel_v1/types/subscriber_event.py +++ /dev/null @@ -1,123 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import proto # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.channel.v1', - manifest={ - 'CustomerEvent', - 'EntitlementEvent', - 'SubscriberEvent', - }, -) - - -class CustomerEvent(proto.Message): - r"""Represents Pub/Sub message content describing customer - update. - - Attributes: - customer (str): - Resource name of the customer. Format: - accounts/{account_id}/customers/{customer_id} - event_type (google.cloud.channel_v1.types.CustomerEvent.Type): - Type of event which happened on the customer. - """ - class Type(proto.Enum): - r"""Type of customer event.""" - TYPE_UNSPECIFIED = 0 - PRIMARY_DOMAIN_CHANGED = 1 - PRIMARY_DOMAIN_VERIFIED = 2 - - customer = proto.Field( - proto.STRING, - number=1, - ) - event_type = proto.Field( - proto.ENUM, - number=2, - enum=Type, - ) - - -class EntitlementEvent(proto.Message): - r"""Represents Pub/Sub message content describing entitlement - update. - - Attributes: - entitlement (str): - Resource name of an entitlement of the form: - accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id} - event_type (google.cloud.channel_v1.types.EntitlementEvent.Type): - Type of event which happened on the - entitlement. - """ - class Type(proto.Enum): - r"""Type of entitlement event.""" - TYPE_UNSPECIFIED = 0 - CREATED = 1 - PRICE_PLAN_SWITCHED = 3 - COMMITMENT_CHANGED = 4 - RENEWED = 5 - SUSPENDED = 6 - ACTIVATED = 7 - CANCELLED = 8 - SKU_CHANGED = 9 - RENEWAL_SETTING_CHANGED = 10 - PAID_SERVICE_STARTED = 11 - LICENSE_ASSIGNMENT_CHANGED = 12 - LICENSE_CAP_CHANGED = 13 - - entitlement = proto.Field( - proto.STRING, - number=1, - ) - event_type = proto.Field( - proto.ENUM, - number=2, - enum=Type, - ) - - -class SubscriberEvent(proto.Message): - r"""Represents information which resellers will get as part of - notification from Cloud Pub/Sub. - - Attributes: - customer_event (google.cloud.channel_v1.types.CustomerEvent): - Customer event send as part of Pub/Sub event - to partners. - entitlement_event (google.cloud.channel_v1.types.EntitlementEvent): - Entitlement event send as part of Pub/Sub - event to partners. - """ - - customer_event = proto.Field( - proto.MESSAGE, - number=1, - oneof='event', - message='CustomerEvent', - ) - entitlement_event = proto.Field( - proto.MESSAGE, - number=2, - oneof='event', - message='EntitlementEvent', - ) - - -__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 d514d9a..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/channel_v1/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python='3.7') -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=['3.6', '3.7']) -def mypy(session): - """Run the type checker.""" - session.install('mypy', 'types-pkg_resources') - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python='3.6') -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx<3.0.0", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) diff --git a/owl-bot-staging/v1/scripts/fixup_channel_v1_keywords.py b/owl-bot-staging/v1/scripts/fixup_channel_v1_keywords.py deleted file mode 100644 index 210090c..0000000 --- a/owl-bot-staging/v1/scripts/fixup_channel_v1_keywords.py +++ /dev/null @@ -1,210 +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 channelCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'activate_entitlement': ('name', 'request_id', ), - 'cancel_entitlement': ('name', 'request_id', ), - 'change_offer': ('name', 'offer', 'parameters', 'purchase_order_id', 'request_id', ), - 'change_parameters': ('name', 'parameters', 'request_id', 'purchase_order_id', ), - 'change_renewal_settings': ('name', 'renewal_settings', 'request_id', ), - 'check_cloud_identity_accounts_exist': ('parent', 'domain', ), - 'create_channel_partner_link': ('parent', 'channel_partner_link', ), - 'create_customer': ('parent', 'customer', ), - 'create_entitlement': ('parent', 'entitlement', 'request_id', ), - 'delete_customer': ('name', ), - 'get_channel_partner_link': ('name', 'view', ), - 'get_customer': ('name', ), - 'get_entitlement': ('name', ), - 'import_customer': ('domain', 'cloud_identity_id', 'parent', 'overwrite_if_exists', 'auth_token', 'channel_partner_id', 'customer', ), - 'list_channel_partner_links': ('parent', 'page_size', 'page_token', 'view', ), - 'list_customers': ('parent', 'page_size', 'page_token', ), - 'list_entitlements': ('parent', 'page_size', 'page_token', ), - 'list_offers': ('parent', 'page_size', 'page_token', 'filter', 'language_code', ), - 'list_products': ('account', 'page_size', 'page_token', 'language_code', ), - 'list_purchasable_offers': ('customer', 'create_entitlement_purchase', 'change_offer_purchase', 'page_size', 'page_token', 'language_code', ), - 'list_purchasable_skus': ('customer', 'create_entitlement_purchase', 'change_offer_purchase', 'page_size', 'page_token', 'language_code', ), - 'list_skus': ('parent', 'account', 'page_size', 'page_token', 'language_code', ), - 'list_subscribers': ('account', 'page_size', 'page_token', ), - 'list_transferable_offers': ('parent', 'sku', 'cloud_identity_id', 'customer_name', 'page_size', 'page_token', 'language_code', ), - 'list_transferable_skus': ('parent', 'cloud_identity_id', 'customer_name', 'page_size', 'page_token', 'auth_token', 'language_code', ), - 'lookup_offer': ('entitlement', ), - 'provision_cloud_identity': ('customer', 'cloud_identity_info', 'user', 'validate_only', ), - 'register_subscriber': ('account', 'service_account', ), - 'start_paid_service': ('name', 'request_id', ), - 'suspend_entitlement': ('name', 'request_id', ), - 'transfer_entitlements': ('parent', 'entitlements', 'auth_token', 'request_id', ), - 'transfer_entitlements_to_google': ('parent', 'entitlements', 'request_id', ), - 'unregister_subscriber': ('account', 'service_account', ), - 'update_channel_partner_link': ('name', 'channel_partner_link', 'update_mask', ), - 'update_customer': ('customer', 'update_mask', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: a.keyword.value not in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=channelCallTransformer(), -): - """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 channel 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 3e6154d..0000000 --- a/owl-bot-staging/v1/setup.py +++ /dev/null @@ -1,54 +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-channel', - version=version, - long_description=readme, - packages=setuptools.PEP420PackageFinder.find(), - namespace_packages=('google', 'google.cloud'), - platforms='Posix; MacOS X; Windows', - include_package_data=True, - install_requires=( - 'google-api-core[grpc] >= 1.27.0, < 3.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', - 'Programming Language :: Python :: 3.9', - '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 deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1/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/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/channel_v1/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/channel_v1/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1/tests/unit/gapic/channel_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/channel_v1/test_cloud_channel_service.py b/owl-bot-staging/v1/tests/unit/gapic/channel_v1/test_cloud_channel_service.py deleted file mode 100644 index cf2c9d0..0000000 --- a/owl-bot-staging/v1/tests/unit/gapic/channel_v1/test_cloud_channel_service.py +++ /dev/null @@ -1,8683 +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.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.channel_v1.services.cloud_channel_service import CloudChannelServiceAsyncClient -from google.cloud.channel_v1.services.cloud_channel_service import CloudChannelServiceClient -from google.cloud.channel_v1.services.cloud_channel_service import pagers -from google.cloud.channel_v1.services.cloud_channel_service import transports -from google.cloud.channel_v1.services.cloud_channel_service.transports.base import _GOOGLE_AUTH_VERSION -from google.cloud.channel_v1.types import channel_partner_links -from google.cloud.channel_v1.types import common -from google.cloud.channel_v1.types import customers -from google.cloud.channel_v1.types import entitlements -from google.cloud.channel_v1.types import offers -from google.cloud.channel_v1.types import operations -from google.cloud.channel_v1.types import products -from google.cloud.channel_v1.types import service -from google.longrunning import operations_pb2 -from google.oauth2 import service_account -from google.protobuf import any_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.type import postal_address_pb2 # type: ignore -import google.auth - - -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert CloudChannelServiceClient._get_default_mtls_endpoint(None) is None - assert CloudChannelServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert CloudChannelServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert CloudChannelServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert CloudChannelServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert CloudChannelServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class", [ - CloudChannelServiceClient, - CloudChannelServiceAsyncClient, -]) -def test_cloud_channel_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 == 'cloudchannel.googleapis.com:443' - - -@pytest.mark.parametrize("transport_class,transport_name", [ - (transports.CloudChannelServiceGrpcTransport, "grpc"), - (transports.CloudChannelServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_cloud_channel_service_client_service_account_always_use_jwt(transport_class, transport_name): - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=True) - use_jwt.assert_called_once_with(True) - - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=False) - use_jwt.assert_not_called() - - -@pytest.mark.parametrize("client_class", [ - CloudChannelServiceClient, - CloudChannelServiceAsyncClient, -]) -def test_cloud_channel_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 == 'cloudchannel.googleapis.com:443' - - -def test_cloud_channel_service_client_get_transport_class(): - transport = CloudChannelServiceClient.get_transport_class() - available_transports = [ - transports.CloudChannelServiceGrpcTransport, - ] - assert transport in available_transports - - transport = CloudChannelServiceClient.get_transport_class("grpc") - assert transport == transports.CloudChannelServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CloudChannelServiceClient, transports.CloudChannelServiceGrpcTransport, "grpc"), - (CloudChannelServiceAsyncClient, transports.CloudChannelServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(CloudChannelServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CloudChannelServiceClient)) -@mock.patch.object(CloudChannelServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CloudChannelServiceAsyncClient)) -def test_cloud_channel_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(CloudChannelServiceClient, '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(CloudChannelServiceClient, '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, - always_use_jwt_access=True, - ) - - # 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, - always_use_jwt_access=True, - ) - - # 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, - always_use_jwt_access=True, - ) - - # 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, - always_use_jwt_access=True, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (CloudChannelServiceClient, transports.CloudChannelServiceGrpcTransport, "grpc", "true"), - (CloudChannelServiceAsyncClient, transports.CloudChannelServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (CloudChannelServiceClient, transports.CloudChannelServiceGrpcTransport, "grpc", "false"), - (CloudChannelServiceAsyncClient, transports.CloudChannelServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(CloudChannelServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CloudChannelServiceClient)) -@mock.patch.object(CloudChannelServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CloudChannelServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_cloud_channel_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, - always_use_jwt_access=True, - ) - - # 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, - always_use_jwt_access=True, - ) - - # 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, - always_use_jwt_access=True, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CloudChannelServiceClient, transports.CloudChannelServiceGrpcTransport, "grpc"), - (CloudChannelServiceAsyncClient, transports.CloudChannelServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_cloud_channel_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, - always_use_jwt_access=True, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (CloudChannelServiceClient, transports.CloudChannelServiceGrpcTransport, "grpc"), - (CloudChannelServiceAsyncClient, transports.CloudChannelServiceGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_cloud_channel_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, - always_use_jwt_access=True, - ) - - -def test_cloud_channel_service_client_client_options_from_dict(): - with mock.patch('google.cloud.channel_v1.services.cloud_channel_service.transports.CloudChannelServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = CloudChannelServiceClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -def test_list_customers(transport: str = 'grpc', request_type=service.ListCustomersRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_customers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListCustomersResponse( - next_page_token='next_page_token_value', - ) - response = client.list_customers(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.ListCustomersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCustomersPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_customers_from_dict(): - test_list_customers(request_type=dict) - - -def test_list_customers_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_customers), - '__call__') as call: - client.list_customers() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCustomersRequest() - - -@pytest.mark.asyncio -async def test_list_customers_async(transport: str = 'grpc_asyncio', request_type=service.ListCustomersRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_customers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListCustomersResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_customers(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListCustomersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCustomersAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_customers_async_from_dict(): - await test_list_customers_async(request_type=dict) - - -def test_list_customers_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCustomersRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_customers), - '__call__') as call: - call.return_value = service.ListCustomersResponse() - client.list_customers(request) - - # Establish that the 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_customers_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListCustomersRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_customers), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListCustomersResponse()) - await client.list_customers(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_customers_pager(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_customers), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCustomersResponse( - customers=[ - customers.Customer(), - customers.Customer(), - customers.Customer(), - ], - next_page_token='abc', - ), - service.ListCustomersResponse( - customers=[], - next_page_token='def', - ), - service.ListCustomersResponse( - customers=[ - customers.Customer(), - ], - next_page_token='ghi', - ), - service.ListCustomersResponse( - customers=[ - customers.Customer(), - customers.Customer(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_customers(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, customers.Customer) - for i in results) - -def test_list_customers_pages(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_customers), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCustomersResponse( - customers=[ - customers.Customer(), - customers.Customer(), - customers.Customer(), - ], - next_page_token='abc', - ), - service.ListCustomersResponse( - customers=[], - next_page_token='def', - ), - service.ListCustomersResponse( - customers=[ - customers.Customer(), - ], - next_page_token='ghi', - ), - service.ListCustomersResponse( - customers=[ - customers.Customer(), - customers.Customer(), - ], - ), - RuntimeError, - ) - pages = list(client.list_customers(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_customers_async_pager(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_customers), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCustomersResponse( - customers=[ - customers.Customer(), - customers.Customer(), - customers.Customer(), - ], - next_page_token='abc', - ), - service.ListCustomersResponse( - customers=[], - next_page_token='def', - ), - service.ListCustomersResponse( - customers=[ - customers.Customer(), - ], - next_page_token='ghi', - ), - service.ListCustomersResponse( - customers=[ - customers.Customer(), - customers.Customer(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_customers(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, customers.Customer) - for i in responses) - -@pytest.mark.asyncio -async def test_list_customers_async_pages(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_customers), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListCustomersResponse( - customers=[ - customers.Customer(), - customers.Customer(), - customers.Customer(), - ], - next_page_token='abc', - ), - service.ListCustomersResponse( - customers=[], - next_page_token='def', - ), - service.ListCustomersResponse( - customers=[ - customers.Customer(), - ], - next_page_token='ghi', - ), - service.ListCustomersResponse( - customers=[ - customers.Customer(), - customers.Customer(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_customers(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_get_customer(transport: str = 'grpc', request_type=service.GetCustomerRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = customers.Customer( - name='name_value', - org_display_name='org_display_name_value', - alternate_email='alternate_email_value', - domain='domain_value', - cloud_identity_id='cloud_identity_id_value', - language_code='language_code_value', - channel_partner_id='channel_partner_id_value', - ) - response = client.get_customer(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.GetCustomerRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, customers.Customer) - assert response.name == 'name_value' - assert response.org_display_name == 'org_display_name_value' - assert response.alternate_email == 'alternate_email_value' - assert response.domain == 'domain_value' - assert response.cloud_identity_id == 'cloud_identity_id_value' - assert response.language_code == 'language_code_value' - assert response.channel_partner_id == 'channel_partner_id_value' - - -def test_get_customer_from_dict(): - test_get_customer(request_type=dict) - - -def test_get_customer_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_customer), - '__call__') as call: - client.get_customer() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCustomerRequest() - - -@pytest.mark.asyncio -async def test_get_customer_async(transport: str = 'grpc_asyncio', request_type=service.GetCustomerRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer( - name='name_value', - org_display_name='org_display_name_value', - alternate_email='alternate_email_value', - domain='domain_value', - cloud_identity_id='cloud_identity_id_value', - language_code='language_code_value', - channel_partner_id='channel_partner_id_value', - )) - response = await client.get_customer(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetCustomerRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, customers.Customer) - assert response.name == 'name_value' - assert response.org_display_name == 'org_display_name_value' - assert response.alternate_email == 'alternate_email_value' - assert response.domain == 'domain_value' - assert response.cloud_identity_id == 'cloud_identity_id_value' - assert response.language_code == 'language_code_value' - assert response.channel_partner_id == 'channel_partner_id_value' - - -@pytest.mark.asyncio -async def test_get_customer_async_from_dict(): - await test_get_customer_async(request_type=dict) - - -def test_get_customer_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCustomerRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_customer), - '__call__') as call: - call.return_value = customers.Customer() - client.get_customer(request) - - # Establish that the 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_customer_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetCustomerRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_customer), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer()) - await client.get_customer(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_customer_flattened(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = customers.Customer() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_customer( - 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_customer_flattened_error(): - client = CloudChannelServiceClient( - 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_customer( - service.GetCustomerRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_customer_flattened_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = customers.Customer() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_customer( - 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_customer_flattened_error_async(): - client = CloudChannelServiceAsyncClient( - 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_customer( - service.GetCustomerRequest(), - name='name_value', - ) - - -def test_check_cloud_identity_accounts_exist(transport: str = 'grpc', request_type=service.CheckCloudIdentityAccountsExistRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.check_cloud_identity_accounts_exist), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.CheckCloudIdentityAccountsExistResponse( - ) - response = client.check_cloud_identity_accounts_exist(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.CheckCloudIdentityAccountsExistRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, service.CheckCloudIdentityAccountsExistResponse) - - -def test_check_cloud_identity_accounts_exist_from_dict(): - test_check_cloud_identity_accounts_exist(request_type=dict) - - -def test_check_cloud_identity_accounts_exist_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.check_cloud_identity_accounts_exist), - '__call__') as call: - client.check_cloud_identity_accounts_exist() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.CheckCloudIdentityAccountsExistRequest() - - -@pytest.mark.asyncio -async def test_check_cloud_identity_accounts_exist_async(transport: str = 'grpc_asyncio', request_type=service.CheckCloudIdentityAccountsExistRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.check_cloud_identity_accounts_exist), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.CheckCloudIdentityAccountsExistResponse( - )) - response = await client.check_cloud_identity_accounts_exist(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.CheckCloudIdentityAccountsExistRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, service.CheckCloudIdentityAccountsExistResponse) - - -@pytest.mark.asyncio -async def test_check_cloud_identity_accounts_exist_async_from_dict(): - await test_check_cloud_identity_accounts_exist_async(request_type=dict) - - -def test_check_cloud_identity_accounts_exist_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CheckCloudIdentityAccountsExistRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.check_cloud_identity_accounts_exist), - '__call__') as call: - call.return_value = service.CheckCloudIdentityAccountsExistResponse() - client.check_cloud_identity_accounts_exist(request) - - # Establish that the 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_check_cloud_identity_accounts_exist_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CheckCloudIdentityAccountsExistRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.check_cloud_identity_accounts_exist), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.CheckCloudIdentityAccountsExistResponse()) - await client.check_cloud_identity_accounts_exist(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_customer(transport: str = 'grpc', request_type=service.CreateCustomerRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = customers.Customer( - name='name_value', - org_display_name='org_display_name_value', - alternate_email='alternate_email_value', - domain='domain_value', - cloud_identity_id='cloud_identity_id_value', - language_code='language_code_value', - channel_partner_id='channel_partner_id_value', - ) - response = client.create_customer(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.CreateCustomerRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, customers.Customer) - assert response.name == 'name_value' - assert response.org_display_name == 'org_display_name_value' - assert response.alternate_email == 'alternate_email_value' - assert response.domain == 'domain_value' - assert response.cloud_identity_id == 'cloud_identity_id_value' - assert response.language_code == 'language_code_value' - assert response.channel_partner_id == 'channel_partner_id_value' - - -def test_create_customer_from_dict(): - test_create_customer(request_type=dict) - - -def test_create_customer_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_customer), - '__call__') as call: - client.create_customer() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCustomerRequest() - - -@pytest.mark.asyncio -async def test_create_customer_async(transport: str = 'grpc_asyncio', request_type=service.CreateCustomerRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer( - name='name_value', - org_display_name='org_display_name_value', - alternate_email='alternate_email_value', - domain='domain_value', - cloud_identity_id='cloud_identity_id_value', - language_code='language_code_value', - channel_partner_id='channel_partner_id_value', - )) - response = await client.create_customer(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateCustomerRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, customers.Customer) - assert response.name == 'name_value' - assert response.org_display_name == 'org_display_name_value' - assert response.alternate_email == 'alternate_email_value' - assert response.domain == 'domain_value' - assert response.cloud_identity_id == 'cloud_identity_id_value' - assert response.language_code == 'language_code_value' - assert response.channel_partner_id == 'channel_partner_id_value' - - -@pytest.mark.asyncio -async def test_create_customer_async_from_dict(): - await test_create_customer_async(request_type=dict) - - -def test_create_customer_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateCustomerRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_customer), - '__call__') as call: - call.return_value = customers.Customer() - client.create_customer(request) - - # Establish that the 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_customer_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateCustomerRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_customer), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer()) - await client.create_customer(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_update_customer(transport: str = 'grpc', request_type=service.UpdateCustomerRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = customers.Customer( - name='name_value', - org_display_name='org_display_name_value', - alternate_email='alternate_email_value', - domain='domain_value', - cloud_identity_id='cloud_identity_id_value', - language_code='language_code_value', - channel_partner_id='channel_partner_id_value', - ) - response = client.update_customer(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.UpdateCustomerRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, customers.Customer) - assert response.name == 'name_value' - assert response.org_display_name == 'org_display_name_value' - assert response.alternate_email == 'alternate_email_value' - assert response.domain == 'domain_value' - assert response.cloud_identity_id == 'cloud_identity_id_value' - assert response.language_code == 'language_code_value' - assert response.channel_partner_id == 'channel_partner_id_value' - - -def test_update_customer_from_dict(): - test_update_customer(request_type=dict) - - -def test_update_customer_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_customer), - '__call__') as call: - client.update_customer() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCustomerRequest() - - -@pytest.mark.asyncio -async def test_update_customer_async(transport: str = 'grpc_asyncio', request_type=service.UpdateCustomerRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer( - name='name_value', - org_display_name='org_display_name_value', - alternate_email='alternate_email_value', - domain='domain_value', - cloud_identity_id='cloud_identity_id_value', - language_code='language_code_value', - channel_partner_id='channel_partner_id_value', - )) - response = await client.update_customer(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateCustomerRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, customers.Customer) - assert response.name == 'name_value' - assert response.org_display_name == 'org_display_name_value' - assert response.alternate_email == 'alternate_email_value' - assert response.domain == 'domain_value' - assert response.cloud_identity_id == 'cloud_identity_id_value' - assert response.language_code == 'language_code_value' - assert response.channel_partner_id == 'channel_partner_id_value' - - -@pytest.mark.asyncio -async def test_update_customer_async_from_dict(): - await test_update_customer_async(request_type=dict) - - -def test_update_customer_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCustomerRequest() - - request.customer.name = 'customer.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_customer), - '__call__') as call: - call.return_value = customers.Customer() - client.update_customer(request) - - # Establish that the 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', - 'customer.name=customer.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_customer_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateCustomerRequest() - - request.customer.name = 'customer.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_customer), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer()) - await client.update_customer(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', - 'customer.name=customer.name/value', - ) in kw['metadata'] - - -def test_delete_customer(transport: str = 'grpc', request_type=service.DeleteCustomerRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_customer(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.DeleteCustomerRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_customer_from_dict(): - test_delete_customer(request_type=dict) - - -def test_delete_customer_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_customer), - '__call__') as call: - client.delete_customer() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCustomerRequest() - - -@pytest.mark.asyncio -async def test_delete_customer_async(transport: str = 'grpc_asyncio', request_type=service.DeleteCustomerRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_customer(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.DeleteCustomerRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_customer_async_from_dict(): - await test_delete_customer_async(request_type=dict) - - -def test_delete_customer_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.DeleteCustomerRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_customer), - '__call__') as call: - call.return_value = None - client.delete_customer(request) - - # Establish that the 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_customer_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.DeleteCustomerRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_customer), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_customer(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_customer_flattened(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_customer( - 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_customer_flattened_error(): - client = CloudChannelServiceClient( - 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_customer( - service.DeleteCustomerRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_customer_flattened_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_customer( - 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_customer_flattened_error_async(): - client = CloudChannelServiceAsyncClient( - 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_customer( - service.DeleteCustomerRequest(), - name='name_value', - ) - - -def test_import_customer(transport: str = 'grpc', request_type=service.ImportCustomerRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.import_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = customers.Customer( - name='name_value', - org_display_name='org_display_name_value', - alternate_email='alternate_email_value', - domain='domain_value', - cloud_identity_id='cloud_identity_id_value', - language_code='language_code_value', - channel_partner_id='channel_partner_id_value', - ) - response = client.import_customer(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.ImportCustomerRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, customers.Customer) - assert response.name == 'name_value' - assert response.org_display_name == 'org_display_name_value' - assert response.alternate_email == 'alternate_email_value' - assert response.domain == 'domain_value' - assert response.cloud_identity_id == 'cloud_identity_id_value' - assert response.language_code == 'language_code_value' - assert response.channel_partner_id == 'channel_partner_id_value' - - -def test_import_customer_from_dict(): - test_import_customer(request_type=dict) - - -def test_import_customer_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.import_customer), - '__call__') as call: - client.import_customer() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ImportCustomerRequest() - - -@pytest.mark.asyncio -async def test_import_customer_async(transport: str = 'grpc_asyncio', request_type=service.ImportCustomerRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.import_customer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer( - name='name_value', - org_display_name='org_display_name_value', - alternate_email='alternate_email_value', - domain='domain_value', - cloud_identity_id='cloud_identity_id_value', - language_code='language_code_value', - channel_partner_id='channel_partner_id_value', - )) - response = await client.import_customer(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ImportCustomerRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, customers.Customer) - assert response.name == 'name_value' - assert response.org_display_name == 'org_display_name_value' - assert response.alternate_email == 'alternate_email_value' - assert response.domain == 'domain_value' - assert response.cloud_identity_id == 'cloud_identity_id_value' - assert response.language_code == 'language_code_value' - assert response.channel_partner_id == 'channel_partner_id_value' - - -@pytest.mark.asyncio -async def test_import_customer_async_from_dict(): - await test_import_customer_async(request_type=dict) - - -def test_import_customer_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ImportCustomerRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.import_customer), - '__call__') as call: - call.return_value = customers.Customer() - client.import_customer(request) - - # Establish that the 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_import_customer_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ImportCustomerRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.import_customer), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(customers.Customer()) - await client.import_customer(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_provision_cloud_identity(transport: str = 'grpc', request_type=service.ProvisionCloudIdentityRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.provision_cloud_identity), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.provision_cloud_identity(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.ProvisionCloudIdentityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_provision_cloud_identity_from_dict(): - test_provision_cloud_identity(request_type=dict) - - -def test_provision_cloud_identity_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.provision_cloud_identity), - '__call__') as call: - client.provision_cloud_identity() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ProvisionCloudIdentityRequest() - - -@pytest.mark.asyncio -async def test_provision_cloud_identity_async(transport: str = 'grpc_asyncio', request_type=service.ProvisionCloudIdentityRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.provision_cloud_identity), - '__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.provision_cloud_identity(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ProvisionCloudIdentityRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_provision_cloud_identity_async_from_dict(): - await test_provision_cloud_identity_async(request_type=dict) - - -def test_provision_cloud_identity_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ProvisionCloudIdentityRequest() - - request.customer = 'customer/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.provision_cloud_identity), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.provision_cloud_identity(request) - - # Establish that the 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', - 'customer=customer/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_provision_cloud_identity_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ProvisionCloudIdentityRequest() - - request.customer = 'customer/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.provision_cloud_identity), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.provision_cloud_identity(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', - 'customer=customer/value', - ) in kw['metadata'] - - -def test_list_entitlements(transport: str = 'grpc', request_type=service.ListEntitlementsRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_entitlements), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListEntitlementsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_entitlements(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.ListEntitlementsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEntitlementsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_entitlements_from_dict(): - test_list_entitlements(request_type=dict) - - -def test_list_entitlements_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_entitlements), - '__call__') as call: - client.list_entitlements() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListEntitlementsRequest() - - -@pytest.mark.asyncio -async def test_list_entitlements_async(transport: str = 'grpc_asyncio', request_type=service.ListEntitlementsRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_entitlements), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListEntitlementsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_entitlements(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListEntitlementsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEntitlementsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_entitlements_async_from_dict(): - await test_list_entitlements_async(request_type=dict) - - -def test_list_entitlements_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListEntitlementsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_entitlements), - '__call__') as call: - call.return_value = service.ListEntitlementsResponse() - client.list_entitlements(request) - - # Establish that the 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_entitlements_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListEntitlementsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_entitlements), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListEntitlementsResponse()) - await client.list_entitlements(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_entitlements_pager(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_entitlements), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListEntitlementsResponse( - entitlements=[ - entitlements.Entitlement(), - entitlements.Entitlement(), - entitlements.Entitlement(), - ], - next_page_token='abc', - ), - service.ListEntitlementsResponse( - entitlements=[], - next_page_token='def', - ), - service.ListEntitlementsResponse( - entitlements=[ - entitlements.Entitlement(), - ], - next_page_token='ghi', - ), - service.ListEntitlementsResponse( - entitlements=[ - entitlements.Entitlement(), - entitlements.Entitlement(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_entitlements(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, entitlements.Entitlement) - for i in results) - -def test_list_entitlements_pages(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_entitlements), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListEntitlementsResponse( - entitlements=[ - entitlements.Entitlement(), - entitlements.Entitlement(), - entitlements.Entitlement(), - ], - next_page_token='abc', - ), - service.ListEntitlementsResponse( - entitlements=[], - next_page_token='def', - ), - service.ListEntitlementsResponse( - entitlements=[ - entitlements.Entitlement(), - ], - next_page_token='ghi', - ), - service.ListEntitlementsResponse( - entitlements=[ - entitlements.Entitlement(), - entitlements.Entitlement(), - ], - ), - RuntimeError, - ) - pages = list(client.list_entitlements(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_entitlements_async_pager(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_entitlements), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListEntitlementsResponse( - entitlements=[ - entitlements.Entitlement(), - entitlements.Entitlement(), - entitlements.Entitlement(), - ], - next_page_token='abc', - ), - service.ListEntitlementsResponse( - entitlements=[], - next_page_token='def', - ), - service.ListEntitlementsResponse( - entitlements=[ - entitlements.Entitlement(), - ], - next_page_token='ghi', - ), - service.ListEntitlementsResponse( - entitlements=[ - entitlements.Entitlement(), - entitlements.Entitlement(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_entitlements(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, entitlements.Entitlement) - for i in responses) - -@pytest.mark.asyncio -async def test_list_entitlements_async_pages(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_entitlements), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListEntitlementsResponse( - entitlements=[ - entitlements.Entitlement(), - entitlements.Entitlement(), - entitlements.Entitlement(), - ], - next_page_token='abc', - ), - service.ListEntitlementsResponse( - entitlements=[], - next_page_token='def', - ), - service.ListEntitlementsResponse( - entitlements=[ - entitlements.Entitlement(), - ], - next_page_token='ghi', - ), - service.ListEntitlementsResponse( - entitlements=[ - entitlements.Entitlement(), - entitlements.Entitlement(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_entitlements(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_list_transferable_skus(transport: str = 'grpc', request_type=service.ListTransferableSkusRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_transferable_skus), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListTransferableSkusResponse( - next_page_token='next_page_token_value', - ) - response = client.list_transferable_skus(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.ListTransferableSkusRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTransferableSkusPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_transferable_skus_from_dict(): - test_list_transferable_skus(request_type=dict) - - -def test_list_transferable_skus_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_transferable_skus), - '__call__') as call: - client.list_transferable_skus() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListTransferableSkusRequest() - - -@pytest.mark.asyncio -async def test_list_transferable_skus_async(transport: str = 'grpc_asyncio', request_type=service.ListTransferableSkusRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_transferable_skus), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListTransferableSkusResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_transferable_skus(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListTransferableSkusRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTransferableSkusAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_transferable_skus_async_from_dict(): - await test_list_transferable_skus_async(request_type=dict) - - -def test_list_transferable_skus_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListTransferableSkusRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_transferable_skus), - '__call__') as call: - call.return_value = service.ListTransferableSkusResponse() - client.list_transferable_skus(request) - - # Establish that the 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_transferable_skus_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListTransferableSkusRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_transferable_skus), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListTransferableSkusResponse()) - await client.list_transferable_skus(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_transferable_skus_pager(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_transferable_skus), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListTransferableSkusResponse( - transferable_skus=[ - entitlements.TransferableSku(), - entitlements.TransferableSku(), - entitlements.TransferableSku(), - ], - next_page_token='abc', - ), - service.ListTransferableSkusResponse( - transferable_skus=[], - next_page_token='def', - ), - service.ListTransferableSkusResponse( - transferable_skus=[ - entitlements.TransferableSku(), - ], - next_page_token='ghi', - ), - service.ListTransferableSkusResponse( - transferable_skus=[ - entitlements.TransferableSku(), - entitlements.TransferableSku(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_transferable_skus(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, entitlements.TransferableSku) - for i in results) - -def test_list_transferable_skus_pages(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_transferable_skus), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListTransferableSkusResponse( - transferable_skus=[ - entitlements.TransferableSku(), - entitlements.TransferableSku(), - entitlements.TransferableSku(), - ], - next_page_token='abc', - ), - service.ListTransferableSkusResponse( - transferable_skus=[], - next_page_token='def', - ), - service.ListTransferableSkusResponse( - transferable_skus=[ - entitlements.TransferableSku(), - ], - next_page_token='ghi', - ), - service.ListTransferableSkusResponse( - transferable_skus=[ - entitlements.TransferableSku(), - entitlements.TransferableSku(), - ], - ), - RuntimeError, - ) - pages = list(client.list_transferable_skus(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_transferable_skus_async_pager(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_transferable_skus), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListTransferableSkusResponse( - transferable_skus=[ - entitlements.TransferableSku(), - entitlements.TransferableSku(), - entitlements.TransferableSku(), - ], - next_page_token='abc', - ), - service.ListTransferableSkusResponse( - transferable_skus=[], - next_page_token='def', - ), - service.ListTransferableSkusResponse( - transferable_skus=[ - entitlements.TransferableSku(), - ], - next_page_token='ghi', - ), - service.ListTransferableSkusResponse( - transferable_skus=[ - entitlements.TransferableSku(), - entitlements.TransferableSku(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_transferable_skus(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, entitlements.TransferableSku) - for i in responses) - -@pytest.mark.asyncio -async def test_list_transferable_skus_async_pages(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_transferable_skus), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListTransferableSkusResponse( - transferable_skus=[ - entitlements.TransferableSku(), - entitlements.TransferableSku(), - entitlements.TransferableSku(), - ], - next_page_token='abc', - ), - service.ListTransferableSkusResponse( - transferable_skus=[], - next_page_token='def', - ), - service.ListTransferableSkusResponse( - transferable_skus=[ - entitlements.TransferableSku(), - ], - next_page_token='ghi', - ), - service.ListTransferableSkusResponse( - transferable_skus=[ - entitlements.TransferableSku(), - entitlements.TransferableSku(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_transferable_skus(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_list_transferable_offers(transport: str = 'grpc', request_type=service.ListTransferableOffersRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_transferable_offers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListTransferableOffersResponse( - next_page_token='next_page_token_value', - ) - response = client.list_transferable_offers(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.ListTransferableOffersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTransferableOffersPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_transferable_offers_from_dict(): - test_list_transferable_offers(request_type=dict) - - -def test_list_transferable_offers_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_transferable_offers), - '__call__') as call: - client.list_transferable_offers() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListTransferableOffersRequest() - - -@pytest.mark.asyncio -async def test_list_transferable_offers_async(transport: str = 'grpc_asyncio', request_type=service.ListTransferableOffersRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_transferable_offers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListTransferableOffersResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_transferable_offers(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListTransferableOffersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTransferableOffersAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_transferable_offers_async_from_dict(): - await test_list_transferable_offers_async(request_type=dict) - - -def test_list_transferable_offers_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListTransferableOffersRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_transferable_offers), - '__call__') as call: - call.return_value = service.ListTransferableOffersResponse() - client.list_transferable_offers(request) - - # Establish that the 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_transferable_offers_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListTransferableOffersRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_transferable_offers), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListTransferableOffersResponse()) - await client.list_transferable_offers(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_transferable_offers_pager(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_transferable_offers), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListTransferableOffersResponse( - transferable_offers=[ - service.TransferableOffer(), - service.TransferableOffer(), - service.TransferableOffer(), - ], - next_page_token='abc', - ), - service.ListTransferableOffersResponse( - transferable_offers=[], - next_page_token='def', - ), - service.ListTransferableOffersResponse( - transferable_offers=[ - service.TransferableOffer(), - ], - next_page_token='ghi', - ), - service.ListTransferableOffersResponse( - transferable_offers=[ - service.TransferableOffer(), - service.TransferableOffer(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_transferable_offers(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, service.TransferableOffer) - for i in results) - -def test_list_transferable_offers_pages(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_transferable_offers), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListTransferableOffersResponse( - transferable_offers=[ - service.TransferableOffer(), - service.TransferableOffer(), - service.TransferableOffer(), - ], - next_page_token='abc', - ), - service.ListTransferableOffersResponse( - transferable_offers=[], - next_page_token='def', - ), - service.ListTransferableOffersResponse( - transferable_offers=[ - service.TransferableOffer(), - ], - next_page_token='ghi', - ), - service.ListTransferableOffersResponse( - transferable_offers=[ - service.TransferableOffer(), - service.TransferableOffer(), - ], - ), - RuntimeError, - ) - pages = list(client.list_transferable_offers(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_transferable_offers_async_pager(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_transferable_offers), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListTransferableOffersResponse( - transferable_offers=[ - service.TransferableOffer(), - service.TransferableOffer(), - service.TransferableOffer(), - ], - next_page_token='abc', - ), - service.ListTransferableOffersResponse( - transferable_offers=[], - next_page_token='def', - ), - service.ListTransferableOffersResponse( - transferable_offers=[ - service.TransferableOffer(), - ], - next_page_token='ghi', - ), - service.ListTransferableOffersResponse( - transferable_offers=[ - service.TransferableOffer(), - service.TransferableOffer(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_transferable_offers(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, service.TransferableOffer) - for i in responses) - -@pytest.mark.asyncio -async def test_list_transferable_offers_async_pages(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_transferable_offers), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListTransferableOffersResponse( - transferable_offers=[ - service.TransferableOffer(), - service.TransferableOffer(), - service.TransferableOffer(), - ], - next_page_token='abc', - ), - service.ListTransferableOffersResponse( - transferable_offers=[], - next_page_token='def', - ), - service.ListTransferableOffersResponse( - transferable_offers=[ - service.TransferableOffer(), - ], - next_page_token='ghi', - ), - service.ListTransferableOffersResponse( - transferable_offers=[ - service.TransferableOffer(), - service.TransferableOffer(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_transferable_offers(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_get_entitlement(transport: str = 'grpc', request_type=service.GetEntitlementRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_entitlement), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = entitlements.Entitlement( - name='name_value', - offer='offer_value', - provisioning_state=entitlements.Entitlement.ProvisioningState.ACTIVE, - suspension_reasons=[entitlements.Entitlement.SuspensionReason.RESELLER_INITIATED], - purchase_order_id='purchase_order_id_value', - ) - response = client.get_entitlement(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.GetEntitlementRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, entitlements.Entitlement) - assert response.name == 'name_value' - assert response.offer == 'offer_value' - assert response.provisioning_state == entitlements.Entitlement.ProvisioningState.ACTIVE - assert response.suspension_reasons == [entitlements.Entitlement.SuspensionReason.RESELLER_INITIATED] - assert response.purchase_order_id == 'purchase_order_id_value' - - -def test_get_entitlement_from_dict(): - test_get_entitlement(request_type=dict) - - -def test_get_entitlement_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_entitlement), - '__call__') as call: - client.get_entitlement() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetEntitlementRequest() - - -@pytest.mark.asyncio -async def test_get_entitlement_async(transport: str = 'grpc_asyncio', request_type=service.GetEntitlementRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_entitlement), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(entitlements.Entitlement( - name='name_value', - offer='offer_value', - provisioning_state=entitlements.Entitlement.ProvisioningState.ACTIVE, - suspension_reasons=[entitlements.Entitlement.SuspensionReason.RESELLER_INITIATED], - purchase_order_id='purchase_order_id_value', - )) - response = await client.get_entitlement(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetEntitlementRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, entitlements.Entitlement) - assert response.name == 'name_value' - assert response.offer == 'offer_value' - assert response.provisioning_state == entitlements.Entitlement.ProvisioningState.ACTIVE - assert response.suspension_reasons == [entitlements.Entitlement.SuspensionReason.RESELLER_INITIATED] - assert response.purchase_order_id == 'purchase_order_id_value' - - -@pytest.mark.asyncio -async def test_get_entitlement_async_from_dict(): - await test_get_entitlement_async(request_type=dict) - - -def test_get_entitlement_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetEntitlementRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_entitlement), - '__call__') as call: - call.return_value = entitlements.Entitlement() - client.get_entitlement(request) - - # Establish that the 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_entitlement_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetEntitlementRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_entitlement), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(entitlements.Entitlement()) - await client.get_entitlement(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_create_entitlement(transport: str = 'grpc', request_type=service.CreateEntitlementRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_entitlement), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_entitlement(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.CreateEntitlementRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_entitlement_from_dict(): - test_create_entitlement(request_type=dict) - - -def test_create_entitlement_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_entitlement), - '__call__') as call: - client.create_entitlement() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateEntitlementRequest() - - -@pytest.mark.asyncio -async def test_create_entitlement_async(transport: str = 'grpc_asyncio', request_type=service.CreateEntitlementRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_entitlement), - '__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_entitlement(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateEntitlementRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_entitlement_async_from_dict(): - await test_create_entitlement_async(request_type=dict) - - -def test_create_entitlement_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateEntitlementRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_entitlement), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_entitlement(request) - - # Establish that the 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_entitlement_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateEntitlementRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_entitlement), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_entitlement(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_change_parameters(transport: str = 'grpc', request_type=service.ChangeParametersRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.change_parameters), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.change_parameters(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.ChangeParametersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_change_parameters_from_dict(): - test_change_parameters(request_type=dict) - - -def test_change_parameters_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.change_parameters), - '__call__') as call: - client.change_parameters() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ChangeParametersRequest() - - -@pytest.mark.asyncio -async def test_change_parameters_async(transport: str = 'grpc_asyncio', request_type=service.ChangeParametersRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.change_parameters), - '__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.change_parameters(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ChangeParametersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_change_parameters_async_from_dict(): - await test_change_parameters_async(request_type=dict) - - -def test_change_parameters_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ChangeParametersRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.change_parameters), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.change_parameters(request) - - # Establish that the 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_change_parameters_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ChangeParametersRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.change_parameters), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.change_parameters(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_change_renewal_settings(transport: str = 'grpc', request_type=service.ChangeRenewalSettingsRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.change_renewal_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.change_renewal_settings(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.ChangeRenewalSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_change_renewal_settings_from_dict(): - test_change_renewal_settings(request_type=dict) - - -def test_change_renewal_settings_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.change_renewal_settings), - '__call__') as call: - client.change_renewal_settings() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ChangeRenewalSettingsRequest() - - -@pytest.mark.asyncio -async def test_change_renewal_settings_async(transport: str = 'grpc_asyncio', request_type=service.ChangeRenewalSettingsRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.change_renewal_settings), - '__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.change_renewal_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ChangeRenewalSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_change_renewal_settings_async_from_dict(): - await test_change_renewal_settings_async(request_type=dict) - - -def test_change_renewal_settings_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ChangeRenewalSettingsRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.change_renewal_settings), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.change_renewal_settings(request) - - # Establish that the 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_change_renewal_settings_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ChangeRenewalSettingsRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.change_renewal_settings), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.change_renewal_settings(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_change_offer(transport: str = 'grpc', request_type=service.ChangeOfferRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.change_offer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.change_offer(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.ChangeOfferRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_change_offer_from_dict(): - test_change_offer(request_type=dict) - - -def test_change_offer_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.change_offer), - '__call__') as call: - client.change_offer() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ChangeOfferRequest() - - -@pytest.mark.asyncio -async def test_change_offer_async(transport: str = 'grpc_asyncio', request_type=service.ChangeOfferRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.change_offer), - '__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.change_offer(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ChangeOfferRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_change_offer_async_from_dict(): - await test_change_offer_async(request_type=dict) - - -def test_change_offer_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ChangeOfferRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.change_offer), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.change_offer(request) - - # Establish that the 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_change_offer_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ChangeOfferRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.change_offer), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.change_offer(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_start_paid_service(transport: str = 'grpc', request_type=service.StartPaidServiceRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.start_paid_service), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.start_paid_service(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.StartPaidServiceRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_start_paid_service_from_dict(): - test_start_paid_service(request_type=dict) - - -def test_start_paid_service_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.start_paid_service), - '__call__') as call: - client.start_paid_service() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.StartPaidServiceRequest() - - -@pytest.mark.asyncio -async def test_start_paid_service_async(transport: str = 'grpc_asyncio', request_type=service.StartPaidServiceRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.start_paid_service), - '__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.start_paid_service(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.StartPaidServiceRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_start_paid_service_async_from_dict(): - await test_start_paid_service_async(request_type=dict) - - -def test_start_paid_service_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.StartPaidServiceRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.start_paid_service), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.start_paid_service(request) - - # Establish that the 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_start_paid_service_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.StartPaidServiceRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.start_paid_service), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.start_paid_service(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_suspend_entitlement(transport: str = 'grpc', request_type=service.SuspendEntitlementRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.suspend_entitlement), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.suspend_entitlement(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.SuspendEntitlementRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_suspend_entitlement_from_dict(): - test_suspend_entitlement(request_type=dict) - - -def test_suspend_entitlement_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.suspend_entitlement), - '__call__') as call: - client.suspend_entitlement() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.SuspendEntitlementRequest() - - -@pytest.mark.asyncio -async def test_suspend_entitlement_async(transport: str = 'grpc_asyncio', request_type=service.SuspendEntitlementRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.suspend_entitlement), - '__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.suspend_entitlement(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.SuspendEntitlementRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_suspend_entitlement_async_from_dict(): - await test_suspend_entitlement_async(request_type=dict) - - -def test_suspend_entitlement_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.SuspendEntitlementRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.suspend_entitlement), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.suspend_entitlement(request) - - # Establish that the 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_suspend_entitlement_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.SuspendEntitlementRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.suspend_entitlement), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.suspend_entitlement(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_cancel_entitlement(transport: str = 'grpc', request_type=service.CancelEntitlementRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.cancel_entitlement), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.cancel_entitlement(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.CancelEntitlementRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_cancel_entitlement_from_dict(): - test_cancel_entitlement(request_type=dict) - - -def test_cancel_entitlement_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.cancel_entitlement), - '__call__') as call: - client.cancel_entitlement() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.CancelEntitlementRequest() - - -@pytest.mark.asyncio -async def test_cancel_entitlement_async(transport: str = 'grpc_asyncio', request_type=service.CancelEntitlementRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.cancel_entitlement), - '__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.cancel_entitlement(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.CancelEntitlementRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_cancel_entitlement_async_from_dict(): - await test_cancel_entitlement_async(request_type=dict) - - -def test_cancel_entitlement_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CancelEntitlementRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.cancel_entitlement), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.cancel_entitlement(request) - - # Establish that the 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_cancel_entitlement_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CancelEntitlementRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.cancel_entitlement), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.cancel_entitlement(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_entitlement(transport: str = 'grpc', request_type=service.ActivateEntitlementRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_entitlement), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.activate_entitlement(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.ActivateEntitlementRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_activate_entitlement_from_dict(): - test_activate_entitlement(request_type=dict) - - -def test_activate_entitlement_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_entitlement), - '__call__') as call: - client.activate_entitlement() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateEntitlementRequest() - - -@pytest.mark.asyncio -async def test_activate_entitlement_async(transport: str = 'grpc_asyncio', request_type=service.ActivateEntitlementRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_entitlement), - '__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_entitlement(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ActivateEntitlementRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_activate_entitlement_async_from_dict(): - await test_activate_entitlement_async(request_type=dict) - - -def test_activate_entitlement_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ActivateEntitlementRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_entitlement), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.activate_entitlement(request) - - # Establish that the 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_entitlement_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ActivateEntitlementRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.activate_entitlement), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.activate_entitlement(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_transfer_entitlements(transport: str = 'grpc', request_type=service.TransferEntitlementsRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.transfer_entitlements), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.transfer_entitlements(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.TransferEntitlementsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_transfer_entitlements_from_dict(): - test_transfer_entitlements(request_type=dict) - - -def test_transfer_entitlements_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.transfer_entitlements), - '__call__') as call: - client.transfer_entitlements() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.TransferEntitlementsRequest() - - -@pytest.mark.asyncio -async def test_transfer_entitlements_async(transport: str = 'grpc_asyncio', request_type=service.TransferEntitlementsRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.transfer_entitlements), - '__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.transfer_entitlements(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.TransferEntitlementsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_transfer_entitlements_async_from_dict(): - await test_transfer_entitlements_async(request_type=dict) - - -def test_transfer_entitlements_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.TransferEntitlementsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.transfer_entitlements), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.transfer_entitlements(request) - - # Establish that the 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_transfer_entitlements_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.TransferEntitlementsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.transfer_entitlements), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.transfer_entitlements(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_transfer_entitlements_to_google(transport: str = 'grpc', request_type=service.TransferEntitlementsToGoogleRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.transfer_entitlements_to_google), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.transfer_entitlements_to_google(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.TransferEntitlementsToGoogleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_transfer_entitlements_to_google_from_dict(): - test_transfer_entitlements_to_google(request_type=dict) - - -def test_transfer_entitlements_to_google_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.transfer_entitlements_to_google), - '__call__') as call: - client.transfer_entitlements_to_google() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.TransferEntitlementsToGoogleRequest() - - -@pytest.mark.asyncio -async def test_transfer_entitlements_to_google_async(transport: str = 'grpc_asyncio', request_type=service.TransferEntitlementsToGoogleRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.transfer_entitlements_to_google), - '__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.transfer_entitlements_to_google(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.TransferEntitlementsToGoogleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_transfer_entitlements_to_google_async_from_dict(): - await test_transfer_entitlements_to_google_async(request_type=dict) - - -def test_transfer_entitlements_to_google_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.TransferEntitlementsToGoogleRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.transfer_entitlements_to_google), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.transfer_entitlements_to_google(request) - - # Establish that the 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_transfer_entitlements_to_google_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.TransferEntitlementsToGoogleRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.transfer_entitlements_to_google), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.transfer_entitlements_to_google(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_channel_partner_links(transport: str = 'grpc', request_type=service.ListChannelPartnerLinksRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_channel_partner_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListChannelPartnerLinksResponse( - next_page_token='next_page_token_value', - ) - response = client.list_channel_partner_links(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.ListChannelPartnerLinksRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListChannelPartnerLinksPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_channel_partner_links_from_dict(): - test_list_channel_partner_links(request_type=dict) - - -def test_list_channel_partner_links_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_channel_partner_links), - '__call__') as call: - client.list_channel_partner_links() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListChannelPartnerLinksRequest() - - -@pytest.mark.asyncio -async def test_list_channel_partner_links_async(transport: str = 'grpc_asyncio', request_type=service.ListChannelPartnerLinksRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_channel_partner_links), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListChannelPartnerLinksResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_channel_partner_links(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListChannelPartnerLinksRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListChannelPartnerLinksAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_channel_partner_links_async_from_dict(): - await test_list_channel_partner_links_async(request_type=dict) - - -def test_list_channel_partner_links_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListChannelPartnerLinksRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_channel_partner_links), - '__call__') as call: - call.return_value = service.ListChannelPartnerLinksResponse() - client.list_channel_partner_links(request) - - # Establish that the 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_channel_partner_links_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListChannelPartnerLinksRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_channel_partner_links), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListChannelPartnerLinksResponse()) - await client.list_channel_partner_links(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_channel_partner_links_pager(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_channel_partner_links), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListChannelPartnerLinksResponse( - channel_partner_links=[ - channel_partner_links.ChannelPartnerLink(), - channel_partner_links.ChannelPartnerLink(), - channel_partner_links.ChannelPartnerLink(), - ], - next_page_token='abc', - ), - service.ListChannelPartnerLinksResponse( - channel_partner_links=[], - next_page_token='def', - ), - service.ListChannelPartnerLinksResponse( - channel_partner_links=[ - channel_partner_links.ChannelPartnerLink(), - ], - next_page_token='ghi', - ), - service.ListChannelPartnerLinksResponse( - channel_partner_links=[ - channel_partner_links.ChannelPartnerLink(), - channel_partner_links.ChannelPartnerLink(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_channel_partner_links(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, channel_partner_links.ChannelPartnerLink) - for i in results) - -def test_list_channel_partner_links_pages(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_channel_partner_links), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListChannelPartnerLinksResponse( - channel_partner_links=[ - channel_partner_links.ChannelPartnerLink(), - channel_partner_links.ChannelPartnerLink(), - channel_partner_links.ChannelPartnerLink(), - ], - next_page_token='abc', - ), - service.ListChannelPartnerLinksResponse( - channel_partner_links=[], - next_page_token='def', - ), - service.ListChannelPartnerLinksResponse( - channel_partner_links=[ - channel_partner_links.ChannelPartnerLink(), - ], - next_page_token='ghi', - ), - service.ListChannelPartnerLinksResponse( - channel_partner_links=[ - channel_partner_links.ChannelPartnerLink(), - channel_partner_links.ChannelPartnerLink(), - ], - ), - RuntimeError, - ) - pages = list(client.list_channel_partner_links(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_channel_partner_links_async_pager(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_channel_partner_links), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListChannelPartnerLinksResponse( - channel_partner_links=[ - channel_partner_links.ChannelPartnerLink(), - channel_partner_links.ChannelPartnerLink(), - channel_partner_links.ChannelPartnerLink(), - ], - next_page_token='abc', - ), - service.ListChannelPartnerLinksResponse( - channel_partner_links=[], - next_page_token='def', - ), - service.ListChannelPartnerLinksResponse( - channel_partner_links=[ - channel_partner_links.ChannelPartnerLink(), - ], - next_page_token='ghi', - ), - service.ListChannelPartnerLinksResponse( - channel_partner_links=[ - channel_partner_links.ChannelPartnerLink(), - channel_partner_links.ChannelPartnerLink(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_channel_partner_links(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, channel_partner_links.ChannelPartnerLink) - for i in responses) - -@pytest.mark.asyncio -async def test_list_channel_partner_links_async_pages(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_channel_partner_links), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListChannelPartnerLinksResponse( - channel_partner_links=[ - channel_partner_links.ChannelPartnerLink(), - channel_partner_links.ChannelPartnerLink(), - channel_partner_links.ChannelPartnerLink(), - ], - next_page_token='abc', - ), - service.ListChannelPartnerLinksResponse( - channel_partner_links=[], - next_page_token='def', - ), - service.ListChannelPartnerLinksResponse( - channel_partner_links=[ - channel_partner_links.ChannelPartnerLink(), - ], - next_page_token='ghi', - ), - service.ListChannelPartnerLinksResponse( - channel_partner_links=[ - channel_partner_links.ChannelPartnerLink(), - channel_partner_links.ChannelPartnerLink(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_channel_partner_links(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_get_channel_partner_link(transport: str = 'grpc', request_type=service.GetChannelPartnerLinkRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_channel_partner_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = channel_partner_links.ChannelPartnerLink( - name='name_value', - reseller_cloud_identity_id='reseller_cloud_identity_id_value', - link_state=channel_partner_links.ChannelPartnerLinkState.INVITED, - invite_link_uri='invite_link_uri_value', - public_id='public_id_value', - ) - response = client.get_channel_partner_link(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.GetChannelPartnerLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, channel_partner_links.ChannelPartnerLink) - assert response.name == 'name_value' - assert response.reseller_cloud_identity_id == 'reseller_cloud_identity_id_value' - assert response.link_state == channel_partner_links.ChannelPartnerLinkState.INVITED - assert response.invite_link_uri == 'invite_link_uri_value' - assert response.public_id == 'public_id_value' - - -def test_get_channel_partner_link_from_dict(): - test_get_channel_partner_link(request_type=dict) - - -def test_get_channel_partner_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_channel_partner_link), - '__call__') as call: - client.get_channel_partner_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetChannelPartnerLinkRequest() - - -@pytest.mark.asyncio -async def test_get_channel_partner_link_async(transport: str = 'grpc_asyncio', request_type=service.GetChannelPartnerLinkRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_channel_partner_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(channel_partner_links.ChannelPartnerLink( - name='name_value', - reseller_cloud_identity_id='reseller_cloud_identity_id_value', - link_state=channel_partner_links.ChannelPartnerLinkState.INVITED, - invite_link_uri='invite_link_uri_value', - public_id='public_id_value', - )) - response = await client.get_channel_partner_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.GetChannelPartnerLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, channel_partner_links.ChannelPartnerLink) - assert response.name == 'name_value' - assert response.reseller_cloud_identity_id == 'reseller_cloud_identity_id_value' - assert response.link_state == channel_partner_links.ChannelPartnerLinkState.INVITED - assert response.invite_link_uri == 'invite_link_uri_value' - assert response.public_id == 'public_id_value' - - -@pytest.mark.asyncio -async def test_get_channel_partner_link_async_from_dict(): - await test_get_channel_partner_link_async(request_type=dict) - - -def test_get_channel_partner_link_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetChannelPartnerLinkRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_channel_partner_link), - '__call__') as call: - call.return_value = channel_partner_links.ChannelPartnerLink() - client.get_channel_partner_link(request) - - # Establish that the 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_channel_partner_link_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.GetChannelPartnerLinkRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_channel_partner_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(channel_partner_links.ChannelPartnerLink()) - await client.get_channel_partner_link(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_create_channel_partner_link(transport: str = 'grpc', request_type=service.CreateChannelPartnerLinkRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_channel_partner_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = channel_partner_links.ChannelPartnerLink( - name='name_value', - reseller_cloud_identity_id='reseller_cloud_identity_id_value', - link_state=channel_partner_links.ChannelPartnerLinkState.INVITED, - invite_link_uri='invite_link_uri_value', - public_id='public_id_value', - ) - response = client.create_channel_partner_link(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.CreateChannelPartnerLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, channel_partner_links.ChannelPartnerLink) - assert response.name == 'name_value' - assert response.reseller_cloud_identity_id == 'reseller_cloud_identity_id_value' - assert response.link_state == channel_partner_links.ChannelPartnerLinkState.INVITED - assert response.invite_link_uri == 'invite_link_uri_value' - assert response.public_id == 'public_id_value' - - -def test_create_channel_partner_link_from_dict(): - test_create_channel_partner_link(request_type=dict) - - -def test_create_channel_partner_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_channel_partner_link), - '__call__') as call: - client.create_channel_partner_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateChannelPartnerLinkRequest() - - -@pytest.mark.asyncio -async def test_create_channel_partner_link_async(transport: str = 'grpc_asyncio', request_type=service.CreateChannelPartnerLinkRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_channel_partner_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(channel_partner_links.ChannelPartnerLink( - name='name_value', - reseller_cloud_identity_id='reseller_cloud_identity_id_value', - link_state=channel_partner_links.ChannelPartnerLinkState.INVITED, - invite_link_uri='invite_link_uri_value', - public_id='public_id_value', - )) - response = await client.create_channel_partner_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.CreateChannelPartnerLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, channel_partner_links.ChannelPartnerLink) - assert response.name == 'name_value' - assert response.reseller_cloud_identity_id == 'reseller_cloud_identity_id_value' - assert response.link_state == channel_partner_links.ChannelPartnerLinkState.INVITED - assert response.invite_link_uri == 'invite_link_uri_value' - assert response.public_id == 'public_id_value' - - -@pytest.mark.asyncio -async def test_create_channel_partner_link_async_from_dict(): - await test_create_channel_partner_link_async(request_type=dict) - - -def test_create_channel_partner_link_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateChannelPartnerLinkRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_channel_partner_link), - '__call__') as call: - call.return_value = channel_partner_links.ChannelPartnerLink() - client.create_channel_partner_link(request) - - # Establish that the 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_channel_partner_link_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.CreateChannelPartnerLinkRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_channel_partner_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(channel_partner_links.ChannelPartnerLink()) - await client.create_channel_partner_link(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_update_channel_partner_link(transport: str = 'grpc', request_type=service.UpdateChannelPartnerLinkRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_channel_partner_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = channel_partner_links.ChannelPartnerLink( - name='name_value', - reseller_cloud_identity_id='reseller_cloud_identity_id_value', - link_state=channel_partner_links.ChannelPartnerLinkState.INVITED, - invite_link_uri='invite_link_uri_value', - public_id='public_id_value', - ) - response = client.update_channel_partner_link(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.UpdateChannelPartnerLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, channel_partner_links.ChannelPartnerLink) - assert response.name == 'name_value' - assert response.reseller_cloud_identity_id == 'reseller_cloud_identity_id_value' - assert response.link_state == channel_partner_links.ChannelPartnerLinkState.INVITED - assert response.invite_link_uri == 'invite_link_uri_value' - assert response.public_id == 'public_id_value' - - -def test_update_channel_partner_link_from_dict(): - test_update_channel_partner_link(request_type=dict) - - -def test_update_channel_partner_link_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_channel_partner_link), - '__call__') as call: - client.update_channel_partner_link() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateChannelPartnerLinkRequest() - - -@pytest.mark.asyncio -async def test_update_channel_partner_link_async(transport: str = 'grpc_asyncio', request_type=service.UpdateChannelPartnerLinkRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_channel_partner_link), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(channel_partner_links.ChannelPartnerLink( - name='name_value', - reseller_cloud_identity_id='reseller_cloud_identity_id_value', - link_state=channel_partner_links.ChannelPartnerLinkState.INVITED, - invite_link_uri='invite_link_uri_value', - public_id='public_id_value', - )) - response = await client.update_channel_partner_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.UpdateChannelPartnerLinkRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, channel_partner_links.ChannelPartnerLink) - assert response.name == 'name_value' - assert response.reseller_cloud_identity_id == 'reseller_cloud_identity_id_value' - assert response.link_state == channel_partner_links.ChannelPartnerLinkState.INVITED - assert response.invite_link_uri == 'invite_link_uri_value' - assert response.public_id == 'public_id_value' - - -@pytest.mark.asyncio -async def test_update_channel_partner_link_async_from_dict(): - await test_update_channel_partner_link_async(request_type=dict) - - -def test_update_channel_partner_link_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateChannelPartnerLinkRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_channel_partner_link), - '__call__') as call: - call.return_value = channel_partner_links.ChannelPartnerLink() - client.update_channel_partner_link(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_channel_partner_link_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UpdateChannelPartnerLinkRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_channel_partner_link), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(channel_partner_links.ChannelPartnerLink()) - await client.update_channel_partner_link(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_lookup_offer(transport: str = 'grpc', request_type=service.LookupOfferRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.lookup_offer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = offers.Offer( - name='name_value', - ) - response = client.lookup_offer(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.LookupOfferRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, offers.Offer) - assert response.name == 'name_value' - - -def test_lookup_offer_from_dict(): - test_lookup_offer(request_type=dict) - - -def test_lookup_offer_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.lookup_offer), - '__call__') as call: - client.lookup_offer() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.LookupOfferRequest() - - -@pytest.mark.asyncio -async def test_lookup_offer_async(transport: str = 'grpc_asyncio', request_type=service.LookupOfferRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.lookup_offer), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(offers.Offer( - name='name_value', - )) - response = await client.lookup_offer(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.LookupOfferRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, offers.Offer) - assert response.name == 'name_value' - - -@pytest.mark.asyncio -async def test_lookup_offer_async_from_dict(): - await test_lookup_offer_async(request_type=dict) - - -def test_lookup_offer_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.LookupOfferRequest() - - request.entitlement = 'entitlement/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.lookup_offer), - '__call__') as call: - call.return_value = offers.Offer() - client.lookup_offer(request) - - # Establish that the 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', - 'entitlement=entitlement/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_lookup_offer_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.LookupOfferRequest() - - request.entitlement = 'entitlement/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.lookup_offer), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(offers.Offer()) - await client.lookup_offer(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', - 'entitlement=entitlement/value', - ) in kw['metadata'] - - -def test_list_products(transport: str = 'grpc', request_type=service.ListProductsRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_products), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListProductsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_products(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.ListProductsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListProductsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_products_from_dict(): - test_list_products(request_type=dict) - - -def test_list_products_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_products), - '__call__') as call: - client.list_products() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListProductsRequest() - - -@pytest.mark.asyncio -async def test_list_products_async(transport: str = 'grpc_asyncio', request_type=service.ListProductsRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_products), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListProductsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_products(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListProductsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListProductsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_products_async_from_dict(): - await test_list_products_async(request_type=dict) - - -def test_list_products_pager(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_products), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListProductsResponse( - products=[ - products.Product(), - products.Product(), - products.Product(), - ], - next_page_token='abc', - ), - service.ListProductsResponse( - products=[], - next_page_token='def', - ), - service.ListProductsResponse( - products=[ - products.Product(), - ], - next_page_token='ghi', - ), - service.ListProductsResponse( - products=[ - products.Product(), - products.Product(), - ], - ), - RuntimeError, - ) - - metadata = () - pager = client.list_products(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, products.Product) - for i in results) - -def test_list_products_pages(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_products), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListProductsResponse( - products=[ - products.Product(), - products.Product(), - products.Product(), - ], - next_page_token='abc', - ), - service.ListProductsResponse( - products=[], - next_page_token='def', - ), - service.ListProductsResponse( - products=[ - products.Product(), - ], - next_page_token='ghi', - ), - service.ListProductsResponse( - products=[ - products.Product(), - products.Product(), - ], - ), - RuntimeError, - ) - pages = list(client.list_products(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_products_async_pager(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_products), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListProductsResponse( - products=[ - products.Product(), - products.Product(), - products.Product(), - ], - next_page_token='abc', - ), - service.ListProductsResponse( - products=[], - next_page_token='def', - ), - service.ListProductsResponse( - products=[ - products.Product(), - ], - next_page_token='ghi', - ), - service.ListProductsResponse( - products=[ - products.Product(), - products.Product(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_products(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, products.Product) - for i in responses) - -@pytest.mark.asyncio -async def test_list_products_async_pages(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_products), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListProductsResponse( - products=[ - products.Product(), - products.Product(), - products.Product(), - ], - next_page_token='abc', - ), - service.ListProductsResponse( - products=[], - next_page_token='def', - ), - service.ListProductsResponse( - products=[ - products.Product(), - ], - next_page_token='ghi', - ), - service.ListProductsResponse( - products=[ - products.Product(), - products.Product(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_products(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_list_skus(transport: str = 'grpc', request_type=service.ListSkusRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_skus), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListSkusResponse( - next_page_token='next_page_token_value', - ) - response = client.list_skus(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.ListSkusRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSkusPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_skus_from_dict(): - test_list_skus(request_type=dict) - - -def test_list_skus_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_skus), - '__call__') as call: - client.list_skus() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListSkusRequest() - - -@pytest.mark.asyncio -async def test_list_skus_async(transport: str = 'grpc_asyncio', request_type=service.ListSkusRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_skus), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListSkusResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_skus(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListSkusRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSkusAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_skus_async_from_dict(): - await test_list_skus_async(request_type=dict) - - -def test_list_skus_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListSkusRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_skus), - '__call__') as call: - call.return_value = service.ListSkusResponse() - client.list_skus(request) - - # Establish that the 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_skus_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListSkusRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_skus), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListSkusResponse()) - await client.list_skus(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_skus_pager(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_skus), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListSkusResponse( - skus=[ - products.Sku(), - products.Sku(), - products.Sku(), - ], - next_page_token='abc', - ), - service.ListSkusResponse( - skus=[], - next_page_token='def', - ), - service.ListSkusResponse( - skus=[ - products.Sku(), - ], - next_page_token='ghi', - ), - service.ListSkusResponse( - skus=[ - products.Sku(), - products.Sku(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_skus(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, products.Sku) - for i in results) - -def test_list_skus_pages(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_skus), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListSkusResponse( - skus=[ - products.Sku(), - products.Sku(), - products.Sku(), - ], - next_page_token='abc', - ), - service.ListSkusResponse( - skus=[], - next_page_token='def', - ), - service.ListSkusResponse( - skus=[ - products.Sku(), - ], - next_page_token='ghi', - ), - service.ListSkusResponse( - skus=[ - products.Sku(), - products.Sku(), - ], - ), - RuntimeError, - ) - pages = list(client.list_skus(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_skus_async_pager(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_skus), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListSkusResponse( - skus=[ - products.Sku(), - products.Sku(), - products.Sku(), - ], - next_page_token='abc', - ), - service.ListSkusResponse( - skus=[], - next_page_token='def', - ), - service.ListSkusResponse( - skus=[ - products.Sku(), - ], - next_page_token='ghi', - ), - service.ListSkusResponse( - skus=[ - products.Sku(), - products.Sku(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_skus(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, products.Sku) - for i in responses) - -@pytest.mark.asyncio -async def test_list_skus_async_pages(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_skus), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListSkusResponse( - skus=[ - products.Sku(), - products.Sku(), - products.Sku(), - ], - next_page_token='abc', - ), - service.ListSkusResponse( - skus=[], - next_page_token='def', - ), - service.ListSkusResponse( - skus=[ - products.Sku(), - ], - next_page_token='ghi', - ), - service.ListSkusResponse( - skus=[ - products.Sku(), - products.Sku(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_skus(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_list_offers(transport: str = 'grpc', request_type=service.ListOffersRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_offers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListOffersResponse( - next_page_token='next_page_token_value', - ) - response = client.list_offers(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.ListOffersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListOffersPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_offers_from_dict(): - test_list_offers(request_type=dict) - - -def test_list_offers_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_offers), - '__call__') as call: - client.list_offers() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListOffersRequest() - - -@pytest.mark.asyncio -async def test_list_offers_async(transport: str = 'grpc_asyncio', request_type=service.ListOffersRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_offers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListOffersResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_offers(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListOffersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListOffersAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_offers_async_from_dict(): - await test_list_offers_async(request_type=dict) - - -def test_list_offers_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListOffersRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_offers), - '__call__') as call: - call.return_value = service.ListOffersResponse() - client.list_offers(request) - - # Establish that the 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_offers_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListOffersRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_offers), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListOffersResponse()) - await client.list_offers(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_offers_pager(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_offers), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListOffersResponse( - offers=[ - offers.Offer(), - offers.Offer(), - offers.Offer(), - ], - next_page_token='abc', - ), - service.ListOffersResponse( - offers=[], - next_page_token='def', - ), - service.ListOffersResponse( - offers=[ - offers.Offer(), - ], - next_page_token='ghi', - ), - service.ListOffersResponse( - offers=[ - offers.Offer(), - offers.Offer(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_offers(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, offers.Offer) - for i in results) - -def test_list_offers_pages(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_offers), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListOffersResponse( - offers=[ - offers.Offer(), - offers.Offer(), - offers.Offer(), - ], - next_page_token='abc', - ), - service.ListOffersResponse( - offers=[], - next_page_token='def', - ), - service.ListOffersResponse( - offers=[ - offers.Offer(), - ], - next_page_token='ghi', - ), - service.ListOffersResponse( - offers=[ - offers.Offer(), - offers.Offer(), - ], - ), - RuntimeError, - ) - pages = list(client.list_offers(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_offers_async_pager(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_offers), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListOffersResponse( - offers=[ - offers.Offer(), - offers.Offer(), - offers.Offer(), - ], - next_page_token='abc', - ), - service.ListOffersResponse( - offers=[], - next_page_token='def', - ), - service.ListOffersResponse( - offers=[ - offers.Offer(), - ], - next_page_token='ghi', - ), - service.ListOffersResponse( - offers=[ - offers.Offer(), - offers.Offer(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_offers(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, offers.Offer) - for i in responses) - -@pytest.mark.asyncio -async def test_list_offers_async_pages(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_offers), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListOffersResponse( - offers=[ - offers.Offer(), - offers.Offer(), - offers.Offer(), - ], - next_page_token='abc', - ), - service.ListOffersResponse( - offers=[], - next_page_token='def', - ), - service.ListOffersResponse( - offers=[ - offers.Offer(), - ], - next_page_token='ghi', - ), - service.ListOffersResponse( - offers=[ - offers.Offer(), - offers.Offer(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_offers(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_list_purchasable_skus(transport: str = 'grpc', request_type=service.ListPurchasableSkusRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_purchasable_skus), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListPurchasableSkusResponse( - next_page_token='next_page_token_value', - ) - response = client.list_purchasable_skus(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.ListPurchasableSkusRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPurchasableSkusPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_purchasable_skus_from_dict(): - test_list_purchasable_skus(request_type=dict) - - -def test_list_purchasable_skus_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_purchasable_skus), - '__call__') as call: - client.list_purchasable_skus() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListPurchasableSkusRequest() - - -@pytest.mark.asyncio -async def test_list_purchasable_skus_async(transport: str = 'grpc_asyncio', request_type=service.ListPurchasableSkusRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_purchasable_skus), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListPurchasableSkusResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_purchasable_skus(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListPurchasableSkusRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPurchasableSkusAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_purchasable_skus_async_from_dict(): - await test_list_purchasable_skus_async(request_type=dict) - - -def test_list_purchasable_skus_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListPurchasableSkusRequest() - - request.customer = 'customer/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_purchasable_skus), - '__call__') as call: - call.return_value = service.ListPurchasableSkusResponse() - client.list_purchasable_skus(request) - - # Establish that the 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', - 'customer=customer/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_purchasable_skus_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListPurchasableSkusRequest() - - request.customer = 'customer/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_purchasable_skus), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListPurchasableSkusResponse()) - await client.list_purchasable_skus(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', - 'customer=customer/value', - ) in kw['metadata'] - - -def test_list_purchasable_skus_pager(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_purchasable_skus), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListPurchasableSkusResponse( - purchasable_skus=[ - service.PurchasableSku(), - service.PurchasableSku(), - service.PurchasableSku(), - ], - next_page_token='abc', - ), - service.ListPurchasableSkusResponse( - purchasable_skus=[], - next_page_token='def', - ), - service.ListPurchasableSkusResponse( - purchasable_skus=[ - service.PurchasableSku(), - ], - next_page_token='ghi', - ), - service.ListPurchasableSkusResponse( - purchasable_skus=[ - service.PurchasableSku(), - service.PurchasableSku(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('customer', ''), - )), - ) - pager = client.list_purchasable_skus(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, service.PurchasableSku) - for i in results) - -def test_list_purchasable_skus_pages(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_purchasable_skus), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListPurchasableSkusResponse( - purchasable_skus=[ - service.PurchasableSku(), - service.PurchasableSku(), - service.PurchasableSku(), - ], - next_page_token='abc', - ), - service.ListPurchasableSkusResponse( - purchasable_skus=[], - next_page_token='def', - ), - service.ListPurchasableSkusResponse( - purchasable_skus=[ - service.PurchasableSku(), - ], - next_page_token='ghi', - ), - service.ListPurchasableSkusResponse( - purchasable_skus=[ - service.PurchasableSku(), - service.PurchasableSku(), - ], - ), - RuntimeError, - ) - pages = list(client.list_purchasable_skus(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_purchasable_skus_async_pager(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_purchasable_skus), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListPurchasableSkusResponse( - purchasable_skus=[ - service.PurchasableSku(), - service.PurchasableSku(), - service.PurchasableSku(), - ], - next_page_token='abc', - ), - service.ListPurchasableSkusResponse( - purchasable_skus=[], - next_page_token='def', - ), - service.ListPurchasableSkusResponse( - purchasable_skus=[ - service.PurchasableSku(), - ], - next_page_token='ghi', - ), - service.ListPurchasableSkusResponse( - purchasable_skus=[ - service.PurchasableSku(), - service.PurchasableSku(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_purchasable_skus(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, service.PurchasableSku) - for i in responses) - -@pytest.mark.asyncio -async def test_list_purchasable_skus_async_pages(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_purchasable_skus), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListPurchasableSkusResponse( - purchasable_skus=[ - service.PurchasableSku(), - service.PurchasableSku(), - service.PurchasableSku(), - ], - next_page_token='abc', - ), - service.ListPurchasableSkusResponse( - purchasable_skus=[], - next_page_token='def', - ), - service.ListPurchasableSkusResponse( - purchasable_skus=[ - service.PurchasableSku(), - ], - next_page_token='ghi', - ), - service.ListPurchasableSkusResponse( - purchasable_skus=[ - service.PurchasableSku(), - service.PurchasableSku(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_purchasable_skus(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_list_purchasable_offers(transport: str = 'grpc', request_type=service.ListPurchasableOffersRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_purchasable_offers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListPurchasableOffersResponse( - next_page_token='next_page_token_value', - ) - response = client.list_purchasable_offers(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.ListPurchasableOffersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPurchasableOffersPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_purchasable_offers_from_dict(): - test_list_purchasable_offers(request_type=dict) - - -def test_list_purchasable_offers_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_purchasable_offers), - '__call__') as call: - client.list_purchasable_offers() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListPurchasableOffersRequest() - - -@pytest.mark.asyncio -async def test_list_purchasable_offers_async(transport: str = 'grpc_asyncio', request_type=service.ListPurchasableOffersRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_purchasable_offers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListPurchasableOffersResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_purchasable_offers(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListPurchasableOffersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPurchasableOffersAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_purchasable_offers_async_from_dict(): - await test_list_purchasable_offers_async(request_type=dict) - - -def test_list_purchasable_offers_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListPurchasableOffersRequest() - - request.customer = 'customer/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_purchasable_offers), - '__call__') as call: - call.return_value = service.ListPurchasableOffersResponse() - client.list_purchasable_offers(request) - - # Establish that the 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', - 'customer=customer/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_purchasable_offers_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListPurchasableOffersRequest() - - request.customer = 'customer/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_purchasable_offers), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListPurchasableOffersResponse()) - await client.list_purchasable_offers(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', - 'customer=customer/value', - ) in kw['metadata'] - - -def test_list_purchasable_offers_pager(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_purchasable_offers), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListPurchasableOffersResponse( - purchasable_offers=[ - service.PurchasableOffer(), - service.PurchasableOffer(), - service.PurchasableOffer(), - ], - next_page_token='abc', - ), - service.ListPurchasableOffersResponse( - purchasable_offers=[], - next_page_token='def', - ), - service.ListPurchasableOffersResponse( - purchasable_offers=[ - service.PurchasableOffer(), - ], - next_page_token='ghi', - ), - service.ListPurchasableOffersResponse( - purchasable_offers=[ - service.PurchasableOffer(), - service.PurchasableOffer(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('customer', ''), - )), - ) - pager = client.list_purchasable_offers(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, service.PurchasableOffer) - for i in results) - -def test_list_purchasable_offers_pages(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_purchasable_offers), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListPurchasableOffersResponse( - purchasable_offers=[ - service.PurchasableOffer(), - service.PurchasableOffer(), - service.PurchasableOffer(), - ], - next_page_token='abc', - ), - service.ListPurchasableOffersResponse( - purchasable_offers=[], - next_page_token='def', - ), - service.ListPurchasableOffersResponse( - purchasable_offers=[ - service.PurchasableOffer(), - ], - next_page_token='ghi', - ), - service.ListPurchasableOffersResponse( - purchasable_offers=[ - service.PurchasableOffer(), - service.PurchasableOffer(), - ], - ), - RuntimeError, - ) - pages = list(client.list_purchasable_offers(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_purchasable_offers_async_pager(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_purchasable_offers), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListPurchasableOffersResponse( - purchasable_offers=[ - service.PurchasableOffer(), - service.PurchasableOffer(), - service.PurchasableOffer(), - ], - next_page_token='abc', - ), - service.ListPurchasableOffersResponse( - purchasable_offers=[], - next_page_token='def', - ), - service.ListPurchasableOffersResponse( - purchasable_offers=[ - service.PurchasableOffer(), - ], - next_page_token='ghi', - ), - service.ListPurchasableOffersResponse( - purchasable_offers=[ - service.PurchasableOffer(), - service.PurchasableOffer(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_purchasable_offers(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, service.PurchasableOffer) - for i in responses) - -@pytest.mark.asyncio -async def test_list_purchasable_offers_async_pages(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_purchasable_offers), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListPurchasableOffersResponse( - purchasable_offers=[ - service.PurchasableOffer(), - service.PurchasableOffer(), - service.PurchasableOffer(), - ], - next_page_token='abc', - ), - service.ListPurchasableOffersResponse( - purchasable_offers=[], - next_page_token='def', - ), - service.ListPurchasableOffersResponse( - purchasable_offers=[ - service.PurchasableOffer(), - ], - next_page_token='ghi', - ), - service.ListPurchasableOffersResponse( - purchasable_offers=[ - service.PurchasableOffer(), - service.PurchasableOffer(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_purchasable_offers(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_register_subscriber(transport: str = 'grpc', request_type=service.RegisterSubscriberRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.register_subscriber), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.RegisterSubscriberResponse( - topic='topic_value', - ) - response = client.register_subscriber(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.RegisterSubscriberRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, service.RegisterSubscriberResponse) - assert response.topic == 'topic_value' - - -def test_register_subscriber_from_dict(): - test_register_subscriber(request_type=dict) - - -def test_register_subscriber_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.register_subscriber), - '__call__') as call: - client.register_subscriber() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.RegisterSubscriberRequest() - - -@pytest.mark.asyncio -async def test_register_subscriber_async(transport: str = 'grpc_asyncio', request_type=service.RegisterSubscriberRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.register_subscriber), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.RegisterSubscriberResponse( - topic='topic_value', - )) - response = await client.register_subscriber(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.RegisterSubscriberRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, service.RegisterSubscriberResponse) - assert response.topic == 'topic_value' - - -@pytest.mark.asyncio -async def test_register_subscriber_async_from_dict(): - await test_register_subscriber_async(request_type=dict) - - -def test_register_subscriber_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.RegisterSubscriberRequest() - - request.account = 'account/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.register_subscriber), - '__call__') as call: - call.return_value = service.RegisterSubscriberResponse() - client.register_subscriber(request) - - # Establish that the 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', - 'account=account/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_register_subscriber_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.RegisterSubscriberRequest() - - request.account = 'account/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.register_subscriber), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.RegisterSubscriberResponse()) - await client.register_subscriber(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', - 'account=account/value', - ) in kw['metadata'] - - -def test_unregister_subscriber(transport: str = 'grpc', request_type=service.UnregisterSubscriberRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.unregister_subscriber), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.UnregisterSubscriberResponse( - topic='topic_value', - ) - response = client.unregister_subscriber(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.UnregisterSubscriberRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, service.UnregisterSubscriberResponse) - assert response.topic == 'topic_value' - - -def test_unregister_subscriber_from_dict(): - test_unregister_subscriber(request_type=dict) - - -def test_unregister_subscriber_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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.unregister_subscriber), - '__call__') as call: - client.unregister_subscriber() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.UnregisterSubscriberRequest() - - -@pytest.mark.asyncio -async def test_unregister_subscriber_async(transport: str = 'grpc_asyncio', request_type=service.UnregisterSubscriberRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.unregister_subscriber), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.UnregisterSubscriberResponse( - topic='topic_value', - )) - response = await client.unregister_subscriber(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.UnregisterSubscriberRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, service.UnregisterSubscriberResponse) - assert response.topic == 'topic_value' - - -@pytest.mark.asyncio -async def test_unregister_subscriber_async_from_dict(): - await test_unregister_subscriber_async(request_type=dict) - - -def test_unregister_subscriber_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UnregisterSubscriberRequest() - - request.account = 'account/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.unregister_subscriber), - '__call__') as call: - call.return_value = service.UnregisterSubscriberResponse() - client.unregister_subscriber(request) - - # Establish that the 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', - 'account=account/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_unregister_subscriber_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.UnregisterSubscriberRequest() - - request.account = 'account/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.unregister_subscriber), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.UnregisterSubscriberResponse()) - await client.unregister_subscriber(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', - 'account=account/value', - ) in kw['metadata'] - - -def test_list_subscribers(transport: str = 'grpc', request_type=service.ListSubscribersRequest): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_subscribers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = service.ListSubscribersResponse( - topic='topic_value', - service_accounts=['service_accounts_value'], - next_page_token='next_page_token_value', - ) - response = client.list_subscribers(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.ListSubscribersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSubscribersPager) - assert response.topic == 'topic_value' - assert response.service_accounts == ['service_accounts_value'] - assert response.next_page_token == 'next_page_token_value' - - -def test_list_subscribers_from_dict(): - test_list_subscribers(request_type=dict) - - -def test_list_subscribers_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = CloudChannelServiceClient( - 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_subscribers), - '__call__') as call: - client.list_subscribers() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListSubscribersRequest() - - -@pytest.mark.asyncio -async def test_list_subscribers_async(transport: str = 'grpc_asyncio', request_type=service.ListSubscribersRequest): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_subscribers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(service.ListSubscribersResponse( - topic='topic_value', - service_accounts=['service_accounts_value'], - next_page_token='next_page_token_value', - )) - response = await client.list_subscribers(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == service.ListSubscribersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSubscribersAsyncPager) - assert response.topic == 'topic_value' - assert response.service_accounts == ['service_accounts_value'] - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_subscribers_async_from_dict(): - await test_list_subscribers_async(request_type=dict) - - -def test_list_subscribers_field_headers(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListSubscribersRequest() - - request.account = 'account/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_subscribers), - '__call__') as call: - call.return_value = service.ListSubscribersResponse() - client.list_subscribers(request) - - # Establish that the 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', - 'account=account/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_subscribers_field_headers_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = service.ListSubscribersRequest() - - request.account = 'account/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_subscribers), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.ListSubscribersResponse()) - await client.list_subscribers(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', - 'account=account/value', - ) in kw['metadata'] - - -def test_list_subscribers_pager(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_subscribers), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListSubscribersResponse( - service_accounts=[ - str(), - str(), - str(), - ], - next_page_token='abc', - ), - service.ListSubscribersResponse( - service_accounts=[], - next_page_token='def', - ), - service.ListSubscribersResponse( - service_accounts=[ - str(), - ], - next_page_token='ghi', - ), - service.ListSubscribersResponse( - service_accounts=[ - str(), - str(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('account', ''), - )), - ) - pager = client.list_subscribers(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, str) - for i in results) - -def test_list_subscribers_pages(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_subscribers), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListSubscribersResponse( - service_accounts=[ - str(), - str(), - str(), - ], - next_page_token='abc', - ), - service.ListSubscribersResponse( - service_accounts=[], - next_page_token='def', - ), - service.ListSubscribersResponse( - service_accounts=[ - str(), - ], - next_page_token='ghi', - ), - service.ListSubscribersResponse( - service_accounts=[ - str(), - str(), - ], - ), - RuntimeError, - ) - pages = list(client.list_subscribers(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_subscribers_async_pager(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_subscribers), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListSubscribersResponse( - service_accounts=[ - str(), - str(), - str(), - ], - next_page_token='abc', - ), - service.ListSubscribersResponse( - service_accounts=[], - next_page_token='def', - ), - service.ListSubscribersResponse( - service_accounts=[ - str(), - ], - next_page_token='ghi', - ), - service.ListSubscribersResponse( - service_accounts=[ - str(), - str(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_subscribers(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, str) - for i in responses) - -@pytest.mark.asyncio -async def test_list_subscribers_async_pages(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_subscribers), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - service.ListSubscribersResponse( - service_accounts=[ - str(), - str(), - str(), - ], - next_page_token='abc', - ), - service.ListSubscribersResponse( - service_accounts=[], - next_page_token='def', - ), - service.ListSubscribersResponse( - service_accounts=[ - str(), - ], - next_page_token='ghi', - ), - service.ListSubscribersResponse( - service_accounts=[ - str(), - str(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_subscribers(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.CloudChannelServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.CloudChannelServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CloudChannelServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.CloudChannelServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = CloudChannelServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.CloudChannelServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = CloudChannelServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.CloudChannelServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.CloudChannelServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.CloudChannelServiceGrpcTransport, - transports.CloudChannelServiceGrpcAsyncIOTransport, -]) -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 = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.CloudChannelServiceGrpcTransport, - ) - -def test_cloud_channel_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.CloudChannelServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_cloud_channel_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.channel_v1.services.cloud_channel_service.transports.CloudChannelServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.CloudChannelServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'list_customers', - 'get_customer', - 'check_cloud_identity_accounts_exist', - 'create_customer', - 'update_customer', - 'delete_customer', - 'import_customer', - 'provision_cloud_identity', - 'list_entitlements', - 'list_transferable_skus', - 'list_transferable_offers', - 'get_entitlement', - 'create_entitlement', - 'change_parameters', - 'change_renewal_settings', - 'change_offer', - 'start_paid_service', - 'suspend_entitlement', - 'cancel_entitlement', - 'activate_entitlement', - 'transfer_entitlements', - 'transfer_entitlements_to_google', - 'list_channel_partner_links', - 'get_channel_partner_link', - 'create_channel_partner_link', - 'update_channel_partner_link', - 'lookup_offer', - 'list_products', - 'list_skus', - 'list_offers', - 'list_purchasable_skus', - 'list_purchasable_offers', - 'register_subscriber', - 'unregister_subscriber', - 'list_subscribers', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - with pytest.raises(NotImplementedError): - transport.close() - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - -@requires_google_auth_gte_1_25_0 -def test_cloud_channel_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.channel_v1.services.cloud_channel_service.transports.CloudChannelServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CloudChannelServiceTransport( - 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/apps.order', -), - quota_project_id="octopus", - ) - - -@requires_google_auth_lt_1_25_0 -def test_cloud_channel_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.channel_v1.services.cloud_channel_service.transports.CloudChannelServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CloudChannelServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", scopes=( - 'https://www.googleapis.com/auth/apps.order', - ), - quota_project_id="octopus", - ) - - -def test_cloud_channel_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.channel_v1.services.cloud_channel_service.transports.CloudChannelServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CloudChannelServiceTransport() - adc.assert_called_once() - - -@requires_google_auth_gte_1_25_0 -def test_cloud_channel_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) - CloudChannelServiceClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/apps.order', -), - quota_project_id=None, - ) - - -@requires_google_auth_lt_1_25_0 -def test_cloud_channel_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) - CloudChannelServiceClient() - adc.assert_called_once_with( - scopes=( 'https://www.googleapis.com/auth/apps.order',), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.CloudChannelServiceGrpcTransport, - transports.CloudChannelServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_gte_1_25_0 -def test_cloud_channel_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/apps.order',), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.CloudChannelServiceGrpcTransport, - transports.CloudChannelServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_cloud_channel_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/apps.order', -), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.CloudChannelServiceGrpcTransport, grpc_helpers), - (transports.CloudChannelServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_cloud_channel_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( - "cloudchannel.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=( - 'https://www.googleapis.com/auth/apps.order', -), - scopes=["1", "2"], - default_host="cloudchannel.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.CloudChannelServiceGrpcTransport, transports.CloudChannelServiceGrpcAsyncIOTransport]) -def test_cloud_channel_service_grpc_transport_client_cert_source_for_mtls( - transport_class -): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, - private_key=expected_key - ) - - -def test_cloud_channel_service_host_no_port(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='cloudchannel.googleapis.com'), - ) - assert client.transport._host == 'cloudchannel.googleapis.com:443' - - -def test_cloud_channel_service_host_with_port(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='cloudchannel.googleapis.com:8000'), - ) - assert client.transport._host == 'cloudchannel.googleapis.com:8000' - -def test_cloud_channel_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CloudChannelServiceGrpcTransport( - 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_cloud_channel_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.CloudChannelServiceGrpcAsyncIOTransport( - 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.CloudChannelServiceGrpcTransport, transports.CloudChannelServiceGrpcAsyncIOTransport]) -def test_cloud_channel_service_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.CloudChannelServiceGrpcTransport, transports.CloudChannelServiceGrpcAsyncIOTransport]) -def test_cloud_channel_service_transport_channel_mtls_with_adc( - transport_class -): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_cloud_channel_service_grpc_lro_client(): - client = CloudChannelServiceClient( - 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_cloud_channel_service_grpc_lro_async_client(): - client = CloudChannelServiceAsyncClient( - 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_customer_path(): - account = "squid" - customer = "clam" - expected = "accounts/{account}/customers/{customer}".format(account=account, customer=customer, ) - actual = CloudChannelServiceClient.customer_path(account, customer) - assert expected == actual - - -def test_parse_customer_path(): - expected = { - "account": "whelk", - "customer": "octopus", - } - path = CloudChannelServiceClient.customer_path(**expected) - - # Check that the path construction is reversible. - actual = CloudChannelServiceClient.parse_customer_path(path) - assert expected == actual - -def test_entitlement_path(): - account = "oyster" - customer = "nudibranch" - entitlement = "cuttlefish" - expected = "accounts/{account}/customers/{customer}/entitlements/{entitlement}".format(account=account, customer=customer, entitlement=entitlement, ) - actual = CloudChannelServiceClient.entitlement_path(account, customer, entitlement) - assert expected == actual - - -def test_parse_entitlement_path(): - expected = { - "account": "mussel", - "customer": "winkle", - "entitlement": "nautilus", - } - path = CloudChannelServiceClient.entitlement_path(**expected) - - # Check that the path construction is reversible. - actual = CloudChannelServiceClient.parse_entitlement_path(path) - assert expected == actual - -def test_offer_path(): - account = "scallop" - offer = "abalone" - expected = "accounts/{account}/offers/{offer}".format(account=account, offer=offer, ) - actual = CloudChannelServiceClient.offer_path(account, offer) - assert expected == actual - - -def test_parse_offer_path(): - expected = { - "account": "squid", - "offer": "clam", - } - path = CloudChannelServiceClient.offer_path(**expected) - - # Check that the path construction is reversible. - actual = CloudChannelServiceClient.parse_offer_path(path) - assert expected == actual - -def test_product_path(): - product = "whelk" - expected = "products/{product}".format(product=product, ) - actual = CloudChannelServiceClient.product_path(product) - assert expected == actual - - -def test_parse_product_path(): - expected = { - "product": "octopus", - } - path = CloudChannelServiceClient.product_path(**expected) - - # Check that the path construction is reversible. - actual = CloudChannelServiceClient.parse_product_path(path) - assert expected == actual - -def test_sku_path(): - product = "oyster" - sku = "nudibranch" - expected = "products/{product}/skus/{sku}".format(product=product, sku=sku, ) - actual = CloudChannelServiceClient.sku_path(product, sku) - assert expected == actual - - -def test_parse_sku_path(): - expected = { - "product": "cuttlefish", - "sku": "mussel", - } - path = CloudChannelServiceClient.sku_path(**expected) - - # Check that the path construction is reversible. - actual = CloudChannelServiceClient.parse_sku_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "winkle" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = CloudChannelServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "nautilus", - } - path = CloudChannelServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = CloudChannelServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "scallop" - expected = "folders/{folder}".format(folder=folder, ) - actual = CloudChannelServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "abalone", - } - path = CloudChannelServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = CloudChannelServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "squid" - expected = "organizations/{organization}".format(organization=organization, ) - actual = CloudChannelServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "clam", - } - path = CloudChannelServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = CloudChannelServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "whelk" - expected = "projects/{project}".format(project=project, ) - actual = CloudChannelServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "octopus", - } - path = CloudChannelServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = CloudChannelServiceClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "oyster" - location = "nudibranch" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = CloudChannelServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "cuttlefish", - "location": "mussel", - } - path = CloudChannelServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = CloudChannelServiceClient.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.CloudChannelServiceTransport, '_prep_wrapped_messages') as prep: - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.CloudChannelServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = CloudChannelServiceClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - -@pytest.mark.asyncio -async def test_transport_close_async(): - client = CloudChannelServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc_asyncio", - ) - with mock.patch.object(type(getattr(client.transport, "grpc_channel")), "close") as close: - async with client: - close.assert_not_called() - close.assert_called_once() - -def test_transport_close(): - transports = { - "grpc": "_grpc_channel", - } - - for transport, close_name in transports.items(): - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport - ) - with mock.patch.object(type(getattr(client.transport, close_name)), "close") as close: - with client: - close.assert_not_called() - close.assert_called_once() - -def test_client_ctx(): - transports = [ - 'grpc', - ] - for transport in transports: - client = CloudChannelServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport - ) - # Test client calls underlying transport. - with mock.patch.object(type(client.transport), "close") as close: - close.assert_not_called() - with client: - pass - close.assert_called() diff --git a/tests/unit/gapic/channel_v1/test_cloud_channel_service.py b/tests/unit/gapic/channel_v1/test_cloud_channel_service.py index 1f6cc1f..1cc90eb 100644 --- a/tests/unit/gapic/channel_v1/test_cloud_channel_service.py +++ b/tests/unit/gapic/channel_v1/test_cloud_channel_service.py @@ -32,6 +32,7 @@ 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.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.channel_v1.services.cloud_channel_service import ( @@ -7563,6 +7564,9 @@ def test_cloud_channel_service_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -8158,3 +8162,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = CloudChannelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = CloudChannelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called()