From 1517e9d8c7e5964930e5f3d7719e84ba43b0e028 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Sun, 9 Jan 2022 21:54:51 +0000 Subject: [PATCH] feat: new API for the View resource PiperOrigin-RevId: 420129820 Source-Link: https://github.com/googleapis/googleapis/commit/c203eea797ddaaf841e996646445d1152abf22ec Source-Link: https://github.com/googleapis/googleapis-gen/commit/ddaafab91678bc0ff2aec1be577a6000d4393ac7 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGRhYWZhYjkxNjc4YmMwZmYyYWVjMWJlNTc3YTYwMDBkNDM5M2FjNyJ9 --- owl-bot-staging/v1/.coveragerc | 17 + owl-bot-staging/v1/MANIFEST.in | 2 + owl-bot-staging/v1/README.rst | 49 + owl-bot-staging/v1/docs/conf.py | 376 + .../contact_center_insights.rst | 10 + .../contact_center_insights_v1/services.rst | 6 + .../docs/contact_center_insights_v1/types.rst | 7 + owl-bot-staging/v1/docs/index.rst | 7 + .../cloud/contact_center_insights/__init__.py | 205 + .../cloud/contact_center_insights/py.typed | 2 + .../contact_center_insights_v1/__init__.py | 206 + .../gapic_metadata.json | 363 + .../cloud/contact_center_insights_v1/py.typed | 2 + .../services/__init__.py | 15 + .../contact_center_insights/__init__.py | 22 + .../contact_center_insights/async_client.py | 2890 +++++ .../contact_center_insights/client.py | 3151 +++++ .../contact_center_insights/pagers.py | 503 + .../transports/__init__.py | 33 + .../transports/base.py | 616 + .../transports/grpc.py | 1140 ++ .../transports/grpc_asyncio.py | 1144 ++ .../types/__init__.py | 204 + .../types/contact_center_insights.py | 1387 +++ .../types/resources.py | 2017 +++ owl-bot-staging/v1/mypy.ini | 3 + owl-bot-staging/v1/noxfile.py | 132 + ...xup_contact_center_insights_v1_keywords.py | 209 + 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 + .../contact_center_insights_v1/__init__.py | 16 + .../test_contact_center_insights.py | 10155 ++++++++++++++++ 34 files changed, 24991 insertions(+) create mode 100644 owl-bot-staging/v1/.coveragerc create mode 100644 owl-bot-staging/v1/MANIFEST.in create mode 100644 owl-bot-staging/v1/README.rst create mode 100644 owl-bot-staging/v1/docs/conf.py create mode 100644 owl-bot-staging/v1/docs/contact_center_insights_v1/contact_center_insights.rst create mode 100644 owl-bot-staging/v1/docs/contact_center_insights_v1/services.rst create mode 100644 owl-bot-staging/v1/docs/contact_center_insights_v1/types.rst create mode 100644 owl-bot-staging/v1/docs/index.rst create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/py.typed create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/types/__init__.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/types/contact_center_insights.py create mode 100644 owl-bot-staging/v1/google/cloud/contact_center_insights_v1/types/resources.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_contact_center_insights_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/contact_center_insights_v1/__init__.py create mode 100644 owl-bot-staging/v1/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py diff --git a/owl-bot-staging/v1/.coveragerc b/owl-bot-staging/v1/.coveragerc new file mode 100644 index 0000000..0bd3a23 --- /dev/null +++ b/owl-bot-staging/v1/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/contact_center_insights/__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..405104e --- /dev/null +++ b/owl-bot-staging/v1/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/contact_center_insights *.py +recursive-include google/cloud/contact_center_insights_v1 *.py diff --git a/owl-bot-staging/v1/README.rst b/owl-bot-staging/v1/README.rst new file mode 100644 index 0000000..d53e851 --- /dev/null +++ b/owl-bot-staging/v1/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Contact Center Insights 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 Contact Center Insights API. +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + python3 -m venv + source /bin/activate + /bin/pip install /path/to/library + + +Windows +^^^^^^^ + +.. code-block:: console + + python3 -m venv + \Scripts\activate + \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/v1/docs/conf.py b/owl-bot-staging/v1/docs/conf.py new file mode 100644 index 0000000..10b09db --- /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-contact-center-insights 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-contact-center-insights" +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-contact-center-insights-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-contact-center-insights.tex", + u"google-cloud-contact-center-insights 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-contact-center-insights", + u"Google Cloud Contact Center Insights 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-contact-center-insights", + u"google-cloud-contact-center-insights Documentation", + author, + "google-cloud-contact-center-insights", + "GAPIC library for Google Cloud Contact Center Insights 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/contact_center_insights_v1/contact_center_insights.rst b/owl-bot-staging/v1/docs/contact_center_insights_v1/contact_center_insights.rst new file mode 100644 index 0000000..bb343f0 --- /dev/null +++ b/owl-bot-staging/v1/docs/contact_center_insights_v1/contact_center_insights.rst @@ -0,0 +1,10 @@ +ContactCenterInsights +--------------------------------------- + +.. automodule:: google.cloud.contact_center_insights_v1.services.contact_center_insights + :members: + :inherited-members: + +.. automodule:: google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v1/docs/contact_center_insights_v1/services.rst b/owl-bot-staging/v1/docs/contact_center_insights_v1/services.rst new file mode 100644 index 0000000..0147aec --- /dev/null +++ b/owl-bot-staging/v1/docs/contact_center_insights_v1/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Contact Center Insights v1 API +======================================================== +.. toctree:: + :maxdepth: 2 + + contact_center_insights diff --git a/owl-bot-staging/v1/docs/contact_center_insights_v1/types.rst b/owl-bot-staging/v1/docs/contact_center_insights_v1/types.rst new file mode 100644 index 0000000..5f079d6 --- /dev/null +++ b/owl-bot-staging/v1/docs/contact_center_insights_v1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Contact Center Insights v1 API +===================================================== + +.. automodule:: google.cloud.contact_center_insights_v1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1/docs/index.rst b/owl-bot-staging/v1/docs/index.rst new file mode 100644 index 0000000..d91ad87 --- /dev/null +++ b/owl-bot-staging/v1/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + contact_center_insights_v1/services + contact_center_insights_v1/types diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights/__init__.py b/owl-bot-staging/v1/google/cloud/contact_center_insights/__init__.py new file mode 100644 index 0000000..c488ada --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights/__init__.py @@ -0,0 +1,205 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.contact_center_insights_v1.services.contact_center_insights.client import ContactCenterInsightsClient +from google.cloud.contact_center_insights_v1.services.contact_center_insights.async_client import ContactCenterInsightsAsyncClient + +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CalculateIssueModelStatsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CalculateIssueModelStatsResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CalculateStatsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CalculateStatsResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateAnalysisOperationMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateAnalysisRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateConversationRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateIssueModelMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateIssueModelRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreatePhraseMatcherRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateViewRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteAnalysisRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteConversationRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteIssueModelMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteIssueModelRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeletePhraseMatcherRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteViewRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeployIssueModelMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeployIssueModelRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeployIssueModelResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ExportInsightsDataMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ExportInsightsDataRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ExportInsightsDataResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetAnalysisRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetConversationRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetIssueModelRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetIssueRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetPhraseMatcherRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetSettingsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetViewRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListAnalysesRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListAnalysesResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListConversationsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListConversationsResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListIssueModelsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListIssueModelsResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListIssuesRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListIssuesResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListPhraseMatchersRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListPhraseMatchersResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListViewsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListViewsResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UndeployIssueModelMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UndeployIssueModelRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UndeployIssueModelResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateConversationRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateIssueModelRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateIssueRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdatePhraseMatcherRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateSettingsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateViewRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ConversationView +from google.cloud.contact_center_insights_v1.types.resources import Analysis +from google.cloud.contact_center_insights_v1.types.resources import AnalysisResult +from google.cloud.contact_center_insights_v1.types.resources import AnnotationBoundary +from google.cloud.contact_center_insights_v1.types.resources import AnswerFeedback +from google.cloud.contact_center_insights_v1.types.resources import ArticleSuggestionData +from google.cloud.contact_center_insights_v1.types.resources import CallAnnotation +from google.cloud.contact_center_insights_v1.types.resources import Conversation +from google.cloud.contact_center_insights_v1.types.resources import ConversationDataSource +from google.cloud.contact_center_insights_v1.types.resources import ConversationLevelSentiment +from google.cloud.contact_center_insights_v1.types.resources import ConversationParticipant +from google.cloud.contact_center_insights_v1.types.resources import DialogflowIntent +from google.cloud.contact_center_insights_v1.types.resources import DialogflowInteractionData +from google.cloud.contact_center_insights_v1.types.resources import DialogflowSource +from google.cloud.contact_center_insights_v1.types.resources import Entity +from google.cloud.contact_center_insights_v1.types.resources import EntityMentionData +from google.cloud.contact_center_insights_v1.types.resources import ExactMatchConfig +from google.cloud.contact_center_insights_v1.types.resources import FaqAnswerData +from google.cloud.contact_center_insights_v1.types.resources import GcsSource +from google.cloud.contact_center_insights_v1.types.resources import HoldData +from google.cloud.contact_center_insights_v1.types.resources import Intent +from google.cloud.contact_center_insights_v1.types.resources import IntentMatchData +from google.cloud.contact_center_insights_v1.types.resources import InterruptionData +from google.cloud.contact_center_insights_v1.types.resources import Issue +from google.cloud.contact_center_insights_v1.types.resources import IssueAssignment +from google.cloud.contact_center_insights_v1.types.resources import IssueModel +from google.cloud.contact_center_insights_v1.types.resources import IssueModelLabelStats +from google.cloud.contact_center_insights_v1.types.resources import IssueModelResult +from google.cloud.contact_center_insights_v1.types.resources import PhraseMatchData +from google.cloud.contact_center_insights_v1.types.resources import PhraseMatcher +from google.cloud.contact_center_insights_v1.types.resources import PhraseMatchRule +from google.cloud.contact_center_insights_v1.types.resources import PhraseMatchRuleConfig +from google.cloud.contact_center_insights_v1.types.resources import PhraseMatchRuleGroup +from google.cloud.contact_center_insights_v1.types.resources import RuntimeAnnotation +from google.cloud.contact_center_insights_v1.types.resources import SentimentData +from google.cloud.contact_center_insights_v1.types.resources import Settings +from google.cloud.contact_center_insights_v1.types.resources import SilenceData +from google.cloud.contact_center_insights_v1.types.resources import SmartComposeSuggestionData +from google.cloud.contact_center_insights_v1.types.resources import SmartReplyData +from google.cloud.contact_center_insights_v1.types.resources import View + +__all__ = ('ContactCenterInsightsClient', + 'ContactCenterInsightsAsyncClient', + 'CalculateIssueModelStatsRequest', + 'CalculateIssueModelStatsResponse', + 'CalculateStatsRequest', + 'CalculateStatsResponse', + 'CreateAnalysisOperationMetadata', + 'CreateAnalysisRequest', + 'CreateConversationRequest', + 'CreateIssueModelMetadata', + 'CreateIssueModelRequest', + 'CreatePhraseMatcherRequest', + 'CreateViewRequest', + 'DeleteAnalysisRequest', + 'DeleteConversationRequest', + 'DeleteIssueModelMetadata', + 'DeleteIssueModelRequest', + 'DeletePhraseMatcherRequest', + 'DeleteViewRequest', + 'DeployIssueModelMetadata', + 'DeployIssueModelRequest', + 'DeployIssueModelResponse', + 'ExportInsightsDataMetadata', + 'ExportInsightsDataRequest', + 'ExportInsightsDataResponse', + 'GetAnalysisRequest', + 'GetConversationRequest', + 'GetIssueModelRequest', + 'GetIssueRequest', + 'GetPhraseMatcherRequest', + 'GetSettingsRequest', + 'GetViewRequest', + 'ListAnalysesRequest', + 'ListAnalysesResponse', + 'ListConversationsRequest', + 'ListConversationsResponse', + 'ListIssueModelsRequest', + 'ListIssueModelsResponse', + 'ListIssuesRequest', + 'ListIssuesResponse', + 'ListPhraseMatchersRequest', + 'ListPhraseMatchersResponse', + 'ListViewsRequest', + 'ListViewsResponse', + 'UndeployIssueModelMetadata', + 'UndeployIssueModelRequest', + 'UndeployIssueModelResponse', + 'UpdateConversationRequest', + 'UpdateIssueModelRequest', + 'UpdateIssueRequest', + 'UpdatePhraseMatcherRequest', + 'UpdateSettingsRequest', + 'UpdateViewRequest', + 'ConversationView', + 'Analysis', + 'AnalysisResult', + 'AnnotationBoundary', + 'AnswerFeedback', + 'ArticleSuggestionData', + 'CallAnnotation', + 'Conversation', + 'ConversationDataSource', + 'ConversationLevelSentiment', + 'ConversationParticipant', + 'DialogflowIntent', + 'DialogflowInteractionData', + 'DialogflowSource', + 'Entity', + 'EntityMentionData', + 'ExactMatchConfig', + 'FaqAnswerData', + 'GcsSource', + 'HoldData', + 'Intent', + 'IntentMatchData', + 'InterruptionData', + 'Issue', + 'IssueAssignment', + 'IssueModel', + 'IssueModelLabelStats', + 'IssueModelResult', + 'PhraseMatchData', + 'PhraseMatcher', + 'PhraseMatchRule', + 'PhraseMatchRuleConfig', + 'PhraseMatchRuleGroup', + 'RuntimeAnnotation', + 'SentimentData', + 'Settings', + 'SilenceData', + 'SmartComposeSuggestionData', + 'SmartReplyData', + 'View', +) diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights/py.typed b/owl-bot-staging/v1/google/cloud/contact_center_insights/py.typed new file mode 100644 index 0000000..d02b3b4 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-contact-center-insights package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/__init__.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/__init__.py new file mode 100644 index 0000000..f063340 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/__init__.py @@ -0,0 +1,206 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.contact_center_insights import ContactCenterInsightsClient +from .services.contact_center_insights import ContactCenterInsightsAsyncClient + +from .types.contact_center_insights import CalculateIssueModelStatsRequest +from .types.contact_center_insights import CalculateIssueModelStatsResponse +from .types.contact_center_insights import CalculateStatsRequest +from .types.contact_center_insights import CalculateStatsResponse +from .types.contact_center_insights import CreateAnalysisOperationMetadata +from .types.contact_center_insights import CreateAnalysisRequest +from .types.contact_center_insights import CreateConversationRequest +from .types.contact_center_insights import CreateIssueModelMetadata +from .types.contact_center_insights import CreateIssueModelRequest +from .types.contact_center_insights import CreatePhraseMatcherRequest +from .types.contact_center_insights import CreateViewRequest +from .types.contact_center_insights import DeleteAnalysisRequest +from .types.contact_center_insights import DeleteConversationRequest +from .types.contact_center_insights import DeleteIssueModelMetadata +from .types.contact_center_insights import DeleteIssueModelRequest +from .types.contact_center_insights import DeletePhraseMatcherRequest +from .types.contact_center_insights import DeleteViewRequest +from .types.contact_center_insights import DeployIssueModelMetadata +from .types.contact_center_insights import DeployIssueModelRequest +from .types.contact_center_insights import DeployIssueModelResponse +from .types.contact_center_insights import ExportInsightsDataMetadata +from .types.contact_center_insights import ExportInsightsDataRequest +from .types.contact_center_insights import ExportInsightsDataResponse +from .types.contact_center_insights import GetAnalysisRequest +from .types.contact_center_insights import GetConversationRequest +from .types.contact_center_insights import GetIssueModelRequest +from .types.contact_center_insights import GetIssueRequest +from .types.contact_center_insights import GetPhraseMatcherRequest +from .types.contact_center_insights import GetSettingsRequest +from .types.contact_center_insights import GetViewRequest +from .types.contact_center_insights import ListAnalysesRequest +from .types.contact_center_insights import ListAnalysesResponse +from .types.contact_center_insights import ListConversationsRequest +from .types.contact_center_insights import ListConversationsResponse +from .types.contact_center_insights import ListIssueModelsRequest +from .types.contact_center_insights import ListIssueModelsResponse +from .types.contact_center_insights import ListIssuesRequest +from .types.contact_center_insights import ListIssuesResponse +from .types.contact_center_insights import ListPhraseMatchersRequest +from .types.contact_center_insights import ListPhraseMatchersResponse +from .types.contact_center_insights import ListViewsRequest +from .types.contact_center_insights import ListViewsResponse +from .types.contact_center_insights import UndeployIssueModelMetadata +from .types.contact_center_insights import UndeployIssueModelRequest +from .types.contact_center_insights import UndeployIssueModelResponse +from .types.contact_center_insights import UpdateConversationRequest +from .types.contact_center_insights import UpdateIssueModelRequest +from .types.contact_center_insights import UpdateIssueRequest +from .types.contact_center_insights import UpdatePhraseMatcherRequest +from .types.contact_center_insights import UpdateSettingsRequest +from .types.contact_center_insights import UpdateViewRequest +from .types.contact_center_insights import ConversationView +from .types.resources import Analysis +from .types.resources import AnalysisResult +from .types.resources import AnnotationBoundary +from .types.resources import AnswerFeedback +from .types.resources import ArticleSuggestionData +from .types.resources import CallAnnotation +from .types.resources import Conversation +from .types.resources import ConversationDataSource +from .types.resources import ConversationLevelSentiment +from .types.resources import ConversationParticipant +from .types.resources import DialogflowIntent +from .types.resources import DialogflowInteractionData +from .types.resources import DialogflowSource +from .types.resources import Entity +from .types.resources import EntityMentionData +from .types.resources import ExactMatchConfig +from .types.resources import FaqAnswerData +from .types.resources import GcsSource +from .types.resources import HoldData +from .types.resources import Intent +from .types.resources import IntentMatchData +from .types.resources import InterruptionData +from .types.resources import Issue +from .types.resources import IssueAssignment +from .types.resources import IssueModel +from .types.resources import IssueModelLabelStats +from .types.resources import IssueModelResult +from .types.resources import PhraseMatchData +from .types.resources import PhraseMatcher +from .types.resources import PhraseMatchRule +from .types.resources import PhraseMatchRuleConfig +from .types.resources import PhraseMatchRuleGroup +from .types.resources import RuntimeAnnotation +from .types.resources import SentimentData +from .types.resources import Settings +from .types.resources import SilenceData +from .types.resources import SmartComposeSuggestionData +from .types.resources import SmartReplyData +from .types.resources import View + +__all__ = ( + 'ContactCenterInsightsAsyncClient', +'Analysis', +'AnalysisResult', +'AnnotationBoundary', +'AnswerFeedback', +'ArticleSuggestionData', +'CalculateIssueModelStatsRequest', +'CalculateIssueModelStatsResponse', +'CalculateStatsRequest', +'CalculateStatsResponse', +'CallAnnotation', +'ContactCenterInsightsClient', +'Conversation', +'ConversationDataSource', +'ConversationLevelSentiment', +'ConversationParticipant', +'ConversationView', +'CreateAnalysisOperationMetadata', +'CreateAnalysisRequest', +'CreateConversationRequest', +'CreateIssueModelMetadata', +'CreateIssueModelRequest', +'CreatePhraseMatcherRequest', +'CreateViewRequest', +'DeleteAnalysisRequest', +'DeleteConversationRequest', +'DeleteIssueModelMetadata', +'DeleteIssueModelRequest', +'DeletePhraseMatcherRequest', +'DeleteViewRequest', +'DeployIssueModelMetadata', +'DeployIssueModelRequest', +'DeployIssueModelResponse', +'DialogflowIntent', +'DialogflowInteractionData', +'DialogflowSource', +'Entity', +'EntityMentionData', +'ExactMatchConfig', +'ExportInsightsDataMetadata', +'ExportInsightsDataRequest', +'ExportInsightsDataResponse', +'FaqAnswerData', +'GcsSource', +'GetAnalysisRequest', +'GetConversationRequest', +'GetIssueModelRequest', +'GetIssueRequest', +'GetPhraseMatcherRequest', +'GetSettingsRequest', +'GetViewRequest', +'HoldData', +'Intent', +'IntentMatchData', +'InterruptionData', +'Issue', +'IssueAssignment', +'IssueModel', +'IssueModelLabelStats', +'IssueModelResult', +'ListAnalysesRequest', +'ListAnalysesResponse', +'ListConversationsRequest', +'ListConversationsResponse', +'ListIssueModelsRequest', +'ListIssueModelsResponse', +'ListIssuesRequest', +'ListIssuesResponse', +'ListPhraseMatchersRequest', +'ListPhraseMatchersResponse', +'ListViewsRequest', +'ListViewsResponse', +'PhraseMatchData', +'PhraseMatchRule', +'PhraseMatchRuleConfig', +'PhraseMatchRuleGroup', +'PhraseMatcher', +'RuntimeAnnotation', +'SentimentData', +'Settings', +'SilenceData', +'SmartComposeSuggestionData', +'SmartReplyData', +'UndeployIssueModelMetadata', +'UndeployIssueModelRequest', +'UndeployIssueModelResponse', +'UpdateConversationRequest', +'UpdateIssueModelRequest', +'UpdateIssueRequest', +'UpdatePhraseMatcherRequest', +'UpdateSettingsRequest', +'UpdateViewRequest', +'View', +) diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/gapic_metadata.json b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/gapic_metadata.json new file mode 100644 index 0000000..94ba0d1 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/gapic_metadata.json @@ -0,0 +1,363 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.contact_center_insights_v1", + "protoPackage": "google.cloud.contactcenterinsights.v1", + "schema": "1.0", + "services": { + "ContactCenterInsights": { + "clients": { + "grpc": { + "libraryClient": "ContactCenterInsightsClient", + "rpcs": { + "CalculateIssueModelStats": { + "methods": [ + "calculate_issue_model_stats" + ] + }, + "CalculateStats": { + "methods": [ + "calculate_stats" + ] + }, + "CreateAnalysis": { + "methods": [ + "create_analysis" + ] + }, + "CreateConversation": { + "methods": [ + "create_conversation" + ] + }, + "CreateIssueModel": { + "methods": [ + "create_issue_model" + ] + }, + "CreatePhraseMatcher": { + "methods": [ + "create_phrase_matcher" + ] + }, + "CreateView": { + "methods": [ + "create_view" + ] + }, + "DeleteAnalysis": { + "methods": [ + "delete_analysis" + ] + }, + "DeleteConversation": { + "methods": [ + "delete_conversation" + ] + }, + "DeleteIssueModel": { + "methods": [ + "delete_issue_model" + ] + }, + "DeletePhraseMatcher": { + "methods": [ + "delete_phrase_matcher" + ] + }, + "DeleteView": { + "methods": [ + "delete_view" + ] + }, + "DeployIssueModel": { + "methods": [ + "deploy_issue_model" + ] + }, + "ExportInsightsData": { + "methods": [ + "export_insights_data" + ] + }, + "GetAnalysis": { + "methods": [ + "get_analysis" + ] + }, + "GetConversation": { + "methods": [ + "get_conversation" + ] + }, + "GetIssue": { + "methods": [ + "get_issue" + ] + }, + "GetIssueModel": { + "methods": [ + "get_issue_model" + ] + }, + "GetPhraseMatcher": { + "methods": [ + "get_phrase_matcher" + ] + }, + "GetSettings": { + "methods": [ + "get_settings" + ] + }, + "GetView": { + "methods": [ + "get_view" + ] + }, + "ListAnalyses": { + "methods": [ + "list_analyses" + ] + }, + "ListConversations": { + "methods": [ + "list_conversations" + ] + }, + "ListIssueModels": { + "methods": [ + "list_issue_models" + ] + }, + "ListIssues": { + "methods": [ + "list_issues" + ] + }, + "ListPhraseMatchers": { + "methods": [ + "list_phrase_matchers" + ] + }, + "ListViews": { + "methods": [ + "list_views" + ] + }, + "UndeployIssueModel": { + "methods": [ + "undeploy_issue_model" + ] + }, + "UpdateConversation": { + "methods": [ + "update_conversation" + ] + }, + "UpdateIssue": { + "methods": [ + "update_issue" + ] + }, + "UpdateIssueModel": { + "methods": [ + "update_issue_model" + ] + }, + "UpdatePhraseMatcher": { + "methods": [ + "update_phrase_matcher" + ] + }, + "UpdateSettings": { + "methods": [ + "update_settings" + ] + }, + "UpdateView": { + "methods": [ + "update_view" + ] + } + } + }, + "grpc-async": { + "libraryClient": "ContactCenterInsightsAsyncClient", + "rpcs": { + "CalculateIssueModelStats": { + "methods": [ + "calculate_issue_model_stats" + ] + }, + "CalculateStats": { + "methods": [ + "calculate_stats" + ] + }, + "CreateAnalysis": { + "methods": [ + "create_analysis" + ] + }, + "CreateConversation": { + "methods": [ + "create_conversation" + ] + }, + "CreateIssueModel": { + "methods": [ + "create_issue_model" + ] + }, + "CreatePhraseMatcher": { + "methods": [ + "create_phrase_matcher" + ] + }, + "CreateView": { + "methods": [ + "create_view" + ] + }, + "DeleteAnalysis": { + "methods": [ + "delete_analysis" + ] + }, + "DeleteConversation": { + "methods": [ + "delete_conversation" + ] + }, + "DeleteIssueModel": { + "methods": [ + "delete_issue_model" + ] + }, + "DeletePhraseMatcher": { + "methods": [ + "delete_phrase_matcher" + ] + }, + "DeleteView": { + "methods": [ + "delete_view" + ] + }, + "DeployIssueModel": { + "methods": [ + "deploy_issue_model" + ] + }, + "ExportInsightsData": { + "methods": [ + "export_insights_data" + ] + }, + "GetAnalysis": { + "methods": [ + "get_analysis" + ] + }, + "GetConversation": { + "methods": [ + "get_conversation" + ] + }, + "GetIssue": { + "methods": [ + "get_issue" + ] + }, + "GetIssueModel": { + "methods": [ + "get_issue_model" + ] + }, + "GetPhraseMatcher": { + "methods": [ + "get_phrase_matcher" + ] + }, + "GetSettings": { + "methods": [ + "get_settings" + ] + }, + "GetView": { + "methods": [ + "get_view" + ] + }, + "ListAnalyses": { + "methods": [ + "list_analyses" + ] + }, + "ListConversations": { + "methods": [ + "list_conversations" + ] + }, + "ListIssueModels": { + "methods": [ + "list_issue_models" + ] + }, + "ListIssues": { + "methods": [ + "list_issues" + ] + }, + "ListPhraseMatchers": { + "methods": [ + "list_phrase_matchers" + ] + }, + "ListViews": { + "methods": [ + "list_views" + ] + }, + "UndeployIssueModel": { + "methods": [ + "undeploy_issue_model" + ] + }, + "UpdateConversation": { + "methods": [ + "update_conversation" + ] + }, + "UpdateIssue": { + "methods": [ + "update_issue" + ] + }, + "UpdateIssueModel": { + "methods": [ + "update_issue_model" + ] + }, + "UpdatePhraseMatcher": { + "methods": [ + "update_phrase_matcher" + ] + }, + "UpdateSettings": { + "methods": [ + "update_settings" + ] + }, + "UpdateView": { + "methods": [ + "update_view" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/py.typed b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/py.typed new file mode 100644 index 0000000..d02b3b4 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-contact-center-insights package uses inline types. diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/__init__.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_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/contact_center_insights_v1/services/contact_center_insights/__init__.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/__init__.py new file mode 100644 index 0000000..50061f4 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/__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 ContactCenterInsightsClient +from .async_client import ContactCenterInsightsAsyncClient + +__all__ = ( + 'ContactCenterInsightsClient', + 'ContactCenterInsightsAsyncClient', +) diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py new file mode 100644 index 0000000..b5b688a --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py @@ -0,0 +1,2890 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 + +from google.api_core.client_options import ClientOptions +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.contact_center_insights_v1.services.contact_center_insights import pagers +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import ContactCenterInsightsGrpcAsyncIOTransport +from .client import ContactCenterInsightsClient + + +class ContactCenterInsightsAsyncClient: + """An API that lets users analyze and explore their business + conversation data. + """ + + _client: ContactCenterInsightsClient + + DEFAULT_ENDPOINT = ContactCenterInsightsClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = ContactCenterInsightsClient.DEFAULT_MTLS_ENDPOINT + + analysis_path = staticmethod(ContactCenterInsightsClient.analysis_path) + parse_analysis_path = staticmethod(ContactCenterInsightsClient.parse_analysis_path) + conversation_path = staticmethod(ContactCenterInsightsClient.conversation_path) + parse_conversation_path = staticmethod(ContactCenterInsightsClient.parse_conversation_path) + issue_path = staticmethod(ContactCenterInsightsClient.issue_path) + parse_issue_path = staticmethod(ContactCenterInsightsClient.parse_issue_path) + issue_model_path = staticmethod(ContactCenterInsightsClient.issue_model_path) + parse_issue_model_path = staticmethod(ContactCenterInsightsClient.parse_issue_model_path) + participant_path = staticmethod(ContactCenterInsightsClient.participant_path) + parse_participant_path = staticmethod(ContactCenterInsightsClient.parse_participant_path) + phrase_matcher_path = staticmethod(ContactCenterInsightsClient.phrase_matcher_path) + parse_phrase_matcher_path = staticmethod(ContactCenterInsightsClient.parse_phrase_matcher_path) + settings_path = staticmethod(ContactCenterInsightsClient.settings_path) + parse_settings_path = staticmethod(ContactCenterInsightsClient.parse_settings_path) + view_path = staticmethod(ContactCenterInsightsClient.view_path) + parse_view_path = staticmethod(ContactCenterInsightsClient.parse_view_path) + common_billing_account_path = staticmethod(ContactCenterInsightsClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(ContactCenterInsightsClient.parse_common_billing_account_path) + common_folder_path = staticmethod(ContactCenterInsightsClient.common_folder_path) + parse_common_folder_path = staticmethod(ContactCenterInsightsClient.parse_common_folder_path) + common_organization_path = staticmethod(ContactCenterInsightsClient.common_organization_path) + parse_common_organization_path = staticmethod(ContactCenterInsightsClient.parse_common_organization_path) + common_project_path = staticmethod(ContactCenterInsightsClient.common_project_path) + parse_common_project_path = staticmethod(ContactCenterInsightsClient.parse_common_project_path) + common_location_path = staticmethod(ContactCenterInsightsClient.common_location_path) + parse_common_location_path = staticmethod(ContactCenterInsightsClient.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: + ContactCenterInsightsAsyncClient: The constructed client. + """ + return ContactCenterInsightsClient.from_service_account_info.__func__(ContactCenterInsightsAsyncClient, 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: + ContactCenterInsightsAsyncClient: The constructed client. + """ + return ContactCenterInsightsClient.from_service_account_file.__func__(ContactCenterInsightsAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> ContactCenterInsightsTransport: + """Returns the transport used by the client instance. + + Returns: + ContactCenterInsightsTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(ContactCenterInsightsClient).get_transport_class, type(ContactCenterInsightsClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, ContactCenterInsightsTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the contact center insights 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, ~.ContactCenterInsightsTransport]): 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 = ContactCenterInsightsClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def create_conversation(self, + request: Union[contact_center_insights.CreateConversationRequest, dict] = None, + *, + parent: str = None, + conversation: resources.Conversation = None, + conversation_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Creates a conversation. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateConversationRequest, dict]): + The request object. Request to create a conversation. + parent (:class:`str`): + Required. The parent resource of the + conversation. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + conversation (:class:`google.cloud.contact_center_insights_v1.types.Conversation`): + Required. The conversation resource + to create. + + This corresponds to the ``conversation`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + conversation_id (:class:`str`): + A unique ID for the new conversation. This ID will + become the final component of the conversation's + resource name. If no ID is specified, a server-generated + ID will be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid + characters are ``[a-z][0-9]-`` + + This corresponds to the ``conversation_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Conversation: + The conversation resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, conversation, conversation_id]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.CreateConversationRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if conversation is not None: + request.conversation = conversation + if conversation_id is not None: + request.conversation_id = conversation_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_conversation, + 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_conversation(self, + request: Union[contact_center_insights.UpdateConversationRequest, dict] = None, + *, + conversation: resources.Conversation = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Updates a conversation. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateConversationRequest, dict]): + The request object. The request to update a + conversation. + conversation (:class:`google.cloud.contact_center_insights_v1.types.Conversation`): + Required. The new values for the + conversation. + + This corresponds to the ``conversation`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Conversation: + The conversation resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([conversation, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UpdateConversationRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if conversation is not None: + request.conversation = conversation + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_conversation, + 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(( + ("conversation.name", request.conversation.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_conversation(self, + request: Union[contact_center_insights.GetConversationRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Gets a conversation. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetConversationRequest, dict]): + The request object. The request to get a conversation. + name (:class:`str`): + Required. The name of the + conversation to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Conversation: + The conversation resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 = contact_center_insights.GetConversationRequest(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_conversation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_conversations(self, + request: Union[contact_center_insights.ListConversationsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListConversationsAsyncPager: + r"""Lists conversations. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListConversationsRequest, dict]): + The request object. Request to list conversations. + parent (:class:`str`): + Required. The parent resource of the + conversation. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsAsyncPager: + The response of listing + conversations. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ListConversationsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_conversations, + 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.ListConversationsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_conversation(self, + request: Union[contact_center_insights.DeleteConversationRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a conversation. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteConversationRequest, dict]): + The request object. The request to delete a + conversation. + name (:class:`str`): + Required. The name of the + conversation 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 = contact_center_insights.DeleteConversationRequest(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_conversation, + 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 create_analysis(self, + request: Union[contact_center_insights.CreateAnalysisRequest, dict] = None, + *, + parent: str = None, + analysis: resources.Analysis = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates an analysis. The long running operation is + done when the analysis has completed. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest, dict]): + The request object. The request to create an analysis. + parent (:class:`str`): + Required. The parent resource of the + analysis. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + analysis (:class:`google.cloud.contact_center_insights_v1.types.Analysis`): + Required. The analysis to create. + This corresponds to the ``analysis`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.contact_center_insights_v1.types.Analysis` + The analysis resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, analysis]) + if request is 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 = contact_center_insights.CreateAnalysisRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if analysis is not None: + request.analysis = analysis + + # 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_analysis, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.Analysis, + metadata_type=contact_center_insights.CreateAnalysisOperationMetadata, + ) + + # Done; return the response. + return response + + async def get_analysis(self, + request: Union[contact_center_insights.GetAnalysisRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Analysis: + r"""Gets an analysis. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetAnalysisRequest, dict]): + The request object. The request to get an analysis. + name (:class:`str`): + Required. The name of the analysis to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Analysis: + The analysis resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 = contact_center_insights.GetAnalysisRequest(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_analysis, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_analyses(self, + request: Union[contact_center_insights.ListAnalysesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAnalysesAsyncPager: + r"""Lists analyses. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListAnalysesRequest, dict]): + The request object. The request to list analyses. + parent (:class:`str`): + Required. The parent resource of the + analyses. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesAsyncPager: + The response to list analyses. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ListAnalysesRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_analyses, + 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.ListAnalysesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_analysis(self, + request: Union[contact_center_insights.DeleteAnalysisRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an analysis. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest, dict]): + The request object. The request to delete an analysis. + name (:class:`str`): + Required. The name of the analysis 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 = contact_center_insights.DeleteAnalysisRequest(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_analysis, + 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 export_insights_data(self, + request: Union[contact_center_insights.ExportInsightsDataRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Export insights data to a destination defined in the + request body. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest, dict]): + The request object. The request to export insights. + parent (:class:`str`): + Required. The parent resource to + export data from. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.ExportInsightsDataResponse` + Response for an export insights operation. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ExportInsightsDataRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.export_insights_data, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.ExportInsightsDataResponse, + metadata_type=contact_center_insights.ExportInsightsDataMetadata, + ) + + # Done; return the response. + return response + + async def create_issue_model(self, + request: Union[contact_center_insights.CreateIssueModelRequest, dict] = None, + *, + parent: str = None, + issue_model: resources.IssueModel = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates an issue model. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest, dict]): + The request object. The request to create an issue + model. + parent (:class:`str`): + Required. The parent resource of the + issue model. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + issue_model (:class:`google.cloud.contact_center_insights_v1.types.IssueModel`): + Required. The issue model to create. + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.contact_center_insights_v1.types.IssueModel` + The issue model resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, issue_model]) + if request is 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 = contact_center_insights.CreateIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if issue_model is not None: + request.issue_model = issue_model + + # 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_issue_model, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.IssueModel, + metadata_type=contact_center_insights.CreateIssueModelMetadata, + ) + + # Done; return the response. + return response + + async def update_issue_model(self, + request: Union[contact_center_insights.UpdateIssueModelRequest, dict] = None, + *, + issue_model: resources.IssueModel = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IssueModel: + r"""Updates an issue model. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest, dict]): + The request object. The request to update an issue + model. + issue_model (:class:`google.cloud.contact_center_insights_v1.types.IssueModel`): + Required. The new values for the + issue model. + + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.IssueModel: + The issue model resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue_model, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UpdateIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue_model is not None: + request.issue_model = issue_model + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_issue_model, + 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(( + ("issue_model.name", request.issue_model.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_issue_model(self, + request: Union[contact_center_insights.GetIssueModelRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IssueModel: + r"""Gets an issue model. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetIssueModelRequest, dict]): + The request object. The request to get an issue model. + name (:class:`str`): + Required. The name of the issue model + to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.IssueModel: + The issue model resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 = contact_center_insights.GetIssueModelRequest(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_issue_model, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_issue_models(self, + request: Union[contact_center_insights.ListIssueModelsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListIssueModelsResponse: + r"""Lists issue models. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest, dict]): + The request object. Request to list issue models. + parent (:class:`str`): + Required. The parent resource of the + issue model. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse: + The response of listing issue models. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ListIssueModelsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_issue_models, + 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 delete_issue_model(self, + request: Union[contact_center_insights.DeleteIssueModelRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes an issue model. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest, dict]): + The request object. The request to delete an issue + model. + name (:class:`str`): + Required. The name of the issue model + 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. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.DeleteIssueModelRequest(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_issue_model, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=contact_center_insights.DeleteIssueModelMetadata, + ) + + # Done; return the response. + return response + + async def deploy_issue_model(self, + request: Union[contact_center_insights.DeployIssueModelRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Deploys an issue model. Returns an error if a model + is already deployed. An issue model can only be used in + analysis after it has been deployed. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest, dict]): + The request object. The request to deploy an issue + model. + name (:class:`str`): + Required. The issue model to deploy. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.DeployIssueModelResponse` + The response to deploy an issue model. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 = contact_center_insights.DeployIssueModelRequest(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.deploy_issue_model, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.DeployIssueModelResponse, + metadata_type=contact_center_insights.DeployIssueModelMetadata, + ) + + # Done; return the response. + return response + + async def undeploy_issue_model(self, + request: Union[contact_center_insights.UndeployIssueModelRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Undeploys an issue model. + An issue model can not be used in analysis after it has + been undeployed. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest, dict]): + The request object. The request to undeploy an issue + model. + name (:class:`str`): + Required. The issue model to + undeploy. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.UndeployIssueModelResponse` + The response to undeploy an issue model. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 = contact_center_insights.UndeployIssueModelRequest(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.undeploy_issue_model, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.UndeployIssueModelResponse, + metadata_type=contact_center_insights.UndeployIssueModelMetadata, + ) + + # Done; return the response. + return response + + async def get_issue(self, + request: Union[contact_center_insights.GetIssueRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Issue: + r"""Gets an issue. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetIssueRequest, dict]): + The request object. The request to get an issue. + name (:class:`str`): + Required. The name of the issue to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Issue: + The issue resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 = contact_center_insights.GetIssueRequest(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_issue, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_issues(self, + request: Union[contact_center_insights.ListIssuesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListIssuesResponse: + r"""Lists issues. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListIssuesRequest, dict]): + The request object. Request to list issues. + parent (:class:`str`): + Required. The parent resource of the + issue. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.ListIssuesResponse: + The response of listing issues. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ListIssuesRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_issues, + 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_issue(self, + request: Union[contact_center_insights.UpdateIssueRequest, dict] = None, + *, + issue: resources.Issue = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Issue: + r"""Updates an issue. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateIssueRequest, dict]): + The request object. The request to update an issue. + issue (:class:`google.cloud.contact_center_insights_v1.types.Issue`): + Required. The new values for the + issue. + + This corresponds to the ``issue`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Issue: + The issue resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UpdateIssueRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue is not None: + request.issue = issue + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_issue, + 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(( + ("issue.name", request.issue.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def calculate_issue_model_stats(self, + request: Union[contact_center_insights.CalculateIssueModelStatsRequest, dict] = None, + *, + issue_model: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.CalculateIssueModelStatsResponse: + r"""Gets an issue model's statistics. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest, dict]): + The request object. Request to get statistics of an + issue model. + issue_model (:class:`str`): + Required. The resource name of the + issue model to query against. + + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse: + Response of querying an issue model's + statistics. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue_model]) + if request is 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 = contact_center_insights.CalculateIssueModelStatsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue_model is not None: + request.issue_model = issue_model + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.calculate_issue_model_stats, + 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(( + ("issue_model", request.issue_model), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_phrase_matcher(self, + request: Union[contact_center_insights.CreatePhraseMatcherRequest, dict] = None, + *, + parent: str = None, + phrase_matcher: resources.PhraseMatcher = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Creates a phrase matcher. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest, dict]): + The request object. Request to create a phrase matcher. + parent (:class:`str`): + Required. The parent resource of the phrase matcher. + Required. The location to create a phrase matcher for. + Format: + ``projects//locations/`` or + ``projects//locations/`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + phrase_matcher (:class:`google.cloud.contact_center_insights_v1.types.PhraseMatcher`): + Required. The phrase matcher resource + to create. + + This corresponds to the ``phrase_matcher`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.PhraseMatcher: + The phrase matcher resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, phrase_matcher]) + if request is 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 = contact_center_insights.CreatePhraseMatcherRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if phrase_matcher is not None: + request.phrase_matcher = phrase_matcher + + # 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_phrase_matcher, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_phrase_matcher(self, + request: Union[contact_center_insights.GetPhraseMatcherRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Gets a phrase matcher. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest, dict]): + The request object. The request to get a a phrase + matcher. + name (:class:`str`): + Required. The name of the phrase + matcher to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.PhraseMatcher: + The phrase matcher resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 = contact_center_insights.GetPhraseMatcherRequest(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_phrase_matcher, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_phrase_matchers(self, + request: Union[contact_center_insights.ListPhraseMatchersRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPhraseMatchersAsyncPager: + r"""Lists phrase matchers. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest, dict]): + The request object. Request to list phrase matchers. + parent (:class:`str`): + Required. The parent resource of the + phrase matcher. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersAsyncPager: + The response of listing phrase + matchers. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ListPhraseMatchersRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_phrase_matchers, + 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.ListPhraseMatchersAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_phrase_matcher(self, + request: Union[contact_center_insights.DeletePhraseMatcherRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a phrase matcher. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest, dict]): + The request object. The request to delete a phrase + matcher. + name (:class:`str`): + Required. The name of the phrase + matcher 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 = contact_center_insights.DeletePhraseMatcherRequest(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_phrase_matcher, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def update_phrase_matcher(self, + request: Union[contact_center_insights.UpdatePhraseMatcherRequest, dict] = None, + *, + phrase_matcher: resources.PhraseMatcher = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Updates a phrase matcher. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest, dict]): + The request object. The request to update a phrase + matcher. + phrase_matcher (:class:`google.cloud.contact_center_insights_v1.types.PhraseMatcher`): + Required. The new values for the + phrase matcher. + + This corresponds to the ``phrase_matcher`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.PhraseMatcher: + The phrase matcher resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([phrase_matcher, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UpdatePhraseMatcherRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if phrase_matcher is not None: + request.phrase_matcher = phrase_matcher + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_phrase_matcher, + 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(( + ("phrase_matcher.name", request.phrase_matcher.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def calculate_stats(self, + request: Union[contact_center_insights.CalculateStatsRequest, dict] = None, + *, + location: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.CalculateStatsResponse: + r"""Gets conversation statistics. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CalculateStatsRequest, dict]): + The request object. The request for calculating + conversation statistics. + location (:class:`str`): + Required. The location of the + conversations. + + This corresponds to the ``location`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.CalculateStatsResponse: + The response for calculating + conversation statistics. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([location]) + if request is 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 = contact_center_insights.CalculateStatsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if location is not None: + request.location = location + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.calculate_stats, + 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(( + ("location", request.location), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_settings(self, + request: Union[contact_center_insights.GetSettingsRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Settings: + r"""Gets project-level settings. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetSettingsRequest, dict]): + The request object. The request to get project-level + settings. + name (:class:`str`): + Required. The name of the settings + resource to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Settings: + The settings resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 = contact_center_insights.GetSettingsRequest(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_settings, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_settings(self, + request: Union[contact_center_insights.UpdateSettingsRequest, dict] = None, + *, + settings: resources.Settings = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Settings: + r"""Updates project-level settings. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateSettingsRequest, dict]): + The request object. The request to update project-level + settings. + settings (:class:`google.cloud.contact_center_insights_v1.types.Settings`): + Required. The new settings values. + This corresponds to the ``settings`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be + updated. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Settings: + The settings resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([settings, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UpdateSettingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if settings is not None: + request.settings = settings + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_settings, + 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(( + ("settings.name", request.settings.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_view(self, + request: Union[contact_center_insights.CreateViewRequest, dict] = None, + *, + parent: str = None, + view: resources.View = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Creates a view. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateViewRequest, dict]): + The request object. The request to create a view. + parent (:class:`str`): + Required. The parent resource of the view. Required. The + location to create a view for. Format: + ``projects//locations/`` or + ``projects//locations/`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + view (:class:`google.cloud.contact_center_insights_v1.types.View`): + Required. The view resource to + create. + + This corresponds to the ``view`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, view]) + if request is 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 = contact_center_insights.CreateViewRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if view is not None: + request.view = view + + # 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_view, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_view(self, + request: Union[contact_center_insights.GetViewRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Gets a view. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetViewRequest, dict]): + The request object. The request to get a view. + name (:class:`str`): + Required. The name of the view to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 = contact_center_insights.GetViewRequest(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_view, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_views(self, + request: Union[contact_center_insights.ListViewsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListViewsAsyncPager: + r"""Lists views. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListViewsRequest, dict]): + The request object. The request to list views. + parent (:class:`str`): + Required. The parent resource of the + views. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsAsyncPager: + The response of listing views. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ListViewsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_views, + 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.ListViewsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_view(self, + request: Union[contact_center_insights.UpdateViewRequest, dict] = None, + *, + view: resources.View = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Updates a view. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateViewRequest, dict]): + The request object. The request to update a view. + view (:class:`google.cloud.contact_center_insights_v1.types.View`): + Required. The new view. + This corresponds to the ``view`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([view, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UpdateViewRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if view is not None: + request.view = view + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_view, + 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(( + ("view.name", request.view.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_view(self, + request: Union[contact_center_insights.DeleteViewRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a view. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteViewRequest, dict]): + The request object. The request to delete a view. + name (:class:`str`): + Required. The name of the view 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 = contact_center_insights.DeleteViewRequest(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_view, + 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 __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-contact-center-insights", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "ContactCenterInsightsAsyncClient", +) diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py new file mode 100644 index 0000000..bb3e6fc --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py @@ -0,0 +1,3151 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +import os +import re +from typing import Dict, Optional, Sequence, Tuple, Type, Union +import pkg_resources + +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.contact_center_insights_v1.services.contact_center_insights import pagers +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import ContactCenterInsightsGrpcTransport +from .transports.grpc_asyncio import ContactCenterInsightsGrpcAsyncIOTransport + + +class ContactCenterInsightsClientMeta(type): + """Metaclass for the ContactCenterInsights 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[ContactCenterInsightsTransport]] + _transport_registry["grpc"] = ContactCenterInsightsGrpcTransport + _transport_registry["grpc_asyncio"] = ContactCenterInsightsGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[ContactCenterInsightsTransport]: + """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 ContactCenterInsightsClient(metaclass=ContactCenterInsightsClientMeta): + """An API that lets users analyze and explore their business + conversation data. + """ + + @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 = "contactcenterinsights.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: + ContactCenterInsightsClient: 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: + ContactCenterInsightsClient: 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) -> ContactCenterInsightsTransport: + """Returns the transport used by the client instance. + + Returns: + ContactCenterInsightsTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def analysis_path(project: str,location: str,conversation: str,analysis: str,) -> str: + """Returns a fully-qualified analysis string.""" + return "projects/{project}/locations/{location}/conversations/{conversation}/analyses/{analysis}".format(project=project, location=location, conversation=conversation, analysis=analysis, ) + + @staticmethod + def parse_analysis_path(path: str) -> Dict[str,str]: + """Parses a analysis path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/conversations/(?P.+?)/analyses/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def conversation_path(project: str,location: str,conversation: str,) -> str: + """Returns a fully-qualified conversation string.""" + return "projects/{project}/locations/{location}/conversations/{conversation}".format(project=project, location=location, conversation=conversation, ) + + @staticmethod + def parse_conversation_path(path: str) -> Dict[str,str]: + """Parses a conversation path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/conversations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def issue_path(project: str,location: str,issue_model: str,issue: str,) -> str: + """Returns a fully-qualified issue string.""" + return "projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue}".format(project=project, location=location, issue_model=issue_model, issue=issue, ) + + @staticmethod + def parse_issue_path(path: str) -> Dict[str,str]: + """Parses a issue path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/issueModels/(?P.+?)/issues/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def issue_model_path(project: str,location: str,issue_model: str,) -> str: + """Returns a fully-qualified issue_model string.""" + return "projects/{project}/locations/{location}/issueModels/{issue_model}".format(project=project, location=location, issue_model=issue_model, ) + + @staticmethod + def parse_issue_model_path(path: str) -> Dict[str,str]: + """Parses a issue_model path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/issueModels/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def participant_path(project: str,conversation: str,participant: str,) -> str: + """Returns a fully-qualified participant string.""" + return "projects/{project}/conversations/{conversation}/participants/{participant}".format(project=project, conversation=conversation, participant=participant, ) + + @staticmethod + def parse_participant_path(path: str) -> Dict[str,str]: + """Parses a participant path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/conversations/(?P.+?)/participants/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def phrase_matcher_path(project: str,location: str,phrase_matcher: str,) -> str: + """Returns a fully-qualified phrase_matcher string.""" + return "projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher}".format(project=project, location=location, phrase_matcher=phrase_matcher, ) + + @staticmethod + def parse_phrase_matcher_path(path: str) -> Dict[str,str]: + """Parses a phrase_matcher path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/phraseMatchers/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def settings_path(project: str,location: str,) -> str: + """Returns a fully-qualified settings string.""" + return "projects/{project}/locations/{location}/settings".format(project=project, location=location, ) + + @staticmethod + def parse_settings_path(path: str) -> Dict[str,str]: + """Parses a settings path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/settings$", path) + return m.groupdict() if m else {} + + @staticmethod + def view_path(project: str,location: str,view: str,) -> str: + """Returns a fully-qualified view string.""" + return "projects/{project}/locations/{location}/views/{view}".format(project=project, location=location, view=view, ) + + @staticmethod + def parse_view_path(path: str) -> Dict[str,str]: + """Parses a view path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/views/(?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, ContactCenterInsightsTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the contact center insights 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, ContactCenterInsightsTransport]): 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. + if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ("true", "false"): + raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`") + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + + 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, ContactCenterInsightsTransport): + # transport is a ContactCenterInsightsTransport 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 create_conversation(self, + request: Union[contact_center_insights.CreateConversationRequest, dict] = None, + *, + parent: str = None, + conversation: resources.Conversation = None, + conversation_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Creates a conversation. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateConversationRequest, dict]): + The request object. Request to create a conversation. + parent (str): + Required. The parent resource of the + conversation. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + conversation (google.cloud.contact_center_insights_v1.types.Conversation): + Required. The conversation resource + to create. + + This corresponds to the ``conversation`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + conversation_id (str): + A unique ID for the new conversation. This ID will + become the final component of the conversation's + resource name. If no ID is specified, a server-generated + ID will be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid + characters are ``[a-z][0-9]-`` + + This corresponds to the ``conversation_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Conversation: + The conversation resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, conversation, conversation_id]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.CreateConversationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CreateConversationRequest): + request = contact_center_insights.CreateConversationRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if conversation is not None: + request.conversation = conversation + if conversation_id is not None: + request.conversation_id = conversation_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_conversation] + + # 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_conversation(self, + request: Union[contact_center_insights.UpdateConversationRequest, dict] = None, + *, + conversation: resources.Conversation = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Updates a conversation. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateConversationRequest, dict]): + The request object. The request to update a + conversation. + conversation (google.cloud.contact_center_insights_v1.types.Conversation): + Required. The new values for the + conversation. + + This corresponds to the ``conversation`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Conversation: + The conversation resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([conversation, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdateConversationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UpdateConversationRequest): + request = contact_center_insights.UpdateConversationRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if conversation is not None: + request.conversation = conversation + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_conversation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("conversation.name", request.conversation.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_conversation(self, + request: Union[contact_center_insights.GetConversationRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Gets a conversation. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetConversationRequest, dict]): + The request object. The request to get a conversation. + name (str): + Required. The name of the + conversation to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Conversation: + The conversation resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 contact_center_insights.GetConversationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetConversationRequest): + request = contact_center_insights.GetConversationRequest(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_conversation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_conversations(self, + request: Union[contact_center_insights.ListConversationsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListConversationsPager: + r"""Lists conversations. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListConversationsRequest, dict]): + The request object. Request to list conversations. + parent (str): + Required. The parent resource of the + conversation. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsPager: + The response of listing + conversations. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ListConversationsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ListConversationsRequest): + request = contact_center_insights.ListConversationsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_conversations] + + # 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.ListConversationsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_conversation(self, + request: Union[contact_center_insights.DeleteConversationRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a conversation. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteConversationRequest, dict]): + The request object. The request to delete a + conversation. + name (str): + Required. The name of the + conversation 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 contact_center_insights.DeleteConversationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeleteConversationRequest): + request = contact_center_insights.DeleteConversationRequest(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_conversation] + + # Certain fields should be 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 create_analysis(self, + request: Union[contact_center_insights.CreateAnalysisRequest, dict] = None, + *, + parent: str = None, + analysis: resources.Analysis = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates an analysis. The long running operation is + done when the analysis has completed. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest, dict]): + The request object. The request to create an analysis. + parent (str): + Required. The parent resource of the + analysis. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + analysis (google.cloud.contact_center_insights_v1.types.Analysis): + Required. The analysis to create. + This corresponds to the ``analysis`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.contact_center_insights_v1.types.Analysis` + The analysis resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, analysis]) + if request is 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 contact_center_insights.CreateAnalysisRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CreateAnalysisRequest): + request = contact_center_insights.CreateAnalysisRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if analysis is not None: + request.analysis = analysis + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_analysis] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + resources.Analysis, + metadata_type=contact_center_insights.CreateAnalysisOperationMetadata, + ) + + # Done; return the response. + return response + + def get_analysis(self, + request: Union[contact_center_insights.GetAnalysisRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Analysis: + r"""Gets an analysis. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetAnalysisRequest, dict]): + The request object. The request to get an analysis. + name (str): + Required. The name of the analysis to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Analysis: + The analysis resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 contact_center_insights.GetAnalysisRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetAnalysisRequest): + request = contact_center_insights.GetAnalysisRequest(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_analysis] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_analyses(self, + request: Union[contact_center_insights.ListAnalysesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAnalysesPager: + r"""Lists analyses. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListAnalysesRequest, dict]): + The request object. The request to list analyses. + parent (str): + Required. The parent resource of the + analyses. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesPager: + The response to list analyses. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ListAnalysesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ListAnalysesRequest): + request = contact_center_insights.ListAnalysesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_analyses] + + # 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.ListAnalysesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_analysis(self, + request: Union[contact_center_insights.DeleteAnalysisRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an analysis. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest, dict]): + The request object. The request to delete an analysis. + name (str): + Required. The name of the analysis 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 contact_center_insights.DeleteAnalysisRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeleteAnalysisRequest): + request = contact_center_insights.DeleteAnalysisRequest(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_analysis] + + # Certain fields should be 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 export_insights_data(self, + request: Union[contact_center_insights.ExportInsightsDataRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Export insights data to a destination defined in the + request body. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest, dict]): + The request object. The request to export insights. + parent (str): + Required. The parent resource to + export data from. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.ExportInsightsDataResponse` + Response for an export insights operation. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ExportInsightsDataRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ExportInsightsDataRequest): + request = contact_center_insights.ExportInsightsDataRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.export_insights_data] + + # 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, + contact_center_insights.ExportInsightsDataResponse, + metadata_type=contact_center_insights.ExportInsightsDataMetadata, + ) + + # Done; return the response. + return response + + def create_issue_model(self, + request: Union[contact_center_insights.CreateIssueModelRequest, dict] = None, + *, + parent: str = None, + issue_model: resources.IssueModel = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates an issue model. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest, dict]): + The request object. The request to create an issue + model. + parent (str): + Required. The parent resource of the + issue model. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): + Required. The issue model to create. + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (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.contact_center_insights_v1.types.IssueModel` + The issue model resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, issue_model]) + if request is 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 contact_center_insights.CreateIssueModelRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CreateIssueModelRequest): + request = contact_center_insights.CreateIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if issue_model is not None: + request.issue_model = issue_model + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + resources.IssueModel, + metadata_type=contact_center_insights.CreateIssueModelMetadata, + ) + + # Done; return the response. + return response + + def update_issue_model(self, + request: Union[contact_center_insights.UpdateIssueModelRequest, dict] = None, + *, + issue_model: resources.IssueModel = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IssueModel: + r"""Updates an issue model. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest, dict]): + The request object. The request to update an issue + model. + issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): + Required. The new values for the + issue model. + + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.IssueModel: + The issue model resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue_model, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdateIssueModelRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UpdateIssueModelRequest): + request = contact_center_insights.UpdateIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue_model is not None: + request.issue_model = issue_model + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("issue_model.name", request.issue_model.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_issue_model(self, + request: Union[contact_center_insights.GetIssueModelRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IssueModel: + r"""Gets an issue model. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetIssueModelRequest, dict]): + The request object. The request to get an issue model. + name (str): + Required. The name of the issue model + to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.IssueModel: + The issue model resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 contact_center_insights.GetIssueModelRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetIssueModelRequest): + request = contact_center_insights.GetIssueModelRequest(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_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_issue_models(self, + request: Union[contact_center_insights.ListIssueModelsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListIssueModelsResponse: + r"""Lists issue models. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest, dict]): + The request object. Request to list issue models. + parent (str): + Required. The parent resource of the + issue model. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse: + The response of listing issue models. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ListIssueModelsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ListIssueModelsRequest): + request = contact_center_insights.ListIssueModelsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_issue_models] + + # 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 delete_issue_model(self, + request: Union[contact_center_insights.DeleteIssueModelRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Deletes an issue model. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest, dict]): + The request object. The request to delete an issue + model. + name (str): + Required. The name of the issue model + 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. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.DeleteIssueModelRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeleteIssueModelRequest): + request = contact_center_insights.DeleteIssueModelRequest(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_issue_model] + + # Certain fields should be provided 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=contact_center_insights.DeleteIssueModelMetadata, + ) + + # Done; return the response. + return response + + def deploy_issue_model(self, + request: Union[contact_center_insights.DeployIssueModelRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Deploys an issue model. Returns an error if a model + is already deployed. An issue model can only be used in + analysis after it has been deployed. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest, dict]): + The request object. The request to deploy an issue + model. + name (str): + Required. The issue model to deploy. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.DeployIssueModelResponse` + The response to deploy an issue model. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 contact_center_insights.DeployIssueModelRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeployIssueModelRequest): + request = contact_center_insights.DeployIssueModelRequest(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.deploy_issue_model] + + # Certain fields should be provided 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, + contact_center_insights.DeployIssueModelResponse, + metadata_type=contact_center_insights.DeployIssueModelMetadata, + ) + + # Done; return the response. + return response + + def undeploy_issue_model(self, + request: Union[contact_center_insights.UndeployIssueModelRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Undeploys an issue model. + An issue model can not be used in analysis after it has + been undeployed. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest, dict]): + The request object. The request to undeploy an issue + model. + name (str): + Required. The issue model to + undeploy. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.UndeployIssueModelResponse` + The response to undeploy an issue model. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 contact_center_insights.UndeployIssueModelRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UndeployIssueModelRequest): + request = contact_center_insights.UndeployIssueModelRequest(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.undeploy_issue_model] + + # Certain fields should be provided 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, + contact_center_insights.UndeployIssueModelResponse, + metadata_type=contact_center_insights.UndeployIssueModelMetadata, + ) + + # Done; return the response. + return response + + def get_issue(self, + request: Union[contact_center_insights.GetIssueRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Issue: + r"""Gets an issue. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetIssueRequest, dict]): + The request object. The request to get an issue. + name (str): + Required. The name of the issue to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Issue: + The issue resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 contact_center_insights.GetIssueRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetIssueRequest): + request = contact_center_insights.GetIssueRequest(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_issue] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_issues(self, + request: Union[contact_center_insights.ListIssuesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListIssuesResponse: + r"""Lists issues. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListIssuesRequest, dict]): + The request object. Request to list issues. + parent (str): + Required. The parent resource of the + issue. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.ListIssuesResponse: + The response of listing issues. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ListIssuesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ListIssuesRequest): + request = contact_center_insights.ListIssuesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_issues] + + # 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_issue(self, + request: Union[contact_center_insights.UpdateIssueRequest, dict] = None, + *, + issue: resources.Issue = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Issue: + r"""Updates an issue. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateIssueRequest, dict]): + The request object. The request to update an issue. + issue (google.cloud.contact_center_insights_v1.types.Issue): + Required. The new values for the + issue. + + This corresponds to the ``issue`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Issue: + The issue resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdateIssueRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UpdateIssueRequest): + request = contact_center_insights.UpdateIssueRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue is not None: + request.issue = issue + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_issue] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("issue.name", request.issue.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def calculate_issue_model_stats(self, + request: Union[contact_center_insights.CalculateIssueModelStatsRequest, dict] = None, + *, + issue_model: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.CalculateIssueModelStatsResponse: + r"""Gets an issue model's statistics. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest, dict]): + The request object. Request to get statistics of an + issue model. + issue_model (str): + Required. The resource name of the + issue model to query against. + + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse: + Response of querying an issue model's + statistics. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue_model]) + if request is 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 contact_center_insights.CalculateIssueModelStatsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CalculateIssueModelStatsRequest): + request = contact_center_insights.CalculateIssueModelStatsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue_model is not None: + request.issue_model = issue_model + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.calculate_issue_model_stats] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("issue_model", request.issue_model), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_phrase_matcher(self, + request: Union[contact_center_insights.CreatePhraseMatcherRequest, dict] = None, + *, + parent: str = None, + phrase_matcher: resources.PhraseMatcher = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Creates a phrase matcher. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest, dict]): + The request object. Request to create a phrase matcher. + parent (str): + Required. The parent resource of the phrase matcher. + Required. The location to create a phrase matcher for. + Format: + ``projects//locations/`` or + ``projects//locations/`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher): + Required. The phrase matcher resource + to create. + + This corresponds to the ``phrase_matcher`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.PhraseMatcher: + The phrase matcher resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, phrase_matcher]) + if request is 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 contact_center_insights.CreatePhraseMatcherRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CreatePhraseMatcherRequest): + request = contact_center_insights.CreatePhraseMatcherRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if phrase_matcher is not None: + request.phrase_matcher = phrase_matcher + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_phrase_matcher] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_phrase_matcher(self, + request: Union[contact_center_insights.GetPhraseMatcherRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Gets a phrase matcher. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest, dict]): + The request object. The request to get a a phrase + matcher. + name (str): + Required. The name of the phrase + matcher to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.PhraseMatcher: + The phrase matcher resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 contact_center_insights.GetPhraseMatcherRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetPhraseMatcherRequest): + request = contact_center_insights.GetPhraseMatcherRequest(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_phrase_matcher] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_phrase_matchers(self, + request: Union[contact_center_insights.ListPhraseMatchersRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPhraseMatchersPager: + r"""Lists phrase matchers. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest, dict]): + The request object. Request to list phrase matchers. + parent (str): + Required. The parent resource of the + phrase matcher. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersPager: + The response of listing phrase + matchers. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ListPhraseMatchersRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ListPhraseMatchersRequest): + request = contact_center_insights.ListPhraseMatchersRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_phrase_matchers] + + # 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.ListPhraseMatchersPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_phrase_matcher(self, + request: Union[contact_center_insights.DeletePhraseMatcherRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a phrase matcher. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest, dict]): + The request object. The request to delete a phrase + matcher. + name (str): + Required. The name of the phrase + matcher 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 contact_center_insights.DeletePhraseMatcherRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeletePhraseMatcherRequest): + request = contact_center_insights.DeletePhraseMatcherRequest(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_phrase_matcher] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def update_phrase_matcher(self, + request: Union[contact_center_insights.UpdatePhraseMatcherRequest, dict] = None, + *, + phrase_matcher: resources.PhraseMatcher = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Updates a phrase matcher. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest, dict]): + The request object. The request to update a phrase + matcher. + phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher): + Required. The new values for the + phrase matcher. + + This corresponds to the ``phrase_matcher`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.PhraseMatcher: + The phrase matcher resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([phrase_matcher, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdatePhraseMatcherRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UpdatePhraseMatcherRequest): + request = contact_center_insights.UpdatePhraseMatcherRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if phrase_matcher is not None: + request.phrase_matcher = phrase_matcher + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_phrase_matcher] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("phrase_matcher.name", request.phrase_matcher.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def calculate_stats(self, + request: Union[contact_center_insights.CalculateStatsRequest, dict] = None, + *, + location: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.CalculateStatsResponse: + r"""Gets conversation statistics. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CalculateStatsRequest, dict]): + The request object. The request for calculating + conversation statistics. + location (str): + Required. The location of the + conversations. + + This corresponds to the ``location`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.CalculateStatsResponse: + The response for calculating + conversation statistics. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([location]) + if request is 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 contact_center_insights.CalculateStatsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CalculateStatsRequest): + request = contact_center_insights.CalculateStatsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if location is not None: + request.location = location + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.calculate_stats] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("location", request.location), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_settings(self, + request: Union[contact_center_insights.GetSettingsRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Settings: + r"""Gets project-level settings. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetSettingsRequest, dict]): + The request object. The request to get project-level + settings. + name (str): + Required. The name of the settings + resource to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Settings: + The settings resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 contact_center_insights.GetSettingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetSettingsRequest): + request = contact_center_insights.GetSettingsRequest(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_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, + ) + + # Done; return the response. + return response + + def update_settings(self, + request: Union[contact_center_insights.UpdateSettingsRequest, dict] = None, + *, + settings: resources.Settings = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Settings: + r"""Updates project-level settings. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateSettingsRequest, dict]): + The request object. The request to update project-level + settings. + settings (google.cloud.contact_center_insights_v1.types.Settings): + Required. The new settings values. + This corresponds to the ``settings`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be + updated. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Settings: + The settings resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([settings, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdateSettingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UpdateSettingsRequest): + request = contact_center_insights.UpdateSettingsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if settings is not None: + request.settings = settings + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_settings] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("settings.name", request.settings.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_view(self, + request: Union[contact_center_insights.CreateViewRequest, dict] = None, + *, + parent: str = None, + view: resources.View = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Creates a view. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateViewRequest, dict]): + The request object. The request to create a view. + parent (str): + Required. The parent resource of the view. Required. The + location to create a view for. Format: + ``projects//locations/`` or + ``projects//locations/`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + view (google.cloud.contact_center_insights_v1.types.View): + Required. The view resource to + create. + + This corresponds to the ``view`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, view]) + if request is 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 contact_center_insights.CreateViewRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CreateViewRequest): + request = contact_center_insights.CreateViewRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if view is not None: + request.view = view + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_view] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_view(self, + request: Union[contact_center_insights.GetViewRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Gets a view. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetViewRequest, dict]): + The request object. The request to get a view. + name (str): + Required. The name of the view to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # Sanity 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 contact_center_insights.GetViewRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetViewRequest): + request = contact_center_insights.GetViewRequest(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_view] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_views(self, + request: Union[contact_center_insights.ListViewsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListViewsPager: + r"""Lists views. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListViewsRequest, dict]): + The request object. The request to list views. + parent (str): + Required. The parent resource of the + views. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsPager: + The response of listing views. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ListViewsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ListViewsRequest): + request = contact_center_insights.ListViewsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_views] + + # 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.ListViewsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_view(self, + request: Union[contact_center_insights.UpdateViewRequest, dict] = None, + *, + view: resources.View = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Updates a view. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateViewRequest, dict]): + The request object. The request to update a view. + view (google.cloud.contact_center_insights_v1.types.View): + Required. The new view. + This corresponds to the ``view`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([view, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdateViewRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UpdateViewRequest): + request = contact_center_insights.UpdateViewRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if view is not None: + request.view = view + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_view] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("view.name", request.view.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_view(self, + request: Union[contact_center_insights.DeleteViewRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a view. + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteViewRequest, dict]): + The request object. The request to delete a view. + name (str): + Required. The name of the view 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 contact_center_insights.DeleteViewRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeleteViewRequest): + request = contact_center_insights.DeleteViewRequest(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_view] + + # Certain fields should be 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 __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-contact-center-insights", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "ContactCenterInsightsClient", +) diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py new file mode 100644 index 0000000..b3195b1 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.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. +# +from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator + +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources + + +class ListConversationsPager: + """A pager for iterating through ``list_conversations`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListConversationsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``conversations`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListConversations`` requests and continue to iterate + through the ``conversations`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListConversationsResponse` + 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[..., contact_center_insights.ListConversationsResponse], + request: contact_center_insights.ListConversationsRequest, + response: contact_center_insights.ListConversationsResponse, + *, + 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.contact_center_insights_v1.types.ListConversationsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListConversationsResponse): + 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 = contact_center_insights.ListConversationsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListConversationsResponse]: + 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[resources.Conversation]: + for page in self.pages: + yield from page.conversations + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListConversationsAsyncPager: + """A pager for iterating through ``list_conversations`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListConversationsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``conversations`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListConversations`` requests and continue to iterate + through the ``conversations`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListConversationsResponse` + 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[contact_center_insights.ListConversationsResponse]], + request: contact_center_insights.ListConversationsRequest, + response: contact_center_insights.ListConversationsResponse, + *, + 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.contact_center_insights_v1.types.ListConversationsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListConversationsResponse): + 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 = contact_center_insights.ListConversationsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[contact_center_insights.ListConversationsResponse]: + 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[resources.Conversation]: + async def async_generator(): + async for page in self.pages: + for response in page.conversations: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListAnalysesPager: + """A pager for iterating through ``list_analyses`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListAnalysesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``analyses`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListAnalyses`` requests and continue to iterate + through the ``analyses`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListAnalysesResponse` + 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[..., contact_center_insights.ListAnalysesResponse], + request: contact_center_insights.ListAnalysesRequest, + response: contact_center_insights.ListAnalysesResponse, + *, + 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.contact_center_insights_v1.types.ListAnalysesRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListAnalysesResponse): + 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 = contact_center_insights.ListAnalysesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListAnalysesResponse]: + 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[resources.Analysis]: + for page in self.pages: + yield from page.analyses + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListAnalysesAsyncPager: + """A pager for iterating through ``list_analyses`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListAnalysesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``analyses`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListAnalyses`` requests and continue to iterate + through the ``analyses`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListAnalysesResponse` + 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[contact_center_insights.ListAnalysesResponse]], + request: contact_center_insights.ListAnalysesRequest, + response: contact_center_insights.ListAnalysesResponse, + *, + 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.contact_center_insights_v1.types.ListAnalysesRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListAnalysesResponse): + 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 = contact_center_insights.ListAnalysesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[contact_center_insights.ListAnalysesResponse]: + 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[resources.Analysis]: + async def async_generator(): + async for page in self.pages: + for response in page.analyses: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListPhraseMatchersPager: + """A pager for iterating through ``list_phrase_matchers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse` object, and + provides an ``__iter__`` method to iterate through its + ``phrase_matchers`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListPhraseMatchers`` requests and continue to iterate + through the ``phrase_matchers`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse` + 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[..., contact_center_insights.ListPhraseMatchersResponse], + request: contact_center_insights.ListPhraseMatchersRequest, + response: contact_center_insights.ListPhraseMatchersResponse, + *, + 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.contact_center_insights_v1.types.ListPhraseMatchersRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse): + 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 = contact_center_insights.ListPhraseMatchersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListPhraseMatchersResponse]: + 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[resources.PhraseMatcher]: + for page in self.pages: + yield from page.phrase_matchers + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListPhraseMatchersAsyncPager: + """A pager for iterating through ``list_phrase_matchers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``phrase_matchers`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListPhraseMatchers`` requests and continue to iterate + through the ``phrase_matchers`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse` + 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[contact_center_insights.ListPhraseMatchersResponse]], + request: contact_center_insights.ListPhraseMatchersRequest, + response: contact_center_insights.ListPhraseMatchersResponse, + *, + 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.contact_center_insights_v1.types.ListPhraseMatchersRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse): + 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 = contact_center_insights.ListPhraseMatchersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[contact_center_insights.ListPhraseMatchersResponse]: + 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[resources.PhraseMatcher]: + async def async_generator(): + async for page in self.pages: + for response in page.phrase_matchers: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListViewsPager: + """A pager for iterating through ``list_views`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListViewsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``views`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListViews`` requests and continue to iterate + through the ``views`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListViewsResponse` + 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[..., contact_center_insights.ListViewsResponse], + request: contact_center_insights.ListViewsRequest, + response: contact_center_insights.ListViewsResponse, + *, + 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.contact_center_insights_v1.types.ListViewsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListViewsResponse): + 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 = contact_center_insights.ListViewsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListViewsResponse]: + 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[resources.View]: + for page in self.pages: + yield from page.views + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListViewsAsyncPager: + """A pager for iterating through ``list_views`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListViewsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``views`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListViews`` requests and continue to iterate + through the ``views`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListViewsResponse` + 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[contact_center_insights.ListViewsResponse]], + request: contact_center_insights.ListViewsRequest, + response: contact_center_insights.ListViewsResponse, + *, + 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.contact_center_insights_v1.types.ListViewsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListViewsResponse): + 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 = contact_center_insights.ListViewsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[contact_center_insights.ListViewsResponse]: + 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[resources.View]: + async def async_generator(): + async for page in self.pages: + for response in page.views: + 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/contact_center_insights_v1/services/contact_center_insights/transports/__init__.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/__init__.py new file mode 100644 index 0000000..43613f9 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/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 ContactCenterInsightsTransport +from .grpc import ContactCenterInsightsGrpcTransport +from .grpc_asyncio import ContactCenterInsightsGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[ContactCenterInsightsTransport]] +_transport_registry['grpc'] = ContactCenterInsightsGrpcTransport +_transport_registry['grpc_asyncio'] = ContactCenterInsightsGrpcAsyncIOTransport + +__all__ = ( + 'ContactCenterInsightsTransport', + 'ContactCenterInsightsGrpcTransport', + 'ContactCenterInsightsGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py new file mode 100644 index 0000000..f4b5c91 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py @@ -0,0 +1,616 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 pkg_resources + +import google.auth # type: ignore +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +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-contact-center-insights', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +class ContactCenterInsightsTransport(abc.ABC): + """Abstract transport class for ContactCenterInsights.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'contactcenterinsights.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 = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} + + # Save the scopes. + self._scopes = scopes + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + + if credentials_file is not None: + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, + **scopes_kwargs, + quota_project_id=quota_project_id + ) + elif credentials is None: + credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + + # 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 + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.create_conversation: gapic_v1.method.wrap_method( + self.create_conversation, + default_timeout=None, + client_info=client_info, + ), + self.update_conversation: gapic_v1.method.wrap_method( + self.update_conversation, + default_timeout=None, + client_info=client_info, + ), + self.get_conversation: gapic_v1.method.wrap_method( + self.get_conversation, + default_timeout=None, + client_info=client_info, + ), + self.list_conversations: gapic_v1.method.wrap_method( + self.list_conversations, + default_timeout=None, + client_info=client_info, + ), + self.delete_conversation: gapic_v1.method.wrap_method( + self.delete_conversation, + default_timeout=None, + client_info=client_info, + ), + self.create_analysis: gapic_v1.method.wrap_method( + self.create_analysis, + default_timeout=None, + client_info=client_info, + ), + self.get_analysis: gapic_v1.method.wrap_method( + self.get_analysis, + default_timeout=None, + client_info=client_info, + ), + self.list_analyses: gapic_v1.method.wrap_method( + self.list_analyses, + default_timeout=None, + client_info=client_info, + ), + self.delete_analysis: gapic_v1.method.wrap_method( + self.delete_analysis, + default_timeout=None, + client_info=client_info, + ), + self.export_insights_data: gapic_v1.method.wrap_method( + self.export_insights_data, + default_timeout=None, + client_info=client_info, + ), + self.create_issue_model: gapic_v1.method.wrap_method( + self.create_issue_model, + default_timeout=None, + client_info=client_info, + ), + self.update_issue_model: gapic_v1.method.wrap_method( + self.update_issue_model, + default_timeout=None, + client_info=client_info, + ), + self.get_issue_model: gapic_v1.method.wrap_method( + self.get_issue_model, + default_timeout=None, + client_info=client_info, + ), + self.list_issue_models: gapic_v1.method.wrap_method( + self.list_issue_models, + default_timeout=None, + client_info=client_info, + ), + self.delete_issue_model: gapic_v1.method.wrap_method( + self.delete_issue_model, + default_timeout=None, + client_info=client_info, + ), + self.deploy_issue_model: gapic_v1.method.wrap_method( + self.deploy_issue_model, + default_timeout=None, + client_info=client_info, + ), + self.undeploy_issue_model: gapic_v1.method.wrap_method( + self.undeploy_issue_model, + default_timeout=None, + client_info=client_info, + ), + self.get_issue: gapic_v1.method.wrap_method( + self.get_issue, + default_timeout=None, + client_info=client_info, + ), + self.list_issues: gapic_v1.method.wrap_method( + self.list_issues, + default_timeout=None, + client_info=client_info, + ), + self.update_issue: gapic_v1.method.wrap_method( + self.update_issue, + default_timeout=None, + client_info=client_info, + ), + self.calculate_issue_model_stats: gapic_v1.method.wrap_method( + self.calculate_issue_model_stats, + default_timeout=None, + client_info=client_info, + ), + self.create_phrase_matcher: gapic_v1.method.wrap_method( + self.create_phrase_matcher, + default_timeout=None, + client_info=client_info, + ), + self.get_phrase_matcher: gapic_v1.method.wrap_method( + self.get_phrase_matcher, + default_timeout=None, + client_info=client_info, + ), + self.list_phrase_matchers: gapic_v1.method.wrap_method( + self.list_phrase_matchers, + default_timeout=None, + client_info=client_info, + ), + self.delete_phrase_matcher: gapic_v1.method.wrap_method( + self.delete_phrase_matcher, + default_timeout=None, + client_info=client_info, + ), + self.update_phrase_matcher: gapic_v1.method.wrap_method( + self.update_phrase_matcher, + default_timeout=None, + client_info=client_info, + ), + self.calculate_stats: gapic_v1.method.wrap_method( + self.calculate_stats, + default_timeout=None, + client_info=client_info, + ), + self.get_settings: gapic_v1.method.wrap_method( + self.get_settings, + default_timeout=None, + client_info=client_info, + ), + self.update_settings: gapic_v1.method.wrap_method( + self.update_settings, + default_timeout=None, + client_info=client_info, + ), + self.create_view: gapic_v1.method.wrap_method( + self.create_view, + default_timeout=None, + client_info=client_info, + ), + self.get_view: gapic_v1.method.wrap_method( + self.get_view, + default_timeout=None, + client_info=client_info, + ), + self.list_views: gapic_v1.method.wrap_method( + self.list_views, + default_timeout=None, + client_info=client_info, + ), + self.update_view: gapic_v1.method.wrap_method( + self.update_view, + default_timeout=None, + client_info=client_info, + ), + self.delete_view: gapic_v1.method.wrap_method( + self.delete_view, + 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): + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def create_conversation(self) -> Callable[ + [contact_center_insights.CreateConversationRequest], + Union[ + resources.Conversation, + Awaitable[resources.Conversation] + ]]: + raise NotImplementedError() + + @property + def update_conversation(self) -> Callable[ + [contact_center_insights.UpdateConversationRequest], + Union[ + resources.Conversation, + Awaitable[resources.Conversation] + ]]: + raise NotImplementedError() + + @property + def get_conversation(self) -> Callable[ + [contact_center_insights.GetConversationRequest], + Union[ + resources.Conversation, + Awaitable[resources.Conversation] + ]]: + raise NotImplementedError() + + @property + def list_conversations(self) -> Callable[ + [contact_center_insights.ListConversationsRequest], + Union[ + contact_center_insights.ListConversationsResponse, + Awaitable[contact_center_insights.ListConversationsResponse] + ]]: + raise NotImplementedError() + + @property + def delete_conversation(self) -> Callable[ + [contact_center_insights.DeleteConversationRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def create_analysis(self) -> Callable[ + [contact_center_insights.CreateAnalysisRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_analysis(self) -> Callable[ + [contact_center_insights.GetAnalysisRequest], + Union[ + resources.Analysis, + Awaitable[resources.Analysis] + ]]: + raise NotImplementedError() + + @property + def list_analyses(self) -> Callable[ + [contact_center_insights.ListAnalysesRequest], + Union[ + contact_center_insights.ListAnalysesResponse, + Awaitable[contact_center_insights.ListAnalysesResponse] + ]]: + raise NotImplementedError() + + @property + def delete_analysis(self) -> Callable[ + [contact_center_insights.DeleteAnalysisRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def export_insights_data(self) -> Callable[ + [contact_center_insights.ExportInsightsDataRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_issue_model(self) -> Callable[ + [contact_center_insights.CreateIssueModelRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_issue_model(self) -> Callable[ + [contact_center_insights.UpdateIssueModelRequest], + Union[ + resources.IssueModel, + Awaitable[resources.IssueModel] + ]]: + raise NotImplementedError() + + @property + def get_issue_model(self) -> Callable[ + [contact_center_insights.GetIssueModelRequest], + Union[ + resources.IssueModel, + Awaitable[resources.IssueModel] + ]]: + raise NotImplementedError() + + @property + def list_issue_models(self) -> Callable[ + [contact_center_insights.ListIssueModelsRequest], + Union[ + contact_center_insights.ListIssueModelsResponse, + Awaitable[contact_center_insights.ListIssueModelsResponse] + ]]: + raise NotImplementedError() + + @property + def delete_issue_model(self) -> Callable[ + [contact_center_insights.DeleteIssueModelRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def deploy_issue_model(self) -> Callable[ + [contact_center_insights.DeployIssueModelRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def undeploy_issue_model(self) -> Callable[ + [contact_center_insights.UndeployIssueModelRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_issue(self) -> Callable[ + [contact_center_insights.GetIssueRequest], + Union[ + resources.Issue, + Awaitable[resources.Issue] + ]]: + raise NotImplementedError() + + @property + def list_issues(self) -> Callable[ + [contact_center_insights.ListIssuesRequest], + Union[ + contact_center_insights.ListIssuesResponse, + Awaitable[contact_center_insights.ListIssuesResponse] + ]]: + raise NotImplementedError() + + @property + def update_issue(self) -> Callable[ + [contact_center_insights.UpdateIssueRequest], + Union[ + resources.Issue, + Awaitable[resources.Issue] + ]]: + raise NotImplementedError() + + @property + def calculate_issue_model_stats(self) -> Callable[ + [contact_center_insights.CalculateIssueModelStatsRequest], + Union[ + contact_center_insights.CalculateIssueModelStatsResponse, + Awaitable[contact_center_insights.CalculateIssueModelStatsResponse] + ]]: + raise NotImplementedError() + + @property + def create_phrase_matcher(self) -> Callable[ + [contact_center_insights.CreatePhraseMatcherRequest], + Union[ + resources.PhraseMatcher, + Awaitable[resources.PhraseMatcher] + ]]: + raise NotImplementedError() + + @property + def get_phrase_matcher(self) -> Callable[ + [contact_center_insights.GetPhraseMatcherRequest], + Union[ + resources.PhraseMatcher, + Awaitable[resources.PhraseMatcher] + ]]: + raise NotImplementedError() + + @property + def list_phrase_matchers(self) -> Callable[ + [contact_center_insights.ListPhraseMatchersRequest], + Union[ + contact_center_insights.ListPhraseMatchersResponse, + Awaitable[contact_center_insights.ListPhraseMatchersResponse] + ]]: + raise NotImplementedError() + + @property + def delete_phrase_matcher(self) -> Callable[ + [contact_center_insights.DeletePhraseMatcherRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def update_phrase_matcher(self) -> Callable[ + [contact_center_insights.UpdatePhraseMatcherRequest], + Union[ + resources.PhraseMatcher, + Awaitable[resources.PhraseMatcher] + ]]: + raise NotImplementedError() + + @property + def calculate_stats(self) -> Callable[ + [contact_center_insights.CalculateStatsRequest], + Union[ + contact_center_insights.CalculateStatsResponse, + Awaitable[contact_center_insights.CalculateStatsResponse] + ]]: + raise NotImplementedError() + + @property + def get_settings(self) -> Callable[ + [contact_center_insights.GetSettingsRequest], + Union[ + resources.Settings, + Awaitable[resources.Settings] + ]]: + raise NotImplementedError() + + @property + def update_settings(self) -> Callable[ + [contact_center_insights.UpdateSettingsRequest], + Union[ + resources.Settings, + Awaitable[resources.Settings] + ]]: + raise NotImplementedError() + + @property + def create_view(self) -> Callable[ + [contact_center_insights.CreateViewRequest], + Union[ + resources.View, + Awaitable[resources.View] + ]]: + raise NotImplementedError() + + @property + def get_view(self) -> Callable[ + [contact_center_insights.GetViewRequest], + Union[ + resources.View, + Awaitable[resources.View] + ]]: + raise NotImplementedError() + + @property + def list_views(self) -> Callable[ + [contact_center_insights.ListViewsRequest], + Union[ + contact_center_insights.ListViewsResponse, + Awaitable[contact_center_insights.ListViewsResponse] + ]]: + raise NotImplementedError() + + @property + def update_view(self) -> Callable[ + [contact_center_insights.UpdateViewRequest], + Union[ + resources.View, + Awaitable[resources.View] + ]]: + raise NotImplementedError() + + @property + def delete_view(self) -> Callable[ + [contact_center_insights.DeleteViewRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + +__all__ = ( + 'ContactCenterInsightsTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py new file mode 100644 index 0000000..b605bac --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py @@ -0,0 +1,1140 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import operations_v1 +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from .base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO + + +class ContactCenterInsightsGrpcTransport(ContactCenterInsightsTransport): + """gRPC backend transport for ContactCenterInsights. + + An API that lets users analyze and explore their business + conversation data. + + 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 = 'contactcenterinsights.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: Optional[operations_v1.OperationsClient] = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + ) + + 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 = 'contactcenterinsights.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 create_conversation(self) -> Callable[ + [contact_center_insights.CreateConversationRequest], + resources.Conversation]: + r"""Return a callable for the create conversation method over gRPC. + + Creates a conversation. + + Returns: + Callable[[~.CreateConversationRequest], + ~.Conversation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversation' not in self._stubs: + self._stubs['create_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateConversation', + request_serializer=contact_center_insights.CreateConversationRequest.serialize, + response_deserializer=resources.Conversation.deserialize, + ) + return self._stubs['create_conversation'] + + @property + def update_conversation(self) -> Callable[ + [contact_center_insights.UpdateConversationRequest], + resources.Conversation]: + r"""Return a callable for the update conversation method over gRPC. + + Updates a conversation. + + Returns: + Callable[[~.UpdateConversationRequest], + ~.Conversation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversation' not in self._stubs: + self._stubs['update_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateConversation', + request_serializer=contact_center_insights.UpdateConversationRequest.serialize, + response_deserializer=resources.Conversation.deserialize, + ) + return self._stubs['update_conversation'] + + @property + def get_conversation(self) -> Callable[ + [contact_center_insights.GetConversationRequest], + resources.Conversation]: + r"""Return a callable for the get conversation method over gRPC. + + Gets a conversation. + + Returns: + Callable[[~.GetConversationRequest], + ~.Conversation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversation' not in self._stubs: + self._stubs['get_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetConversation', + request_serializer=contact_center_insights.GetConversationRequest.serialize, + response_deserializer=resources.Conversation.deserialize, + ) + return self._stubs['get_conversation'] + + @property + def list_conversations(self) -> Callable[ + [contact_center_insights.ListConversationsRequest], + contact_center_insights.ListConversationsResponse]: + r"""Return a callable for the list conversations method over gRPC. + + Lists conversations. + + Returns: + Callable[[~.ListConversationsRequest], + ~.ListConversationsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversations' not in self._stubs: + self._stubs['list_conversations'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListConversations', + request_serializer=contact_center_insights.ListConversationsRequest.serialize, + response_deserializer=contact_center_insights.ListConversationsResponse.deserialize, + ) + return self._stubs['list_conversations'] + + @property + def delete_conversation(self) -> Callable[ + [contact_center_insights.DeleteConversationRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete conversation method over gRPC. + + Deletes a conversation. + + Returns: + Callable[[~.DeleteConversationRequest], + ~.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_conversation' not in self._stubs: + self._stubs['delete_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteConversation', + request_serializer=contact_center_insights.DeleteConversationRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_conversation'] + + @property + def create_analysis(self) -> Callable[ + [contact_center_insights.CreateAnalysisRequest], + operations_pb2.Operation]: + r"""Return a callable for the create analysis method over gRPC. + + Creates an analysis. The long running operation is + done when the analysis has completed. + + Returns: + Callable[[~.CreateAnalysisRequest], + ~.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_analysis' not in self._stubs: + self._stubs['create_analysis'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateAnalysis', + request_serializer=contact_center_insights.CreateAnalysisRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_analysis'] + + @property + def get_analysis(self) -> Callable[ + [contact_center_insights.GetAnalysisRequest], + resources.Analysis]: + r"""Return a callable for the get analysis method over gRPC. + + Gets an analysis. + + Returns: + Callable[[~.GetAnalysisRequest], + ~.Analysis]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_analysis' not in self._stubs: + self._stubs['get_analysis'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetAnalysis', + request_serializer=contact_center_insights.GetAnalysisRequest.serialize, + response_deserializer=resources.Analysis.deserialize, + ) + return self._stubs['get_analysis'] + + @property + def list_analyses(self) -> Callable[ + [contact_center_insights.ListAnalysesRequest], + contact_center_insights.ListAnalysesResponse]: + r"""Return a callable for the list analyses method over gRPC. + + Lists analyses. + + Returns: + Callable[[~.ListAnalysesRequest], + ~.ListAnalysesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_analyses' not in self._stubs: + self._stubs['list_analyses'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListAnalyses', + request_serializer=contact_center_insights.ListAnalysesRequest.serialize, + response_deserializer=contact_center_insights.ListAnalysesResponse.deserialize, + ) + return self._stubs['list_analyses'] + + @property + def delete_analysis(self) -> Callable[ + [contact_center_insights.DeleteAnalysisRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete analysis method over gRPC. + + Deletes an analysis. + + Returns: + Callable[[~.DeleteAnalysisRequest], + ~.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_analysis' not in self._stubs: + self._stubs['delete_analysis'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteAnalysis', + request_serializer=contact_center_insights.DeleteAnalysisRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_analysis'] + + @property + def export_insights_data(self) -> Callable[ + [contact_center_insights.ExportInsightsDataRequest], + operations_pb2.Operation]: + r"""Return a callable for the export insights data method over gRPC. + + Export insights data to a destination defined in the + request body. + + Returns: + Callable[[~.ExportInsightsDataRequest], + ~.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 'export_insights_data' not in self._stubs: + self._stubs['export_insights_data'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ExportInsightsData', + request_serializer=contact_center_insights.ExportInsightsDataRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['export_insights_data'] + + @property + def create_issue_model(self) -> Callable[ + [contact_center_insights.CreateIssueModelRequest], + operations_pb2.Operation]: + r"""Return a callable for the create issue model method over gRPC. + + Creates an issue model. + + Returns: + Callable[[~.CreateIssueModelRequest], + ~.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_issue_model' not in self._stubs: + self._stubs['create_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateIssueModel', + request_serializer=contact_center_insights.CreateIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_issue_model'] + + @property + def update_issue_model(self) -> Callable[ + [contact_center_insights.UpdateIssueModelRequest], + resources.IssueModel]: + r"""Return a callable for the update issue model method over gRPC. + + Updates an issue model. + + Returns: + Callable[[~.UpdateIssueModelRequest], + ~.IssueModel]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_issue_model' not in self._stubs: + self._stubs['update_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssueModel', + request_serializer=contact_center_insights.UpdateIssueModelRequest.serialize, + response_deserializer=resources.IssueModel.deserialize, + ) + return self._stubs['update_issue_model'] + + @property + def get_issue_model(self) -> Callable[ + [contact_center_insights.GetIssueModelRequest], + resources.IssueModel]: + r"""Return a callable for the get issue model method over gRPC. + + Gets an issue model. + + Returns: + Callable[[~.GetIssueModelRequest], + ~.IssueModel]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_issue_model' not in self._stubs: + self._stubs['get_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssueModel', + request_serializer=contact_center_insights.GetIssueModelRequest.serialize, + response_deserializer=resources.IssueModel.deserialize, + ) + return self._stubs['get_issue_model'] + + @property + def list_issue_models(self) -> Callable[ + [contact_center_insights.ListIssueModelsRequest], + contact_center_insights.ListIssueModelsResponse]: + r"""Return a callable for the list issue models method over gRPC. + + Lists issue models. + + Returns: + Callable[[~.ListIssueModelsRequest], + ~.ListIssueModelsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_issue_models' not in self._stubs: + self._stubs['list_issue_models'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssueModels', + request_serializer=contact_center_insights.ListIssueModelsRequest.serialize, + response_deserializer=contact_center_insights.ListIssueModelsResponse.deserialize, + ) + return self._stubs['list_issue_models'] + + @property + def delete_issue_model(self) -> Callable[ + [contact_center_insights.DeleteIssueModelRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete issue model method over gRPC. + + Deletes an issue model. + + Returns: + Callable[[~.DeleteIssueModelRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_issue_model' not in self._stubs: + self._stubs['delete_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssueModel', + request_serializer=contact_center_insights.DeleteIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_issue_model'] + + @property + def deploy_issue_model(self) -> Callable[ + [contact_center_insights.DeployIssueModelRequest], + operations_pb2.Operation]: + r"""Return a callable for the deploy issue model method over gRPC. + + Deploys an issue model. Returns an error if a model + is already deployed. An issue model can only be used in + analysis after it has been deployed. + + Returns: + Callable[[~.DeployIssueModelRequest], + ~.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 'deploy_issue_model' not in self._stubs: + self._stubs['deploy_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployIssueModel', + request_serializer=contact_center_insights.DeployIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['deploy_issue_model'] + + @property + def undeploy_issue_model(self) -> Callable[ + [contact_center_insights.UndeployIssueModelRequest], + operations_pb2.Operation]: + r"""Return a callable for the undeploy issue model method over gRPC. + + Undeploys an issue model. + An issue model can not be used in analysis after it has + been undeployed. + + Returns: + Callable[[~.UndeployIssueModelRequest], + ~.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 'undeploy_issue_model' not in self._stubs: + self._stubs['undeploy_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployIssueModel', + request_serializer=contact_center_insights.UndeployIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['undeploy_issue_model'] + + @property + def get_issue(self) -> Callable[ + [contact_center_insights.GetIssueRequest], + resources.Issue]: + r"""Return a callable for the get issue method over gRPC. + + Gets an issue. + + Returns: + Callable[[~.GetIssueRequest], + ~.Issue]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_issue' not in self._stubs: + self._stubs['get_issue'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssue', + request_serializer=contact_center_insights.GetIssueRequest.serialize, + response_deserializer=resources.Issue.deserialize, + ) + return self._stubs['get_issue'] + + @property + def list_issues(self) -> Callable[ + [contact_center_insights.ListIssuesRequest], + contact_center_insights.ListIssuesResponse]: + r"""Return a callable for the list issues method over gRPC. + + Lists issues. + + Returns: + Callable[[~.ListIssuesRequest], + ~.ListIssuesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_issues' not in self._stubs: + self._stubs['list_issues'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssues', + request_serializer=contact_center_insights.ListIssuesRequest.serialize, + response_deserializer=contact_center_insights.ListIssuesResponse.deserialize, + ) + return self._stubs['list_issues'] + + @property + def update_issue(self) -> Callable[ + [contact_center_insights.UpdateIssueRequest], + resources.Issue]: + r"""Return a callable for the update issue method over gRPC. + + Updates an issue. + + Returns: + Callable[[~.UpdateIssueRequest], + ~.Issue]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_issue' not in self._stubs: + self._stubs['update_issue'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssue', + request_serializer=contact_center_insights.UpdateIssueRequest.serialize, + response_deserializer=resources.Issue.deserialize, + ) + return self._stubs['update_issue'] + + @property + def calculate_issue_model_stats(self) -> Callable[ + [contact_center_insights.CalculateIssueModelStatsRequest], + contact_center_insights.CalculateIssueModelStatsResponse]: + r"""Return a callable for the calculate issue model stats method over gRPC. + + Gets an issue model's statistics. + + Returns: + Callable[[~.CalculateIssueModelStatsRequest], + ~.CalculateIssueModelStatsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'calculate_issue_model_stats' not in self._stubs: + self._stubs['calculate_issue_model_stats'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateIssueModelStats', + request_serializer=contact_center_insights.CalculateIssueModelStatsRequest.serialize, + response_deserializer=contact_center_insights.CalculateIssueModelStatsResponse.deserialize, + ) + return self._stubs['calculate_issue_model_stats'] + + @property + def create_phrase_matcher(self) -> Callable[ + [contact_center_insights.CreatePhraseMatcherRequest], + resources.PhraseMatcher]: + r"""Return a callable for the create phrase matcher method over gRPC. + + Creates a phrase matcher. + + Returns: + Callable[[~.CreatePhraseMatcherRequest], + ~.PhraseMatcher]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_phrase_matcher' not in self._stubs: + self._stubs['create_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreatePhraseMatcher', + request_serializer=contact_center_insights.CreatePhraseMatcherRequest.serialize, + response_deserializer=resources.PhraseMatcher.deserialize, + ) + return self._stubs['create_phrase_matcher'] + + @property + def get_phrase_matcher(self) -> Callable[ + [contact_center_insights.GetPhraseMatcherRequest], + resources.PhraseMatcher]: + r"""Return a callable for the get phrase matcher method over gRPC. + + Gets a phrase matcher. + + Returns: + Callable[[~.GetPhraseMatcherRequest], + ~.PhraseMatcher]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_phrase_matcher' not in self._stubs: + self._stubs['get_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetPhraseMatcher', + request_serializer=contact_center_insights.GetPhraseMatcherRequest.serialize, + response_deserializer=resources.PhraseMatcher.deserialize, + ) + return self._stubs['get_phrase_matcher'] + + @property + def list_phrase_matchers(self) -> Callable[ + [contact_center_insights.ListPhraseMatchersRequest], + contact_center_insights.ListPhraseMatchersResponse]: + r"""Return a callable for the list phrase matchers method over gRPC. + + Lists phrase matchers. + + Returns: + Callable[[~.ListPhraseMatchersRequest], + ~.ListPhraseMatchersResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_phrase_matchers' not in self._stubs: + self._stubs['list_phrase_matchers'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListPhraseMatchers', + request_serializer=contact_center_insights.ListPhraseMatchersRequest.serialize, + response_deserializer=contact_center_insights.ListPhraseMatchersResponse.deserialize, + ) + return self._stubs['list_phrase_matchers'] + + @property + def delete_phrase_matcher(self) -> Callable[ + [contact_center_insights.DeletePhraseMatcherRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete phrase matcher method over gRPC. + + Deletes a phrase matcher. + + Returns: + Callable[[~.DeletePhraseMatcherRequest], + ~.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_phrase_matcher' not in self._stubs: + self._stubs['delete_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeletePhraseMatcher', + request_serializer=contact_center_insights.DeletePhraseMatcherRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_phrase_matcher'] + + @property + def update_phrase_matcher(self) -> Callable[ + [contact_center_insights.UpdatePhraseMatcherRequest], + resources.PhraseMatcher]: + r"""Return a callable for the update phrase matcher method over gRPC. + + Updates a phrase matcher. + + Returns: + Callable[[~.UpdatePhraseMatcherRequest], + ~.PhraseMatcher]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_phrase_matcher' not in self._stubs: + self._stubs['update_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher', + request_serializer=contact_center_insights.UpdatePhraseMatcherRequest.serialize, + response_deserializer=resources.PhraseMatcher.deserialize, + ) + return self._stubs['update_phrase_matcher'] + + @property + def calculate_stats(self) -> Callable[ + [contact_center_insights.CalculateStatsRequest], + contact_center_insights.CalculateStatsResponse]: + r"""Return a callable for the calculate stats method over gRPC. + + Gets conversation statistics. + + Returns: + Callable[[~.CalculateStatsRequest], + ~.CalculateStatsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'calculate_stats' not in self._stubs: + self._stubs['calculate_stats'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateStats', + request_serializer=contact_center_insights.CalculateStatsRequest.serialize, + response_deserializer=contact_center_insights.CalculateStatsResponse.deserialize, + ) + return self._stubs['calculate_stats'] + + @property + def get_settings(self) -> Callable[ + [contact_center_insights.GetSettingsRequest], + resources.Settings]: + r"""Return a callable for the get settings method over gRPC. + + Gets project-level settings. + + Returns: + Callable[[~.GetSettingsRequest], + ~.Settings]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_settings' not in self._stubs: + self._stubs['get_settings'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetSettings', + request_serializer=contact_center_insights.GetSettingsRequest.serialize, + response_deserializer=resources.Settings.deserialize, + ) + return self._stubs['get_settings'] + + @property + def update_settings(self) -> Callable[ + [contact_center_insights.UpdateSettingsRequest], + resources.Settings]: + r"""Return a callable for the update settings method over gRPC. + + Updates project-level settings. + + Returns: + Callable[[~.UpdateSettingsRequest], + ~.Settings]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_settings' not in self._stubs: + self._stubs['update_settings'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateSettings', + request_serializer=contact_center_insights.UpdateSettingsRequest.serialize, + response_deserializer=resources.Settings.deserialize, + ) + return self._stubs['update_settings'] + + @property + def create_view(self) -> Callable[ + [contact_center_insights.CreateViewRequest], + resources.View]: + r"""Return a callable for the create view method over gRPC. + + Creates a view. + + Returns: + Callable[[~.CreateViewRequest], + ~.View]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_view' not in self._stubs: + self._stubs['create_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateView', + request_serializer=contact_center_insights.CreateViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs['create_view'] + + @property + def get_view(self) -> Callable[ + [contact_center_insights.GetViewRequest], + resources.View]: + r"""Return a callable for the get view method over gRPC. + + Gets a view. + + Returns: + Callable[[~.GetViewRequest], + ~.View]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_view' not in self._stubs: + self._stubs['get_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetView', + request_serializer=contact_center_insights.GetViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs['get_view'] + + @property + def list_views(self) -> Callable[ + [contact_center_insights.ListViewsRequest], + contact_center_insights.ListViewsResponse]: + r"""Return a callable for the list views method over gRPC. + + Lists views. + + Returns: + Callable[[~.ListViewsRequest], + ~.ListViewsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_views' not in self._stubs: + self._stubs['list_views'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListViews', + request_serializer=contact_center_insights.ListViewsRequest.serialize, + response_deserializer=contact_center_insights.ListViewsResponse.deserialize, + ) + return self._stubs['list_views'] + + @property + def update_view(self) -> Callable[ + [contact_center_insights.UpdateViewRequest], + resources.View]: + r"""Return a callable for the update view method over gRPC. + + Updates a view. + + Returns: + Callable[[~.UpdateViewRequest], + ~.View]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_view' not in self._stubs: + self._stubs['update_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateView', + request_serializer=contact_center_insights.UpdateViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs['update_view'] + + @property + def delete_view(self) -> Callable[ + [contact_center_insights.DeleteViewRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete view method over gRPC. + + Deletes a view. + + Returns: + Callable[[~.DeleteViewRequest], + ~.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_view' not in self._stubs: + self._stubs['delete_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteView', + request_serializer=contact_center_insights.DeleteViewRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_view'] + + def close(self): + self.grpc_channel.close() + +__all__ = ( + 'ContactCenterInsightsGrpcTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py new file mode 100644 index 0000000..8922300 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py @@ -0,0 +1,1144 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from .base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO +from .grpc import ContactCenterInsightsGrpcTransport + + +class ContactCenterInsightsGrpcAsyncIOTransport(ContactCenterInsightsTransport): + """gRPC AsyncIO backend transport for ContactCenterInsights. + + An API that lets users analyze and explore their business + conversation data. + + 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 = 'contactcenterinsights.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 = 'contactcenterinsights.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: Optional[operations_v1.OperationsAsyncClient] = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_conversation(self) -> Callable[ + [contact_center_insights.CreateConversationRequest], + Awaitable[resources.Conversation]]: + r"""Return a callable for the create conversation method over gRPC. + + Creates a conversation. + + Returns: + Callable[[~.CreateConversationRequest], + Awaitable[~.Conversation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversation' not in self._stubs: + self._stubs['create_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateConversation', + request_serializer=contact_center_insights.CreateConversationRequest.serialize, + response_deserializer=resources.Conversation.deserialize, + ) + return self._stubs['create_conversation'] + + @property + def update_conversation(self) -> Callable[ + [contact_center_insights.UpdateConversationRequest], + Awaitable[resources.Conversation]]: + r"""Return a callable for the update conversation method over gRPC. + + Updates a conversation. + + Returns: + Callable[[~.UpdateConversationRequest], + Awaitable[~.Conversation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversation' not in self._stubs: + self._stubs['update_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateConversation', + request_serializer=contact_center_insights.UpdateConversationRequest.serialize, + response_deserializer=resources.Conversation.deserialize, + ) + return self._stubs['update_conversation'] + + @property + def get_conversation(self) -> Callable[ + [contact_center_insights.GetConversationRequest], + Awaitable[resources.Conversation]]: + r"""Return a callable for the get conversation method over gRPC. + + Gets a conversation. + + Returns: + Callable[[~.GetConversationRequest], + Awaitable[~.Conversation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversation' not in self._stubs: + self._stubs['get_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetConversation', + request_serializer=contact_center_insights.GetConversationRequest.serialize, + response_deserializer=resources.Conversation.deserialize, + ) + return self._stubs['get_conversation'] + + @property + def list_conversations(self) -> Callable[ + [contact_center_insights.ListConversationsRequest], + Awaitable[contact_center_insights.ListConversationsResponse]]: + r"""Return a callable for the list conversations method over gRPC. + + Lists conversations. + + Returns: + Callable[[~.ListConversationsRequest], + Awaitable[~.ListConversationsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_conversations' not in self._stubs: + self._stubs['list_conversations'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListConversations', + request_serializer=contact_center_insights.ListConversationsRequest.serialize, + response_deserializer=contact_center_insights.ListConversationsResponse.deserialize, + ) + return self._stubs['list_conversations'] + + @property + def delete_conversation(self) -> Callable[ + [contact_center_insights.DeleteConversationRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete conversation method over gRPC. + + Deletes a conversation. + + Returns: + Callable[[~.DeleteConversationRequest], + 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_conversation' not in self._stubs: + self._stubs['delete_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteConversation', + request_serializer=contact_center_insights.DeleteConversationRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_conversation'] + + @property + def create_analysis(self) -> Callable[ + [contact_center_insights.CreateAnalysisRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create analysis method over gRPC. + + Creates an analysis. The long running operation is + done when the analysis has completed. + + Returns: + Callable[[~.CreateAnalysisRequest], + 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_analysis' not in self._stubs: + self._stubs['create_analysis'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateAnalysis', + request_serializer=contact_center_insights.CreateAnalysisRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_analysis'] + + @property + def get_analysis(self) -> Callable[ + [contact_center_insights.GetAnalysisRequest], + Awaitable[resources.Analysis]]: + r"""Return a callable for the get analysis method over gRPC. + + Gets an analysis. + + Returns: + Callable[[~.GetAnalysisRequest], + Awaitable[~.Analysis]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_analysis' not in self._stubs: + self._stubs['get_analysis'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetAnalysis', + request_serializer=contact_center_insights.GetAnalysisRequest.serialize, + response_deserializer=resources.Analysis.deserialize, + ) + return self._stubs['get_analysis'] + + @property + def list_analyses(self) -> Callable[ + [contact_center_insights.ListAnalysesRequest], + Awaitable[contact_center_insights.ListAnalysesResponse]]: + r"""Return a callable for the list analyses method over gRPC. + + Lists analyses. + + Returns: + Callable[[~.ListAnalysesRequest], + Awaitable[~.ListAnalysesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_analyses' not in self._stubs: + self._stubs['list_analyses'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListAnalyses', + request_serializer=contact_center_insights.ListAnalysesRequest.serialize, + response_deserializer=contact_center_insights.ListAnalysesResponse.deserialize, + ) + return self._stubs['list_analyses'] + + @property + def delete_analysis(self) -> Callable[ + [contact_center_insights.DeleteAnalysisRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete analysis method over gRPC. + + Deletes an analysis. + + Returns: + Callable[[~.DeleteAnalysisRequest], + 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_analysis' not in self._stubs: + self._stubs['delete_analysis'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteAnalysis', + request_serializer=contact_center_insights.DeleteAnalysisRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_analysis'] + + @property + def export_insights_data(self) -> Callable[ + [contact_center_insights.ExportInsightsDataRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the export insights data method over gRPC. + + Export insights data to a destination defined in the + request body. + + Returns: + Callable[[~.ExportInsightsDataRequest], + 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 'export_insights_data' not in self._stubs: + self._stubs['export_insights_data'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ExportInsightsData', + request_serializer=contact_center_insights.ExportInsightsDataRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['export_insights_data'] + + @property + def create_issue_model(self) -> Callable[ + [contact_center_insights.CreateIssueModelRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create issue model method over gRPC. + + Creates an issue model. + + Returns: + Callable[[~.CreateIssueModelRequest], + 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_issue_model' not in self._stubs: + self._stubs['create_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateIssueModel', + request_serializer=contact_center_insights.CreateIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_issue_model'] + + @property + def update_issue_model(self) -> Callable[ + [contact_center_insights.UpdateIssueModelRequest], + Awaitable[resources.IssueModel]]: + r"""Return a callable for the update issue model method over gRPC. + + Updates an issue model. + + Returns: + Callable[[~.UpdateIssueModelRequest], + Awaitable[~.IssueModel]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_issue_model' not in self._stubs: + self._stubs['update_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssueModel', + request_serializer=contact_center_insights.UpdateIssueModelRequest.serialize, + response_deserializer=resources.IssueModel.deserialize, + ) + return self._stubs['update_issue_model'] + + @property + def get_issue_model(self) -> Callable[ + [contact_center_insights.GetIssueModelRequest], + Awaitable[resources.IssueModel]]: + r"""Return a callable for the get issue model method over gRPC. + + Gets an issue model. + + Returns: + Callable[[~.GetIssueModelRequest], + Awaitable[~.IssueModel]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_issue_model' not in self._stubs: + self._stubs['get_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssueModel', + request_serializer=contact_center_insights.GetIssueModelRequest.serialize, + response_deserializer=resources.IssueModel.deserialize, + ) + return self._stubs['get_issue_model'] + + @property + def list_issue_models(self) -> Callable[ + [contact_center_insights.ListIssueModelsRequest], + Awaitable[contact_center_insights.ListIssueModelsResponse]]: + r"""Return a callable for the list issue models method over gRPC. + + Lists issue models. + + Returns: + Callable[[~.ListIssueModelsRequest], + Awaitable[~.ListIssueModelsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_issue_models' not in self._stubs: + self._stubs['list_issue_models'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssueModels', + request_serializer=contact_center_insights.ListIssueModelsRequest.serialize, + response_deserializer=contact_center_insights.ListIssueModelsResponse.deserialize, + ) + return self._stubs['list_issue_models'] + + @property + def delete_issue_model(self) -> Callable[ + [contact_center_insights.DeleteIssueModelRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete issue model method over gRPC. + + Deletes an issue model. + + Returns: + Callable[[~.DeleteIssueModelRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_issue_model' not in self._stubs: + self._stubs['delete_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssueModel', + request_serializer=contact_center_insights.DeleteIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_issue_model'] + + @property + def deploy_issue_model(self) -> Callable[ + [contact_center_insights.DeployIssueModelRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the deploy issue model method over gRPC. + + Deploys an issue model. Returns an error if a model + is already deployed. An issue model can only be used in + analysis after it has been deployed. + + Returns: + Callable[[~.DeployIssueModelRequest], + 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 'deploy_issue_model' not in self._stubs: + self._stubs['deploy_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployIssueModel', + request_serializer=contact_center_insights.DeployIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['deploy_issue_model'] + + @property + def undeploy_issue_model(self) -> Callable[ + [contact_center_insights.UndeployIssueModelRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the undeploy issue model method over gRPC. + + Undeploys an issue model. + An issue model can not be used in analysis after it has + been undeployed. + + Returns: + Callable[[~.UndeployIssueModelRequest], + 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 'undeploy_issue_model' not in self._stubs: + self._stubs['undeploy_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployIssueModel', + request_serializer=contact_center_insights.UndeployIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['undeploy_issue_model'] + + @property + def get_issue(self) -> Callable[ + [contact_center_insights.GetIssueRequest], + Awaitable[resources.Issue]]: + r"""Return a callable for the get issue method over gRPC. + + Gets an issue. + + Returns: + Callable[[~.GetIssueRequest], + Awaitable[~.Issue]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_issue' not in self._stubs: + self._stubs['get_issue'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssue', + request_serializer=contact_center_insights.GetIssueRequest.serialize, + response_deserializer=resources.Issue.deserialize, + ) + return self._stubs['get_issue'] + + @property + def list_issues(self) -> Callable[ + [contact_center_insights.ListIssuesRequest], + Awaitable[contact_center_insights.ListIssuesResponse]]: + r"""Return a callable for the list issues method over gRPC. + + Lists issues. + + Returns: + Callable[[~.ListIssuesRequest], + Awaitable[~.ListIssuesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_issues' not in self._stubs: + self._stubs['list_issues'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssues', + request_serializer=contact_center_insights.ListIssuesRequest.serialize, + response_deserializer=contact_center_insights.ListIssuesResponse.deserialize, + ) + return self._stubs['list_issues'] + + @property + def update_issue(self) -> Callable[ + [contact_center_insights.UpdateIssueRequest], + Awaitable[resources.Issue]]: + r"""Return a callable for the update issue method over gRPC. + + Updates an issue. + + Returns: + Callable[[~.UpdateIssueRequest], + Awaitable[~.Issue]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_issue' not in self._stubs: + self._stubs['update_issue'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssue', + request_serializer=contact_center_insights.UpdateIssueRequest.serialize, + response_deserializer=resources.Issue.deserialize, + ) + return self._stubs['update_issue'] + + @property + def calculate_issue_model_stats(self) -> Callable[ + [contact_center_insights.CalculateIssueModelStatsRequest], + Awaitable[contact_center_insights.CalculateIssueModelStatsResponse]]: + r"""Return a callable for the calculate issue model stats method over gRPC. + + Gets an issue model's statistics. + + Returns: + Callable[[~.CalculateIssueModelStatsRequest], + Awaitable[~.CalculateIssueModelStatsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'calculate_issue_model_stats' not in self._stubs: + self._stubs['calculate_issue_model_stats'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateIssueModelStats', + request_serializer=contact_center_insights.CalculateIssueModelStatsRequest.serialize, + response_deserializer=contact_center_insights.CalculateIssueModelStatsResponse.deserialize, + ) + return self._stubs['calculate_issue_model_stats'] + + @property + def create_phrase_matcher(self) -> Callable[ + [contact_center_insights.CreatePhraseMatcherRequest], + Awaitable[resources.PhraseMatcher]]: + r"""Return a callable for the create phrase matcher method over gRPC. + + Creates a phrase matcher. + + Returns: + Callable[[~.CreatePhraseMatcherRequest], + Awaitable[~.PhraseMatcher]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_phrase_matcher' not in self._stubs: + self._stubs['create_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreatePhraseMatcher', + request_serializer=contact_center_insights.CreatePhraseMatcherRequest.serialize, + response_deserializer=resources.PhraseMatcher.deserialize, + ) + return self._stubs['create_phrase_matcher'] + + @property + def get_phrase_matcher(self) -> Callable[ + [contact_center_insights.GetPhraseMatcherRequest], + Awaitable[resources.PhraseMatcher]]: + r"""Return a callable for the get phrase matcher method over gRPC. + + Gets a phrase matcher. + + Returns: + Callable[[~.GetPhraseMatcherRequest], + Awaitable[~.PhraseMatcher]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_phrase_matcher' not in self._stubs: + self._stubs['get_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetPhraseMatcher', + request_serializer=contact_center_insights.GetPhraseMatcherRequest.serialize, + response_deserializer=resources.PhraseMatcher.deserialize, + ) + return self._stubs['get_phrase_matcher'] + + @property + def list_phrase_matchers(self) -> Callable[ + [contact_center_insights.ListPhraseMatchersRequest], + Awaitable[contact_center_insights.ListPhraseMatchersResponse]]: + r"""Return a callable for the list phrase matchers method over gRPC. + + Lists phrase matchers. + + Returns: + Callable[[~.ListPhraseMatchersRequest], + Awaitable[~.ListPhraseMatchersResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_phrase_matchers' not in self._stubs: + self._stubs['list_phrase_matchers'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListPhraseMatchers', + request_serializer=contact_center_insights.ListPhraseMatchersRequest.serialize, + response_deserializer=contact_center_insights.ListPhraseMatchersResponse.deserialize, + ) + return self._stubs['list_phrase_matchers'] + + @property + def delete_phrase_matcher(self) -> Callable[ + [contact_center_insights.DeletePhraseMatcherRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete phrase matcher method over gRPC. + + Deletes a phrase matcher. + + Returns: + Callable[[~.DeletePhraseMatcherRequest], + 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_phrase_matcher' not in self._stubs: + self._stubs['delete_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeletePhraseMatcher', + request_serializer=contact_center_insights.DeletePhraseMatcherRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_phrase_matcher'] + + @property + def update_phrase_matcher(self) -> Callable[ + [contact_center_insights.UpdatePhraseMatcherRequest], + Awaitable[resources.PhraseMatcher]]: + r"""Return a callable for the update phrase matcher method over gRPC. + + Updates a phrase matcher. + + Returns: + Callable[[~.UpdatePhraseMatcherRequest], + Awaitable[~.PhraseMatcher]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_phrase_matcher' not in self._stubs: + self._stubs['update_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher', + request_serializer=contact_center_insights.UpdatePhraseMatcherRequest.serialize, + response_deserializer=resources.PhraseMatcher.deserialize, + ) + return self._stubs['update_phrase_matcher'] + + @property + def calculate_stats(self) -> Callable[ + [contact_center_insights.CalculateStatsRequest], + Awaitable[contact_center_insights.CalculateStatsResponse]]: + r"""Return a callable for the calculate stats method over gRPC. + + Gets conversation statistics. + + Returns: + Callable[[~.CalculateStatsRequest], + Awaitable[~.CalculateStatsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'calculate_stats' not in self._stubs: + self._stubs['calculate_stats'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateStats', + request_serializer=contact_center_insights.CalculateStatsRequest.serialize, + response_deserializer=contact_center_insights.CalculateStatsResponse.deserialize, + ) + return self._stubs['calculate_stats'] + + @property + def get_settings(self) -> Callable[ + [contact_center_insights.GetSettingsRequest], + Awaitable[resources.Settings]]: + r"""Return a callable for the get settings method over gRPC. + + Gets project-level settings. + + Returns: + Callable[[~.GetSettingsRequest], + Awaitable[~.Settings]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_settings' not in self._stubs: + self._stubs['get_settings'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetSettings', + request_serializer=contact_center_insights.GetSettingsRequest.serialize, + response_deserializer=resources.Settings.deserialize, + ) + return self._stubs['get_settings'] + + @property + def update_settings(self) -> Callable[ + [contact_center_insights.UpdateSettingsRequest], + Awaitable[resources.Settings]]: + r"""Return a callable for the update settings method over gRPC. + + Updates project-level settings. + + Returns: + Callable[[~.UpdateSettingsRequest], + Awaitable[~.Settings]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_settings' not in self._stubs: + self._stubs['update_settings'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateSettings', + request_serializer=contact_center_insights.UpdateSettingsRequest.serialize, + response_deserializer=resources.Settings.deserialize, + ) + return self._stubs['update_settings'] + + @property + def create_view(self) -> Callable[ + [contact_center_insights.CreateViewRequest], + Awaitable[resources.View]]: + r"""Return a callable for the create view method over gRPC. + + Creates a view. + + Returns: + Callable[[~.CreateViewRequest], + Awaitable[~.View]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_view' not in self._stubs: + self._stubs['create_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateView', + request_serializer=contact_center_insights.CreateViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs['create_view'] + + @property + def get_view(self) -> Callable[ + [contact_center_insights.GetViewRequest], + Awaitable[resources.View]]: + r"""Return a callable for the get view method over gRPC. + + Gets a view. + + Returns: + Callable[[~.GetViewRequest], + Awaitable[~.View]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_view' not in self._stubs: + self._stubs['get_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetView', + request_serializer=contact_center_insights.GetViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs['get_view'] + + @property + def list_views(self) -> Callable[ + [contact_center_insights.ListViewsRequest], + Awaitable[contact_center_insights.ListViewsResponse]]: + r"""Return a callable for the list views method over gRPC. + + Lists views. + + Returns: + Callable[[~.ListViewsRequest], + Awaitable[~.ListViewsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_views' not in self._stubs: + self._stubs['list_views'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListViews', + request_serializer=contact_center_insights.ListViewsRequest.serialize, + response_deserializer=contact_center_insights.ListViewsResponse.deserialize, + ) + return self._stubs['list_views'] + + @property + def update_view(self) -> Callable[ + [contact_center_insights.UpdateViewRequest], + Awaitable[resources.View]]: + r"""Return a callable for the update view method over gRPC. + + Updates a view. + + Returns: + Callable[[~.UpdateViewRequest], + Awaitable[~.View]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_view' not in self._stubs: + self._stubs['update_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateView', + request_serializer=contact_center_insights.UpdateViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs['update_view'] + + @property + def delete_view(self) -> Callable[ + [contact_center_insights.DeleteViewRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete view method over gRPC. + + Deletes a view. + + Returns: + Callable[[~.DeleteViewRequest], + 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_view' not in self._stubs: + self._stubs['delete_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteView', + request_serializer=contact_center_insights.DeleteViewRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_view'] + + def close(self): + return self.grpc_channel.close() + + +__all__ = ( + 'ContactCenterInsightsGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/types/__init__.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/types/__init__.py new file mode 100644 index 0000000..135d34a --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/types/__init__.py @@ -0,0 +1,204 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 .contact_center_insights import ( + CalculateIssueModelStatsRequest, + CalculateIssueModelStatsResponse, + CalculateStatsRequest, + CalculateStatsResponse, + CreateAnalysisOperationMetadata, + CreateAnalysisRequest, + CreateConversationRequest, + CreateIssueModelMetadata, + CreateIssueModelRequest, + CreatePhraseMatcherRequest, + CreateViewRequest, + DeleteAnalysisRequest, + DeleteConversationRequest, + DeleteIssueModelMetadata, + DeleteIssueModelRequest, + DeletePhraseMatcherRequest, + DeleteViewRequest, + DeployIssueModelMetadata, + DeployIssueModelRequest, + DeployIssueModelResponse, + ExportInsightsDataMetadata, + ExportInsightsDataRequest, + ExportInsightsDataResponse, + GetAnalysisRequest, + GetConversationRequest, + GetIssueModelRequest, + GetIssueRequest, + GetPhraseMatcherRequest, + GetSettingsRequest, + GetViewRequest, + ListAnalysesRequest, + ListAnalysesResponse, + ListConversationsRequest, + ListConversationsResponse, + ListIssueModelsRequest, + ListIssueModelsResponse, + ListIssuesRequest, + ListIssuesResponse, + ListPhraseMatchersRequest, + ListPhraseMatchersResponse, + ListViewsRequest, + ListViewsResponse, + UndeployIssueModelMetadata, + UndeployIssueModelRequest, + UndeployIssueModelResponse, + UpdateConversationRequest, + UpdateIssueModelRequest, + UpdateIssueRequest, + UpdatePhraseMatcherRequest, + UpdateSettingsRequest, + UpdateViewRequest, + ConversationView, +) +from .resources import ( + Analysis, + AnalysisResult, + AnnotationBoundary, + AnswerFeedback, + ArticleSuggestionData, + CallAnnotation, + Conversation, + ConversationDataSource, + ConversationLevelSentiment, + ConversationParticipant, + DialogflowIntent, + DialogflowInteractionData, + DialogflowSource, + Entity, + EntityMentionData, + ExactMatchConfig, + FaqAnswerData, + GcsSource, + HoldData, + Intent, + IntentMatchData, + InterruptionData, + Issue, + IssueAssignment, + IssueModel, + IssueModelLabelStats, + IssueModelResult, + PhraseMatchData, + PhraseMatcher, + PhraseMatchRule, + PhraseMatchRuleConfig, + PhraseMatchRuleGroup, + RuntimeAnnotation, + SentimentData, + Settings, + SilenceData, + SmartComposeSuggestionData, + SmartReplyData, + View, +) + +__all__ = ( + 'CalculateIssueModelStatsRequest', + 'CalculateIssueModelStatsResponse', + 'CalculateStatsRequest', + 'CalculateStatsResponse', + 'CreateAnalysisOperationMetadata', + 'CreateAnalysisRequest', + 'CreateConversationRequest', + 'CreateIssueModelMetadata', + 'CreateIssueModelRequest', + 'CreatePhraseMatcherRequest', + 'CreateViewRequest', + 'DeleteAnalysisRequest', + 'DeleteConversationRequest', + 'DeleteIssueModelMetadata', + 'DeleteIssueModelRequest', + 'DeletePhraseMatcherRequest', + 'DeleteViewRequest', + 'DeployIssueModelMetadata', + 'DeployIssueModelRequest', + 'DeployIssueModelResponse', + 'ExportInsightsDataMetadata', + 'ExportInsightsDataRequest', + 'ExportInsightsDataResponse', + 'GetAnalysisRequest', + 'GetConversationRequest', + 'GetIssueModelRequest', + 'GetIssueRequest', + 'GetPhraseMatcherRequest', + 'GetSettingsRequest', + 'GetViewRequest', + 'ListAnalysesRequest', + 'ListAnalysesResponse', + 'ListConversationsRequest', + 'ListConversationsResponse', + 'ListIssueModelsRequest', + 'ListIssueModelsResponse', + 'ListIssuesRequest', + 'ListIssuesResponse', + 'ListPhraseMatchersRequest', + 'ListPhraseMatchersResponse', + 'ListViewsRequest', + 'ListViewsResponse', + 'UndeployIssueModelMetadata', + 'UndeployIssueModelRequest', + 'UndeployIssueModelResponse', + 'UpdateConversationRequest', + 'UpdateIssueModelRequest', + 'UpdateIssueRequest', + 'UpdatePhraseMatcherRequest', + 'UpdateSettingsRequest', + 'UpdateViewRequest', + 'ConversationView', + 'Analysis', + 'AnalysisResult', + 'AnnotationBoundary', + 'AnswerFeedback', + 'ArticleSuggestionData', + 'CallAnnotation', + 'Conversation', + 'ConversationDataSource', + 'ConversationLevelSentiment', + 'ConversationParticipant', + 'DialogflowIntent', + 'DialogflowInteractionData', + 'DialogflowSource', + 'Entity', + 'EntityMentionData', + 'ExactMatchConfig', + 'FaqAnswerData', + 'GcsSource', + 'HoldData', + 'Intent', + 'IntentMatchData', + 'InterruptionData', + 'Issue', + 'IssueAssignment', + 'IssueModel', + 'IssueModelLabelStats', + 'IssueModelResult', + 'PhraseMatchData', + 'PhraseMatcher', + 'PhraseMatchRule', + 'PhraseMatchRuleConfig', + 'PhraseMatchRuleGroup', + 'RuntimeAnnotation', + 'SentimentData', + 'Settings', + 'SilenceData', + 'SmartComposeSuggestionData', + 'SmartReplyData', + 'View', +) diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/types/contact_center_insights.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/types/contact_center_insights.py new file mode 100644 index 0000000..fb7568e --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/types/contact_center_insights.py @@ -0,0 +1,1387 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.contact_center_insights_v1.types import resources +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.contactcenterinsights.v1', + manifest={ + 'ConversationView', + 'CalculateStatsRequest', + 'CalculateStatsResponse', + 'CreateAnalysisOperationMetadata', + 'CreateConversationRequest', + 'ListConversationsRequest', + 'ListConversationsResponse', + 'GetConversationRequest', + 'UpdateConversationRequest', + 'DeleteConversationRequest', + 'CreateAnalysisRequest', + 'ListAnalysesRequest', + 'ListAnalysesResponse', + 'GetAnalysisRequest', + 'DeleteAnalysisRequest', + 'ExportInsightsDataRequest', + 'ExportInsightsDataMetadata', + 'ExportInsightsDataResponse', + 'CreateIssueModelRequest', + 'CreateIssueModelMetadata', + 'UpdateIssueModelRequest', + 'ListIssueModelsRequest', + 'ListIssueModelsResponse', + 'GetIssueModelRequest', + 'DeleteIssueModelRequest', + 'DeleteIssueModelMetadata', + 'DeployIssueModelRequest', + 'DeployIssueModelResponse', + 'DeployIssueModelMetadata', + 'UndeployIssueModelRequest', + 'UndeployIssueModelResponse', + 'UndeployIssueModelMetadata', + 'GetIssueRequest', + 'ListIssuesRequest', + 'ListIssuesResponse', + 'UpdateIssueRequest', + 'CalculateIssueModelStatsRequest', + 'CalculateIssueModelStatsResponse', + 'CreatePhraseMatcherRequest', + 'ListPhraseMatchersRequest', + 'ListPhraseMatchersResponse', + 'GetPhraseMatcherRequest', + 'DeletePhraseMatcherRequest', + 'UpdatePhraseMatcherRequest', + 'GetSettingsRequest', + 'UpdateSettingsRequest', + 'CreateViewRequest', + 'GetViewRequest', + 'ListViewsRequest', + 'ListViewsResponse', + 'UpdateViewRequest', + 'DeleteViewRequest', + }, +) + + +class ConversationView(proto.Enum): + r"""Represents the options for views of a conversation.""" + CONVERSATION_VIEW_UNSPECIFIED = 0 + BASIC = 1 + FULL = 2 + + +class CalculateStatsRequest(proto.Message): + r"""The request for calculating conversation statistics. + + Attributes: + location (str): + Required. The location of the conversations. + filter (str): + A filter to reduce results to a specific + subset. This field is useful for getting + statistics about conversations with specific + properties. + """ + + location = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + + +class CalculateStatsResponse(proto.Message): + r"""The response for calculating conversation statistics. + + Attributes: + average_duration (google.protobuf.duration_pb2.Duration): + The average duration of all conversations. + The average is calculated using only + conversations that have a time duration. + average_turn_count (int): + The average number of turns per conversation. + conversation_count (int): + The total number of conversations. + smart_highlighter_matches (Sequence[google.cloud.contact_center_insights_v1.types.CalculateStatsResponse.SmartHighlighterMatchesEntry]): + A map associating each smart highlighter + display name with its respective number of + matches in the set of conversations. + custom_highlighter_matches (Sequence[google.cloud.contact_center_insights_v1.types.CalculateStatsResponse.CustomHighlighterMatchesEntry]): + A map associating each custom highlighter + resource name with its respective number of + matches in the set of conversations. + issue_matches (Sequence[google.cloud.contact_center_insights_v1.types.CalculateStatsResponse.IssueMatchesEntry]): + A map associating each issue resource name with its + respective number of matches in the set of conversations. + Key has the format: + ``projects//locations//issueModels//issues/`` + Deprecated, use ``issue_matches_stats`` field instead. + issue_matches_stats (Sequence[google.cloud.contact_center_insights_v1.types.CalculateStatsResponse.IssueMatchesStatsEntry]): + A map associating each issue resource name with its + respective number of matches in the set of conversations. + Key has the format: + ``projects//locations//issueModels//issues/`` + conversation_count_time_series (google.cloud.contact_center_insights_v1.types.CalculateStatsResponse.TimeSeries): + A time series representing the count of + conversations created over time that match that + requested filter criteria. + """ + + class TimeSeries(proto.Message): + r"""A time series representing conversations over time. + + Attributes: + interval_duration (google.protobuf.duration_pb2.Duration): + The duration of each interval. + points (Sequence[google.cloud.contact_center_insights_v1.types.CalculateStatsResponse.TimeSeries.Interval]): + An ordered list of intervals from earliest to + latest, where each interval represents the + number of conversations that transpired during + the time window. + """ + + class Interval(proto.Message): + r"""A single interval in a time series. + + Attributes: + start_time (google.protobuf.timestamp_pb2.Timestamp): + The start time of this interval. + conversation_count (int): + The number of conversations created in this + interval. + """ + + start_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + conversation_count = proto.Field( + proto.INT32, + number=2, + ) + + interval_duration = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) + points = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='CalculateStatsResponse.TimeSeries.Interval', + ) + + average_duration = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) + average_turn_count = proto.Field( + proto.INT32, + number=2, + ) + conversation_count = proto.Field( + proto.INT32, + number=3, + ) + smart_highlighter_matches = proto.MapField( + proto.STRING, + proto.INT32, + number=4, + ) + custom_highlighter_matches = proto.MapField( + proto.STRING, + proto.INT32, + number=5, + ) + issue_matches = proto.MapField( + proto.STRING, + proto.INT32, + number=6, + ) + issue_matches_stats = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=8, + message=resources.IssueModelLabelStats.IssueStats, + ) + conversation_count_time_series = proto.Field( + proto.MESSAGE, + number=7, + message=TimeSeries, + ) + + +class CreateAnalysisOperationMetadata(proto.Message): + r"""Metadata for a create analysis operation. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + conversation (str): + Output only. The Conversation that this + Analysis Operation belongs to. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + conversation = proto.Field( + proto.STRING, + number=3, + ) + + +class CreateConversationRequest(proto.Message): + r"""Request to create a conversation. + + Attributes: + parent (str): + Required. The parent resource of the + conversation. + conversation (google.cloud.contact_center_insights_v1.types.Conversation): + Required. The conversation resource to + create. + conversation_id (str): + A unique ID for the new conversation. This ID will become + the final component of the conversation's resource name. If + no ID is specified, a server-generated ID will be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid characters + are ``[a-z][0-9]-`` + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + conversation = proto.Field( + proto.MESSAGE, + number=2, + message=resources.Conversation, + ) + conversation_id = proto.Field( + proto.STRING, + number=3, + ) + + +class ListConversationsRequest(proto.Message): + r"""Request to list conversations. + + Attributes: + parent (str): + Required. The parent resource of the + conversation. + page_size (int): + The maximum number of conversations to return + in the response. A valid page size ranges from 0 + to 1,000 inclusive. If the page size is zero or + unspecified, a default page size of 100 will be + chosen. Note that a call might return fewer + results than the requested page size. + page_token (str): + The value returned by the last + ``ListConversationsResponse``. This value indicates that + this is a continuation of a prior ``ListConversations`` call + and that the system should return the next page of data. + filter (str): + A filter to reduce results to a specific + subset. Useful for querying conversations with + specific properties. + view (google.cloud.contact_center_insights_v1.types.ConversationView): + The level of details of the conversation. Default is + ``BASIC``. + """ + + 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, + ) + view = proto.Field( + proto.ENUM, + number=5, + enum='ConversationView', + ) + + +class ListConversationsResponse(proto.Message): + r"""The response of listing conversations. + + Attributes: + conversations (Sequence[google.cloud.contact_center_insights_v1.types.Conversation]): + The conversations that match the request. + next_page_token (str): + A token which can be sent as ``page_token`` to retrieve the + next page. If this field is set, it means there is another + page available. If it is not set, it means no other pages + are available. + """ + + @property + def raw_page(self): + return self + + conversations = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.Conversation, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class GetConversationRequest(proto.Message): + r"""The request to get a conversation. + + Attributes: + name (str): + Required. The name of the conversation to + get. + view (google.cloud.contact_center_insights_v1.types.ConversationView): + The level of details of the conversation. Default is + ``FULL``. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + view = proto.Field( + proto.ENUM, + number=2, + enum='ConversationView', + ) + + +class UpdateConversationRequest(proto.Message): + r"""The request to update a conversation. + + Attributes: + conversation (google.cloud.contact_center_insights_v1.types.Conversation): + Required. The new values for the + conversation. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + """ + + conversation = proto.Field( + proto.MESSAGE, + number=1, + message=resources.Conversation, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteConversationRequest(proto.Message): + r"""The request to delete a conversation. + + Attributes: + name (str): + Required. The name of the conversation to + delete. + force (bool): + If set to true, all of this conversation's + analyses will also be deleted. Otherwise, the + request will only succeed if the conversation + has no analyses. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + force = proto.Field( + proto.BOOL, + number=2, + ) + + +class CreateAnalysisRequest(proto.Message): + r"""The request to create an analysis. + + Attributes: + parent (str): + Required. The parent resource of the + analysis. + analysis (google.cloud.contact_center_insights_v1.types.Analysis): + Required. The analysis to create. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + analysis = proto.Field( + proto.MESSAGE, + number=2, + message=resources.Analysis, + ) + + +class ListAnalysesRequest(proto.Message): + r"""The request to list analyses. + + Attributes: + parent (str): + Required. The parent resource of the + analyses. + page_size (int): + The maximum number of analyses to return in the response. If + this value is zero, the service will select a default size. + A call might return fewer objects than requested. A + non-empty ``next_page_token`` in the response indicates that + more data is available. + page_token (str): + The value returned by the last ``ListAnalysesResponse``; + indicates that this is a continuation of a prior + ``ListAnalyses`` call and the system should return the next + page of data. + filter (str): + A filter to reduce results to a specific + subset. Useful for querying conversations with + specific properties. + """ + + 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, + ) + + +class ListAnalysesResponse(proto.Message): + r"""The response to list analyses. + + Attributes: + analyses (Sequence[google.cloud.contact_center_insights_v1.types.Analysis]): + The analyses that match the request. + next_page_token (str): + A token, which 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 + + analyses = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.Analysis, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class GetAnalysisRequest(proto.Message): + r"""The request to get an analysis. + + Attributes: + name (str): + Required. The name of the analysis to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteAnalysisRequest(proto.Message): + r"""The request to delete an analysis. + + Attributes: + name (str): + Required. The name of the analysis to delete. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ExportInsightsDataRequest(proto.Message): + r"""The request to export insights. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + big_query_destination (google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest.BigQueryDestination): + Specified if sink is a BigQuery table. + + This field is a member of `oneof`_ ``destination``. + parent (str): + Required. The parent resource to export data + from. + filter (str): + A filter to reduce results to a specific + subset. Useful for exporting conversations with + specific properties. + kms_key (str): + A fully qualified KMS key name for BigQuery + tables protected by CMEK. Format: + projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}/cryptoKeyVersions/{version} + write_disposition (google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest.WriteDisposition): + Options for what to do if the destination + table already exists. + """ + class WriteDisposition(proto.Enum): + r"""Specifies the action that occurs if the destination table + already exists. + """ + WRITE_DISPOSITION_UNSPECIFIED = 0 + WRITE_TRUNCATE = 1 + WRITE_APPEND = 2 + + class BigQueryDestination(proto.Message): + r"""A BigQuery Table Reference. + + Attributes: + project_id (str): + A project ID or number. If specified, then + export will attempt to write data to this + project instead of the resource project. + Otherwise, the resource project will be used. + dataset (str): + Required. The name of the BigQuery dataset that the snapshot + result should be exported to. If this dataset does not + exist, the export call returns an INVALID_ARGUMENT error. + table (str): + The BigQuery table name to which the insights data should be + written. If this table does not exist, the export call + returns an INVALID_ARGUMENT error. + """ + + project_id = proto.Field( + proto.STRING, + number=3, + ) + dataset = proto.Field( + proto.STRING, + number=1, + ) + table = proto.Field( + proto.STRING, + number=2, + ) + + big_query_destination = proto.Field( + proto.MESSAGE, + number=2, + oneof='destination', + message=BigQueryDestination, + ) + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=3, + ) + kms_key = proto.Field( + proto.STRING, + number=4, + ) + write_disposition = proto.Field( + proto.ENUM, + number=5, + enum=WriteDisposition, + ) + + +class ExportInsightsDataMetadata(proto.Message): + r"""Metadata for an export insights operation. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest): + The original request for export. + partial_errors (Sequence[google.rpc.status_pb2.Status]): + Partial errors during export operation that + might cause the operation output to be + incomplete. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request = proto.Field( + proto.MESSAGE, + number=3, + message='ExportInsightsDataRequest', + ) + partial_errors = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=status_pb2.Status, + ) + + +class ExportInsightsDataResponse(proto.Message): + r"""Response for an export insights operation. + """ + + +class CreateIssueModelRequest(proto.Message): + r"""The request to create an issue model. + + Attributes: + parent (str): + Required. The parent resource of the issue + model. + issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): + Required. The issue model to create. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + issue_model = proto.Field( + proto.MESSAGE, + number=2, + message=resources.IssueModel, + ) + + +class CreateIssueModelMetadata(proto.Message): + r"""Metadata for creating an issue model. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest): + The original request for creation. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request = proto.Field( + proto.MESSAGE, + number=3, + message='CreateIssueModelRequest', + ) + + +class UpdateIssueModelRequest(proto.Message): + r"""The request to update an issue model. + + Attributes: + issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): + Required. The new values for the issue model. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + """ + + issue_model = proto.Field( + proto.MESSAGE, + number=1, + message=resources.IssueModel, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class ListIssueModelsRequest(proto.Message): + r"""Request to list issue models. + + Attributes: + parent (str): + Required. The parent resource of the issue + model. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + + +class ListIssueModelsResponse(proto.Message): + r"""The response of listing issue models. + + Attributes: + issue_models (Sequence[google.cloud.contact_center_insights_v1.types.IssueModel]): + The issue models that match the request. + """ + + issue_models = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.IssueModel, + ) + + +class GetIssueModelRequest(proto.Message): + r"""The request to get an issue model. + + Attributes: + name (str): + Required. The name of the issue model to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteIssueModelRequest(proto.Message): + r"""The request to delete an issue model. + + Attributes: + name (str): + Required. The name of the issue model to + delete. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteIssueModelMetadata(proto.Message): + r"""Metadata for deleting an issue model. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest): + The original request for deletion. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request = proto.Field( + proto.MESSAGE, + number=3, + message='DeleteIssueModelRequest', + ) + + +class DeployIssueModelRequest(proto.Message): + r"""The request to deploy an issue model. + + Attributes: + name (str): + Required. The issue model to deploy. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class DeployIssueModelResponse(proto.Message): + r"""The response to deploy an issue model. + """ + + +class DeployIssueModelMetadata(proto.Message): + r"""Metadata for deploying an issue model. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest): + The original request for deployment. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request = proto.Field( + proto.MESSAGE, + number=3, + message='DeployIssueModelRequest', + ) + + +class UndeployIssueModelRequest(proto.Message): + r"""The request to undeploy an issue model. + + Attributes: + name (str): + Required. The issue model to undeploy. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UndeployIssueModelResponse(proto.Message): + r"""The response to undeploy an issue model. + """ + + +class UndeployIssueModelMetadata(proto.Message): + r"""Metadata for undeploying an issue model. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest): + The original request for undeployment. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request = proto.Field( + proto.MESSAGE, + number=3, + message='UndeployIssueModelRequest', + ) + + +class GetIssueRequest(proto.Message): + r"""The request to get an issue. + + Attributes: + name (str): + Required. The name of the issue to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListIssuesRequest(proto.Message): + r"""Request to list issues. + + Attributes: + parent (str): + Required. The parent resource of the issue. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + + +class ListIssuesResponse(proto.Message): + r"""The response of listing issues. + + Attributes: + issues (Sequence[google.cloud.contact_center_insights_v1.types.Issue]): + The issues that match the request. + """ + + issues = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.Issue, + ) + + +class UpdateIssueRequest(proto.Message): + r"""The request to update an issue. + + Attributes: + issue (google.cloud.contact_center_insights_v1.types.Issue): + Required. The new values for the issue. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + """ + + issue = proto.Field( + proto.MESSAGE, + number=1, + message=resources.Issue, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class CalculateIssueModelStatsRequest(proto.Message): + r"""Request to get statistics of an issue model. + + Attributes: + issue_model (str): + Required. The resource name of the issue + model to query against. + """ + + issue_model = proto.Field( + proto.STRING, + number=1, + ) + + +class CalculateIssueModelStatsResponse(proto.Message): + r"""Response of querying an issue model's statistics. + + Attributes: + current_stats (google.cloud.contact_center_insights_v1.types.IssueModelLabelStats): + The latest label statistics for the queried + issue model. Includes results on both training + data and data labeled after deployment. + """ + + current_stats = proto.Field( + proto.MESSAGE, + number=4, + message=resources.IssueModelLabelStats, + ) + + +class CreatePhraseMatcherRequest(proto.Message): + r"""Request to create a phrase matcher. + + Attributes: + parent (str): + Required. The parent resource of the phrase matcher. + Required. The location to create a phrase matcher for. + Format: ``projects//locations/`` or + ``projects//locations/`` + phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher): + Required. The phrase matcher resource to + create. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + phrase_matcher = proto.Field( + proto.MESSAGE, + number=2, + message=resources.PhraseMatcher, + ) + + +class ListPhraseMatchersRequest(proto.Message): + r"""Request to list phrase matchers. + + Attributes: + parent (str): + Required. The parent resource of the phrase + matcher. + page_size (int): + The maximum number of phrase matchers to return in the + response. If this value is zero, the service will select a + default size. A call might return fewer objects than + requested. A non-empty ``next_page_token`` in the response + indicates that more data is available. + page_token (str): + The value returned by the last + ``ListPhraseMatchersResponse``. This value indicates that + this is a continuation of a prior ``ListPhraseMatchers`` + call and that the system should return the next page of + data. + filter (str): + A filter to reduce results to a specific + subset. Useful for querying phrase matchers with + specific properties. + """ + + 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, + ) + + +class ListPhraseMatchersResponse(proto.Message): + r"""The response of listing phrase matchers. + + Attributes: + phrase_matchers (Sequence[google.cloud.contact_center_insights_v1.types.PhraseMatcher]): + The phrase matchers that match the request. + next_page_token (str): + A token, which 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 + + phrase_matchers = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.PhraseMatcher, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class GetPhraseMatcherRequest(proto.Message): + r"""The request to get a a phrase matcher. + + Attributes: + name (str): + Required. The name of the phrase matcher to + get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class DeletePhraseMatcherRequest(proto.Message): + r"""The request to delete a phrase matcher. + + Attributes: + name (str): + Required. The name of the phrase matcher to + delete. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdatePhraseMatcherRequest(proto.Message): + r"""The request to update a phrase matcher. + + Attributes: + phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher): + Required. The new values for the phrase + matcher. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + """ + + phrase_matcher = proto.Field( + proto.MESSAGE, + number=1, + message=resources.PhraseMatcher, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class GetSettingsRequest(proto.Message): + r"""The request to get project-level settings. + + Attributes: + name (str): + Required. The name of the settings resource + to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateSettingsRequest(proto.Message): + r"""The request to update project-level settings. + + Attributes: + settings (google.cloud.contact_center_insights_v1.types.Settings): + Required. The new settings values. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. + """ + + settings = proto.Field( + proto.MESSAGE, + number=1, + message=resources.Settings, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class CreateViewRequest(proto.Message): + r"""The request to create a view. + + Attributes: + parent (str): + Required. The parent resource of the view. Required. The + location to create a view for. Format: + ``projects//locations/`` or + ``projects//locations/`` + view (google.cloud.contact_center_insights_v1.types.View): + Required. The view resource to create. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + view = proto.Field( + proto.MESSAGE, + number=2, + message=resources.View, + ) + + +class GetViewRequest(proto.Message): + r"""The request to get a view. + + Attributes: + name (str): + Required. The name of the view to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class ListViewsRequest(proto.Message): + r"""The request to list views. + + Attributes: + parent (str): + Required. The parent resource of the views. + page_size (int): + The maximum number of views to return in the response. If + this value is zero, the service will select a default size. + A call may return fewer objects than requested. A non-empty + ``next_page_token`` in the response indicates that more data + is available. + page_token (str): + The value returned by the last ``ListViewsResponse``; + indicates that this is a continuation of a prior + ``ListViews`` call and the system should return the next + page of data. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + + +class ListViewsResponse(proto.Message): + r"""The response of listing views. + + Attributes: + views (Sequence[google.cloud.contact_center_insights_v1.types.View]): + The views that match the request. + next_page_token (str): + A token, which 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 + + views = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.View, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class UpdateViewRequest(proto.Message): + r"""The request to update a view. + + Attributes: + view (google.cloud.contact_center_insights_v1.types.View): + Required. The new view. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + """ + + view = proto.Field( + proto.MESSAGE, + number=1, + message=resources.View, + ) + update_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteViewRequest(proto.Message): + r"""The request to delete a view. + + Attributes: + name (str): + Required. The name of the view to delete. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/types/resources.py b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/types/resources.py new file mode 100644 index 0000000..0020354 --- /dev/null +++ b/owl-bot-staging/v1/google/cloud/contact_center_insights_v1/types/resources.py @@ -0,0 +1,2017 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import proto # type: ignore + +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.contactcenterinsights.v1', + manifest={ + 'Conversation', + 'Analysis', + 'ConversationDataSource', + 'GcsSource', + 'DialogflowSource', + 'AnalysisResult', + 'IssueModelResult', + 'ConversationLevelSentiment', + 'IssueAssignment', + 'CallAnnotation', + 'AnnotationBoundary', + 'Entity', + 'Intent', + 'PhraseMatchData', + 'DialogflowIntent', + 'InterruptionData', + 'SilenceData', + 'HoldData', + 'EntityMentionData', + 'IntentMatchData', + 'SentimentData', + 'IssueModel', + 'Issue', + 'IssueModelLabelStats', + 'PhraseMatcher', + 'PhraseMatchRuleGroup', + 'PhraseMatchRule', + 'PhraseMatchRuleConfig', + 'ExactMatchConfig', + 'Settings', + 'RuntimeAnnotation', + 'AnswerFeedback', + 'ArticleSuggestionData', + 'FaqAnswerData', + 'SmartReplyData', + 'SmartComposeSuggestionData', + 'DialogflowInteractionData', + 'ConversationParticipant', + 'View', + }, +) + + +class Conversation(proto.Message): + r"""The conversation resource. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + call_metadata (google.cloud.contact_center_insights_v1.types.Conversation.CallMetadata): + Call-specific metadata. + + This field is a member of `oneof`_ ``metadata``. + expire_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which this conversation should + expire. After this time, the conversation data + and any associated analyses will be deleted. + + This field is a member of `oneof`_ ``expiration``. + ttl (google.protobuf.duration_pb2.Duration): + Input only. The TTL for this resource. If + specified, then this TTL will be used to + calculate the expire time. + + This field is a member of `oneof`_ ``expiration``. + name (str): + Immutable. The resource name of the + conversation. Format: + projects/{project}/locations/{location}/conversations/{conversation} + data_source (google.cloud.contact_center_insights_v1.types.ConversationDataSource): + The source of the audio and transcription for + the conversation. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the + conversation was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + the conversation was updated. + start_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which the conversation started. + language_code (str): + A user-specified language code for the + conversation. + agent_id (str): + An opaque, user-specified string representing + the human agent who handled the conversation. + labels (Sequence[google.cloud.contact_center_insights_v1.types.Conversation.LabelsEntry]): + A map for the user to specify any custom + fields. A maximum of 20 labels per conversation + is allowed, with a maximum of 256 characters per + entry. + transcript (google.cloud.contact_center_insights_v1.types.Conversation.Transcript): + Output only. The conversation transcript. + medium (google.cloud.contact_center_insights_v1.types.Conversation.Medium): + Immutable. The conversation medium, if unspecified will + default to PHONE_CALL. + duration (google.protobuf.duration_pb2.Duration): + Output only. The duration of the + conversation. + turn_count (int): + Output only. The number of turns in the + conversation. + latest_analysis (google.cloud.contact_center_insights_v1.types.Analysis): + Output only. The conversation's latest + analysis, if one exists. + runtime_annotations (Sequence[google.cloud.contact_center_insights_v1.types.RuntimeAnnotation]): + Output only. The annotations that were + generated during the customer and agent + interaction. + dialogflow_intents (Sequence[google.cloud.contact_center_insights_v1.types.Conversation.DialogflowIntentsEntry]): + Output only. All the matched Dialogflow + intents in the call. The key corresponds to a + Dialogflow intent, format: + projects/{project}/agent/{agent}/intents/{intent} + obfuscated_user_id (str): + Obfuscated user ID which the customer sent to + us. + """ + class Medium(proto.Enum): + r"""Possible media for the conversation.""" + MEDIUM_UNSPECIFIED = 0 + PHONE_CALL = 1 + CHAT = 2 + + class CallMetadata(proto.Message): + r"""Call-specific metadata. + + Attributes: + customer_channel (int): + The audio channel that contains the customer. + agent_channel (int): + The audio channel that contains the agent. + """ + + customer_channel = proto.Field( + proto.INT32, + number=1, + ) + agent_channel = proto.Field( + proto.INT32, + number=2, + ) + + class Transcript(proto.Message): + r"""A message representing the transcript of a conversation. + + Attributes: + transcript_segments (Sequence[google.cloud.contact_center_insights_v1.types.Conversation.Transcript.TranscriptSegment]): + A list of sequential transcript segments that + comprise the conversation. + """ + + class TranscriptSegment(proto.Message): + r"""A segment of a full transcript. + + Attributes: + message_time (google.protobuf.timestamp_pb2.Timestamp): + The time that the message occurred, if + provided. + text (str): + The text of this segment. + confidence (float): + A confidence estimate between 0.0 and 1.0 of + the fidelity of this segment. A default value of + 0.0 indicates that the value is unset. + words (Sequence[google.cloud.contact_center_insights_v1.types.Conversation.Transcript.TranscriptSegment.WordInfo]): + A list of the word-specific information for + each word in the segment. + language_code (str): + The language code of this segment as a + `BCP-47 `__ + language tag. Example: "en-US". + channel_tag (int): + For conversations derived from multi-channel + audio, this is the channel number corresponding + to the audio from that channel. For + audioChannelCount = N, its output values can + range from '1' to 'N'. A channel tag of 0 + indicates that the audio is mono. + segment_participant (google.cloud.contact_center_insights_v1.types.ConversationParticipant): + The participant of this segment. + dialogflow_segment_metadata (google.cloud.contact_center_insights_v1.types.Conversation.Transcript.TranscriptSegment.DialogflowSegmentMetadata): + CCAI metadata relating to the current + transcript segment. + sentiment (google.cloud.contact_center_insights_v1.types.SentimentData): + The sentiment for this transcript segment. + """ + + class WordInfo(proto.Message): + r"""Word-level info for words in a transcript. + + Attributes: + start_offset (google.protobuf.duration_pb2.Duration): + Time offset of the start of this word + relative to the beginning of the total + conversation. + end_offset (google.protobuf.duration_pb2.Duration): + Time offset of the end of this word relative + to the beginning of the total conversation. + word (str): + The word itself. Includes punctuation marks + that surround the word. + confidence (float): + A confidence estimate between 0.0 and 1.0 of + the fidelity of this word. A default value of + 0.0 indicates that the value is unset. + """ + + start_offset = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) + end_offset = proto.Field( + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, + ) + word = proto.Field( + proto.STRING, + number=3, + ) + confidence = proto.Field( + proto.FLOAT, + number=4, + ) + + class DialogflowSegmentMetadata(proto.Message): + r"""Metadata from Dialogflow relating to the current transcript + segment. + + Attributes: + smart_reply_allowlist_covered (bool): + Whether the transcript segment was covered + under the configured smart reply allowlist in + Agent Assist. + """ + + smart_reply_allowlist_covered = proto.Field( + proto.BOOL, + number=1, + ) + + message_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + text = proto.Field( + proto.STRING, + number=1, + ) + confidence = proto.Field( + proto.FLOAT, + number=2, + ) + words = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='Conversation.Transcript.TranscriptSegment.WordInfo', + ) + language_code = proto.Field( + proto.STRING, + number=4, + ) + channel_tag = proto.Field( + proto.INT32, + number=5, + ) + segment_participant = proto.Field( + proto.MESSAGE, + number=9, + message='ConversationParticipant', + ) + dialogflow_segment_metadata = proto.Field( + proto.MESSAGE, + number=10, + message='Conversation.Transcript.TranscriptSegment.DialogflowSegmentMetadata', + ) + sentiment = proto.Field( + proto.MESSAGE, + number=11, + message='SentimentData', + ) + + transcript_segments = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='Conversation.Transcript.TranscriptSegment', + ) + + call_metadata = proto.Field( + proto.MESSAGE, + number=7, + oneof='metadata', + message=CallMetadata, + ) + expire_time = proto.Field( + proto.MESSAGE, + number=15, + oneof='expiration', + message=timestamp_pb2.Timestamp, + ) + ttl = proto.Field( + proto.MESSAGE, + number=16, + oneof='expiration', + message=duration_pb2.Duration, + ) + name = proto.Field( + proto.STRING, + number=1, + ) + data_source = proto.Field( + proto.MESSAGE, + number=2, + message='ConversationDataSource', + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + start_time = proto.Field( + proto.MESSAGE, + number=17, + message=timestamp_pb2.Timestamp, + ) + language_code = proto.Field( + proto.STRING, + number=14, + ) + agent_id = proto.Field( + proto.STRING, + number=5, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=6, + ) + transcript = proto.Field( + proto.MESSAGE, + number=8, + message=Transcript, + ) + medium = proto.Field( + proto.ENUM, + number=9, + enum=Medium, + ) + duration = proto.Field( + proto.MESSAGE, + number=10, + message=duration_pb2.Duration, + ) + turn_count = proto.Field( + proto.INT32, + number=11, + ) + latest_analysis = proto.Field( + proto.MESSAGE, + number=12, + message='Analysis', + ) + runtime_annotations = proto.RepeatedField( + proto.MESSAGE, + number=13, + message='RuntimeAnnotation', + ) + dialogflow_intents = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=18, + message='DialogflowIntent', + ) + obfuscated_user_id = proto.Field( + proto.STRING, + number=21, + ) + + +class Analysis(proto.Message): + r"""The analysis resource. + + Attributes: + name (str): + Immutable. The resource name of the analysis. + Format: + projects/{project}/locations/{location}/conversations/{conversation}/analyses/{analysis} + request_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the analysis + was requested. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the analysis + was created, which occurs when the long-running + operation completes. + analysis_result (google.cloud.contact_center_insights_v1.types.AnalysisResult): + Output only. The result of the analysis, + which is populated when the analysis finishes. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + analysis_result = proto.Field( + proto.MESSAGE, + number=7, + message='AnalysisResult', + ) + + +class ConversationDataSource(proto.Message): + r"""The conversation source, which is a combination of transcript + and audio. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + gcs_source (google.cloud.contact_center_insights_v1.types.GcsSource): + A Cloud Storage location specification for + the audio and transcript. + + This field is a member of `oneof`_ ``source``. + dialogflow_source (google.cloud.contact_center_insights_v1.types.DialogflowSource): + The source when the conversation comes from + Dialogflow. + + This field is a member of `oneof`_ ``source``. + """ + + gcs_source = proto.Field( + proto.MESSAGE, + number=1, + oneof='source', + message='GcsSource', + ) + dialogflow_source = proto.Field( + proto.MESSAGE, + number=3, + oneof='source', + message='DialogflowSource', + ) + + +class GcsSource(proto.Message): + r"""A Cloud Storage source of conversation data. + + Attributes: + audio_uri (str): + Cloud Storage URI that points to a file that + contains the conversation audio. + transcript_uri (str): + Immutable. Cloud Storage URI that points to a + file that contains the conversation transcript. + """ + + audio_uri = proto.Field( + proto.STRING, + number=1, + ) + transcript_uri = proto.Field( + proto.STRING, + number=2, + ) + + +class DialogflowSource(proto.Message): + r"""A Dialogflow source of conversation data. + + Attributes: + dialogflow_conversation (str): + Output only. The name of the Dialogflow + conversation that this conversation resource is + derived from. Format: + projects/{project}/locations/{location}/conversations/{conversation} + audio_uri (str): + Cloud Storage URI that points to a file that + contains the conversation audio. + """ + + dialogflow_conversation = proto.Field( + proto.STRING, + number=1, + ) + audio_uri = proto.Field( + proto.STRING, + number=3, + ) + + +class AnalysisResult(proto.Message): + r"""The result of an analysis. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + call_analysis_metadata (google.cloud.contact_center_insights_v1.types.AnalysisResult.CallAnalysisMetadata): + Call-specific metadata created by the + analysis. + + This field is a member of `oneof`_ ``metadata``. + end_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which the analysis ended. + """ + + class CallAnalysisMetadata(proto.Message): + r"""Call-specific metadata created during analysis. + + Attributes: + annotations (Sequence[google.cloud.contact_center_insights_v1.types.CallAnnotation]): + A list of call annotations that apply to this + call. + entities (Sequence[google.cloud.contact_center_insights_v1.types.AnalysisResult.CallAnalysisMetadata.EntitiesEntry]): + All the entities in the call. + sentiments (Sequence[google.cloud.contact_center_insights_v1.types.ConversationLevelSentiment]): + Overall conversation-level sentiment for each + channel of the call. + intents (Sequence[google.cloud.contact_center_insights_v1.types.AnalysisResult.CallAnalysisMetadata.IntentsEntry]): + All the matched intents in the call. + phrase_matchers (Sequence[google.cloud.contact_center_insights_v1.types.AnalysisResult.CallAnalysisMetadata.PhraseMatchersEntry]): + All the matched phrase matchers in the call. + issue_model_result (google.cloud.contact_center_insights_v1.types.IssueModelResult): + Overall conversation-level issue modeling + result. + """ + + annotations = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='CallAnnotation', + ) + entities = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=3, + message='Entity', + ) + sentiments = proto.RepeatedField( + proto.MESSAGE, + number=4, + message='ConversationLevelSentiment', + ) + intents = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=6, + message='Intent', + ) + phrase_matchers = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=7, + message='PhraseMatchData', + ) + issue_model_result = proto.Field( + proto.MESSAGE, + number=8, + message='IssueModelResult', + ) + + call_analysis_metadata = proto.Field( + proto.MESSAGE, + number=2, + oneof='metadata', + message=CallAnalysisMetadata, + ) + end_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + + +class IssueModelResult(proto.Message): + r"""Issue Modeling result on a conversation. + + Attributes: + issue_model (str): + Issue model that generates the result. Format: + projects/{project}/locations/{location}/issueModels/{issue_model} + issues (Sequence[google.cloud.contact_center_insights_v1.types.IssueAssignment]): + All the matched issues. + """ + + issue_model = proto.Field( + proto.STRING, + number=1, + ) + issues = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='IssueAssignment', + ) + + +class ConversationLevelSentiment(proto.Message): + r"""One channel of conversation-level sentiment data. + + Attributes: + channel_tag (int): + The channel of the audio that the data + applies to. + sentiment_data (google.cloud.contact_center_insights_v1.types.SentimentData): + Data specifying sentiment. + """ + + channel_tag = proto.Field( + proto.INT32, + number=1, + ) + sentiment_data = proto.Field( + proto.MESSAGE, + number=2, + message='SentimentData', + ) + + +class IssueAssignment(proto.Message): + r"""Information about the issue. + + Attributes: + issue (str): + Resource name of the assigned issue. + score (float): + Score indicating the likelihood of the issue assignment. + currently bounded on [0,1]. + display_name (str): + Immutable. Display name of the assigned + issue. This field is set at time of analyis and + immutable since then. + """ + + issue = proto.Field( + proto.STRING, + number=1, + ) + score = proto.Field( + proto.DOUBLE, + number=2, + ) + display_name = proto.Field( + proto.STRING, + number=3, + ) + + +class CallAnnotation(proto.Message): + r"""A piece of metadata that applies to a window of a call. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + interruption_data (google.cloud.contact_center_insights_v1.types.InterruptionData): + Data specifying an interruption. + + This field is a member of `oneof`_ ``data``. + sentiment_data (google.cloud.contact_center_insights_v1.types.SentimentData): + Data specifying sentiment. + + This field is a member of `oneof`_ ``data``. + silence_data (google.cloud.contact_center_insights_v1.types.SilenceData): + Data specifying silence. + + This field is a member of `oneof`_ ``data``. + hold_data (google.cloud.contact_center_insights_v1.types.HoldData): + Data specifying a hold. + + This field is a member of `oneof`_ ``data``. + entity_mention_data (google.cloud.contact_center_insights_v1.types.EntityMentionData): + Data specifying an entity mention. + + This field is a member of `oneof`_ ``data``. + intent_match_data (google.cloud.contact_center_insights_v1.types.IntentMatchData): + Data specifying an intent match. + + This field is a member of `oneof`_ ``data``. + phrase_match_data (google.cloud.contact_center_insights_v1.types.PhraseMatchData): + Data specifying a phrase match. + + This field is a member of `oneof`_ ``data``. + channel_tag (int): + The channel of the audio where the annotation + occurs. For single-channel audio, this field is + not populated. + annotation_start_boundary (google.cloud.contact_center_insights_v1.types.AnnotationBoundary): + The boundary in the conversation where the + annotation starts, inclusive. + annotation_end_boundary (google.cloud.contact_center_insights_v1.types.AnnotationBoundary): + The boundary in the conversation where the + annotation ends, inclusive. + """ + + interruption_data = proto.Field( + proto.MESSAGE, + number=10, + oneof='data', + message='InterruptionData', + ) + sentiment_data = proto.Field( + proto.MESSAGE, + number=11, + oneof='data', + message='SentimentData', + ) + silence_data = proto.Field( + proto.MESSAGE, + number=12, + oneof='data', + message='SilenceData', + ) + hold_data = proto.Field( + proto.MESSAGE, + number=13, + oneof='data', + message='HoldData', + ) + entity_mention_data = proto.Field( + proto.MESSAGE, + number=15, + oneof='data', + message='EntityMentionData', + ) + intent_match_data = proto.Field( + proto.MESSAGE, + number=16, + oneof='data', + message='IntentMatchData', + ) + phrase_match_data = proto.Field( + proto.MESSAGE, + number=17, + oneof='data', + message='PhraseMatchData', + ) + channel_tag = proto.Field( + proto.INT32, + number=1, + ) + annotation_start_boundary = proto.Field( + proto.MESSAGE, + number=4, + message='AnnotationBoundary', + ) + annotation_end_boundary = proto.Field( + proto.MESSAGE, + number=5, + message='AnnotationBoundary', + ) + + +class AnnotationBoundary(proto.Message): + r"""A point in a conversation that marks the start or the end of + an annotation. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + word_index (int): + The word index of this boundary with respect + to the first word in the transcript piece. This + index starts at zero. + + This field is a member of `oneof`_ ``detailed_boundary``. + transcript_index (int): + The index in the sequence of transcribed + pieces of the conversation where the boundary is + located. This index starts at zero. + """ + + word_index = proto.Field( + proto.INT32, + number=3, + oneof='detailed_boundary', + ) + transcript_index = proto.Field( + proto.INT32, + number=1, + ) + + +class Entity(proto.Message): + r"""The data for an entity annotation. + Represents a phrase in the conversation that is a known entity, + such as a person, an organization, or location. + + Attributes: + display_name (str): + The representative name for the entity. + type_ (google.cloud.contact_center_insights_v1.types.Entity.Type): + The entity type. + metadata (Sequence[google.cloud.contact_center_insights_v1.types.Entity.MetadataEntry]): + Metadata associated with the entity. + + For most entity types, the metadata is a Wikipedia URL + (``wikipedia_url``) and Knowledge Graph MID (``mid``), if + they are available. For the metadata associated with other + entity types, see the Type table below. + salience (float): + The salience score associated with the entity in the [0, + 1.0] range. + + The salience score for an entity provides information about + the importance or centrality of that entity to the entire + document text. Scores closer to 0 are less salient, while + scores closer to 1.0 are highly salient. + sentiment (google.cloud.contact_center_insights_v1.types.SentimentData): + The aggregate sentiment expressed for this + entity in the conversation. + """ + class Type(proto.Enum): + r"""The type of the entity. For most entity types, the associated + metadata is a Wikipedia URL (``wikipedia_url``) and Knowledge Graph + MID (``mid``). The table below lists the associated fields for + entities that have different metadata. + """ + TYPE_UNSPECIFIED = 0 + PERSON = 1 + LOCATION = 2 + ORGANIZATION = 3 + EVENT = 4 + WORK_OF_ART = 5 + CONSUMER_GOOD = 6 + OTHER = 7 + PHONE_NUMBER = 9 + ADDRESS = 10 + DATE = 11 + NUMBER = 12 + PRICE = 13 + + display_name = proto.Field( + proto.STRING, + number=1, + ) + type_ = proto.Field( + proto.ENUM, + number=2, + enum=Type, + ) + metadata = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) + salience = proto.Field( + proto.FLOAT, + number=4, + ) + sentiment = proto.Field( + proto.MESSAGE, + number=5, + message='SentimentData', + ) + + +class Intent(proto.Message): + r"""The data for an intent. Represents a detected intent in the + conversation, for example MAKES_PROMISE. + + Attributes: + id (str): + The unique identifier of the intent. + display_name (str): + The human-readable name of the intent. + """ + + id = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + + +class PhraseMatchData(proto.Message): + r"""The data for a matched phrase matcher. + Represents information identifying a phrase matcher for a given + match. + + Attributes: + phrase_matcher (str): + The unique identifier (the resource name) of + the phrase matcher. + display_name (str): + The human-readable name of the phrase + matcher. + """ + + phrase_matcher = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + + +class DialogflowIntent(proto.Message): + r"""The data for a Dialogflow intent. Represents a detected intent in + the conversation, e.g. MAKES_PROMISE. + + Attributes: + display_name (str): + The human-readable name of the intent. + """ + + display_name = proto.Field( + proto.STRING, + number=1, + ) + + +class InterruptionData(proto.Message): + r"""The data for an interruption annotation. + """ + + +class SilenceData(proto.Message): + r"""The data for a silence annotation. + """ + + +class HoldData(proto.Message): + r"""The data for a hold annotation. + """ + + +class EntityMentionData(proto.Message): + r"""The data for an entity mention annotation. This represents a mention + of an ``Entity`` in the conversation. + + Attributes: + entity_unique_id (str): + The key of this entity in conversation entities. Can be used + to retrieve the exact ``Entity`` this mention is attached + to. + type_ (google.cloud.contact_center_insights_v1.types.EntityMentionData.MentionType): + The type of the entity mention. + sentiment (google.cloud.contact_center_insights_v1.types.SentimentData): + Sentiment expressed for this mention of the + entity. + """ + class MentionType(proto.Enum): + r"""The supported types of mentions.""" + MENTION_TYPE_UNSPECIFIED = 0 + PROPER = 1 + COMMON = 2 + + entity_unique_id = proto.Field( + proto.STRING, + number=1, + ) + type_ = proto.Field( + proto.ENUM, + number=2, + enum=MentionType, + ) + sentiment = proto.Field( + proto.MESSAGE, + number=3, + message='SentimentData', + ) + + +class IntentMatchData(proto.Message): + r"""The data for an intent match. + Represents an intent match for a text segment in the + conversation. A text segment can be part of a sentence, a + complete sentence, or an utterance with multiple sentences. + + Attributes: + intent_unique_id (str): + The id of the matched intent. + Can be used to retrieve the corresponding intent + information. + """ + + intent_unique_id = proto.Field( + proto.STRING, + number=1, + ) + + +class SentimentData(proto.Message): + r"""The data for a sentiment annotation. + + Attributes: + magnitude (float): + A non-negative number from 0 to infinity + which represents the abolute magnitude of + sentiment regardless of score. + score (float): + The sentiment score between -1.0 (negative) + and 1.0 (positive). + """ + + magnitude = proto.Field( + proto.FLOAT, + number=1, + ) + score = proto.Field( + proto.FLOAT, + number=2, + ) + + +class IssueModel(proto.Message): + r"""The issue model resource. + + Attributes: + name (str): + Immutable. The resource name of the issue model. Format: + projects/{project}/locations/{location}/issueModels/{issue_model} + display_name (str): + The representative name for the issue model. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this issue + model was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + the issue model was updated. + state (google.cloud.contact_center_insights_v1.types.IssueModel.State): + Output only. State of the model. + input_data_config (google.cloud.contact_center_insights_v1.types.IssueModel.InputDataConfig): + Configs for the input data that used to + create the issue model. + training_stats (google.cloud.contact_center_insights_v1.types.IssueModelLabelStats): + Output only. Immutable. The issue model's + label statistics on its training data. + """ + class State(proto.Enum): + r"""State of the model.""" + STATE_UNSPECIFIED = 0 + UNDEPLOYED = 1 + DEPLOYING = 2 + DEPLOYED = 3 + UNDEPLOYING = 4 + DELETING = 5 + + class InputDataConfig(proto.Message): + r"""Configs for the input data used to create the issue model. + + Attributes: + medium (google.cloud.contact_center_insights_v1.types.Conversation.Medium): + Medium of conversations used in training data. This field is + being deprecated. To specify the medium to be used in + training a new issue model, set the ``medium`` field on + ``filter``. + training_conversations_count (int): + Output only. Number of conversations used in + training. Output only. + filter (str): + A filter to reduce the conversations used for + training the model to a specific subset. + """ + + medium = proto.Field( + proto.ENUM, + number=1, + enum='Conversation.Medium', + ) + training_conversations_count = proto.Field( + proto.INT64, + number=2, + ) + filter = proto.Field( + proto.STRING, + number=3, + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + state = proto.Field( + proto.ENUM, + number=5, + enum=State, + ) + input_data_config = proto.Field( + proto.MESSAGE, + number=6, + message=InputDataConfig, + ) + training_stats = proto.Field( + proto.MESSAGE, + number=7, + message='IssueModelLabelStats', + ) + + +class Issue(proto.Message): + r"""The issue resource. + + Attributes: + name (str): + Immutable. The resource name of the issue. Format: + projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue} + display_name (str): + The representative name for the issue. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this issue was + created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time that this + issue was updated. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + + +class IssueModelLabelStats(proto.Message): + r"""Aggregated statistics about an issue model. + + Attributes: + analyzed_conversations_count (int): + Number of conversations the issue model has + analyzed at this point in time. + unclassified_conversations_count (int): + Number of analyzed conversations for which no + issue was applicable at this point in time. + issue_stats (Sequence[google.cloud.contact_center_insights_v1.types.IssueModelLabelStats.IssueStatsEntry]): + Statistics on each issue. Key is the issue's + resource name. + """ + + class IssueStats(proto.Message): + r"""Aggregated statistics about an issue. + + Attributes: + issue (str): + Issue resource. Format: + projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue} + labeled_conversations_count (int): + Number of conversations attached to the issue + at this point in time. + display_name (str): + Display name of the issue. + """ + + issue = proto.Field( + proto.STRING, + number=1, + ) + labeled_conversations_count = proto.Field( + proto.INT64, + number=2, + ) + display_name = proto.Field( + proto.STRING, + number=3, + ) + + analyzed_conversations_count = proto.Field( + proto.INT64, + number=1, + ) + unclassified_conversations_count = proto.Field( + proto.INT64, + number=2, + ) + issue_stats = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=3, + message=IssueStats, + ) + + +class PhraseMatcher(proto.Message): + r"""The phrase matcher resource. + + Attributes: + name (str): + The resource name of the phrase matcher. Format: + projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher} + revision_id (str): + Output only. Immutable. The revision ID of + the phrase matcher. A new revision is committed + whenever the matcher is changed, except when it + is activated or deactivated. A server generated + random ID will be used. Example: + locations/global/phraseMatchers/my-first- + matcher@1234567 + version_tag (str): + The customized version tag to use for the phrase matcher. If + not specified, it will default to ``revision_id``. + revision_create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The timestamp of when the + revision was created. It is also the create time + when a new matcher is added. + display_name (str): + The human-readable name of the phrase + matcher. + type_ (google.cloud.contact_center_insights_v1.types.PhraseMatcher.PhraseMatcherType): + Required. The type of this phrase matcher. + active (bool): + Applies the phrase matcher only when it is + active. + phrase_match_rule_groups (Sequence[google.cloud.contact_center_insights_v1.types.PhraseMatchRuleGroup]): + A list of phase match rule groups that are + included in this matcher. + activation_update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + the activation status was updated. + role_match (google.cloud.contact_center_insights_v1.types.ConversationParticipant.Role): + The role whose utterances the phrase matcher should be + matched against. If the role is ROLE_UNSPECIFIED it will be + matched against any utterances in the transcript. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + the phrase matcher was updated. + """ + class PhraseMatcherType(proto.Enum): + r"""Specifies how to combine each phrase match rule group to + determine whether there is a match. + """ + PHRASE_MATCHER_TYPE_UNSPECIFIED = 0 + ALL_OF = 1 + ANY_OF = 2 + + name = proto.Field( + proto.STRING, + number=1, + ) + revision_id = proto.Field( + proto.STRING, + number=2, + ) + version_tag = proto.Field( + proto.STRING, + number=3, + ) + revision_create_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + display_name = proto.Field( + proto.STRING, + number=5, + ) + type_ = proto.Field( + proto.ENUM, + number=6, + enum=PhraseMatcherType, + ) + active = proto.Field( + proto.BOOL, + number=7, + ) + phrase_match_rule_groups = proto.RepeatedField( + proto.MESSAGE, + number=8, + message='PhraseMatchRuleGroup', + ) + activation_update_time = proto.Field( + proto.MESSAGE, + number=9, + message=timestamp_pb2.Timestamp, + ) + role_match = proto.Field( + proto.ENUM, + number=10, + enum='ConversationParticipant.Role', + ) + update_time = proto.Field( + proto.MESSAGE, + number=11, + message=timestamp_pb2.Timestamp, + ) + + +class PhraseMatchRuleGroup(proto.Message): + r"""A message representing a rule in the phrase matcher. + + Attributes: + type_ (google.cloud.contact_center_insights_v1.types.PhraseMatchRuleGroup.PhraseMatchRuleGroupType): + Required. The type of this phrase match rule + group. + phrase_match_rules (Sequence[google.cloud.contact_center_insights_v1.types.PhraseMatchRule]): + A list of phase match rules that are included + in this group. + """ + class PhraseMatchRuleGroupType(proto.Enum): + r"""Specifies how to combine each phrase match rule for whether + there is a match. + """ + PHRASE_MATCH_RULE_GROUP_TYPE_UNSPECIFIED = 0 + ALL_OF = 1 + ANY_OF = 2 + + type_ = proto.Field( + proto.ENUM, + number=1, + enum=PhraseMatchRuleGroupType, + ) + phrase_match_rules = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='PhraseMatchRule', + ) + + +class PhraseMatchRule(proto.Message): + r"""The data for a phrase match rule. + + Attributes: + query (str): + Required. The phrase to be matched. + negated (bool): + Specifies whether the phrase must be missing + from the transcript segment or present in the + transcript segment. + config (google.cloud.contact_center_insights_v1.types.PhraseMatchRuleConfig): + Provides additional information about the + rule that specifies how to apply the rule. + """ + + query = proto.Field( + proto.STRING, + number=1, + ) + negated = proto.Field( + proto.BOOL, + number=2, + ) + config = proto.Field( + proto.MESSAGE, + number=3, + message='PhraseMatchRuleConfig', + ) + + +class PhraseMatchRuleConfig(proto.Message): + r"""Configuration information of a phrase match rule. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + exact_match_config (google.cloud.contact_center_insights_v1.types.ExactMatchConfig): + The configuration for the exact match rule. + + This field is a member of `oneof`_ ``config``. + """ + + exact_match_config = proto.Field( + proto.MESSAGE, + number=1, + oneof='config', + message='ExactMatchConfig', + ) + + +class ExactMatchConfig(proto.Message): + r"""Exact match configuration. + + Attributes: + case_sensitive (bool): + Whether to consider case sensitivity when + performing an exact match. + """ + + case_sensitive = proto.Field( + proto.BOOL, + number=1, + ) + + +class Settings(proto.Message): + r"""The settings resource. + + Attributes: + name (str): + Immutable. The resource name of the settings + resource. Format: + projects/{project}/locations/{location}/settings + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the settings + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the settings + were last updated. + language_code (str): + A language code to be applied to each + transcript segment unless the segment already + specifies a language code. Language code + defaults to "en-US" if it is neither specified + on the segment nor here. + conversation_ttl (google.protobuf.duration_pb2.Duration): + The default TTL for newly-created + conversations. If a conversation has a specified + expiration, that value will be used instead. + Changing this value will not change the + expiration of existing conversations. + Conversations with no expire time persist until + they are deleted. + pubsub_notification_settings (Sequence[google.cloud.contact_center_insights_v1.types.Settings.PubsubNotificationSettingsEntry]): + A map that maps a notification trigger to a Pub/Sub topic. + Each time a specified trigger occurs, Insights will notify + the corresponding Pub/Sub topic. + + Keys are notification triggers. Supported keys are: + + - "all-triggers": Notify each time any of the supported + triggers occurs. + - "create-analysis": Notify each time an analysis is + created. + - "create-conversation": Notify each time a conversation is + created. + - "export-insights-data": Notify each time an export is + complete. + - "update-conversation": Notify each time a conversation is + updated via UpdateConversation. + + Values are Pub/Sub topics. The format of each Pub/Sub topic + is: projects/{project}/topics/{topic} + analysis_config (google.cloud.contact_center_insights_v1.types.Settings.AnalysisConfig): + Default analysis settings. + """ + + class AnalysisConfig(proto.Message): + r"""Default configuration when creating Analyses in Insights. + + Attributes: + runtime_integration_analysis_percentage (float): + Percentage of conversations created using Dialogflow runtime + integration to analyze automatically, between [0, 100]. + """ + + runtime_integration_analysis_percentage = proto.Field( + proto.DOUBLE, + number=1, + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + create_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + language_code = proto.Field( + proto.STRING, + number=4, + ) + conversation_ttl = proto.Field( + proto.MESSAGE, + number=5, + message=duration_pb2.Duration, + ) + pubsub_notification_settings = proto.MapField( + proto.STRING, + proto.STRING, + number=6, + ) + analysis_config = proto.Field( + proto.MESSAGE, + number=7, + message=AnalysisConfig, + ) + + +class RuntimeAnnotation(proto.Message): + r"""An annotation that was generated during the customer and + agent interaction. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + article_suggestion (google.cloud.contact_center_insights_v1.types.ArticleSuggestionData): + Agent Assist Article Suggestion data. + + This field is a member of `oneof`_ ``data``. + faq_answer (google.cloud.contact_center_insights_v1.types.FaqAnswerData): + Agent Assist FAQ answer data. + + This field is a member of `oneof`_ ``data``. + smart_reply (google.cloud.contact_center_insights_v1.types.SmartReplyData): + Agent Assist Smart Reply data. + + This field is a member of `oneof`_ ``data``. + smart_compose_suggestion (google.cloud.contact_center_insights_v1.types.SmartComposeSuggestionData): + Agent Assist Smart Compose suggestion data. + + This field is a member of `oneof`_ ``data``. + dialogflow_interaction (google.cloud.contact_center_insights_v1.types.DialogflowInteractionData): + Dialogflow interaction data. + + This field is a member of `oneof`_ ``data``. + annotation_id (str): + The unique identifier of the annotation. Format: + projects/{project}/locations/{location}/conversationDatasets/{dataset}/conversationDataItems/{data_item}/conversationAnnotations/{annotation} + create_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which this annotation was + created. + start_boundary (google.cloud.contact_center_insights_v1.types.AnnotationBoundary): + The boundary in the conversation where the + annotation starts, inclusive. + end_boundary (google.cloud.contact_center_insights_v1.types.AnnotationBoundary): + The boundary in the conversation where the + annotation ends, inclusive. + answer_feedback (google.cloud.contact_center_insights_v1.types.AnswerFeedback): + The feedback that the customer has about the answer in + ``data``. + """ + + article_suggestion = proto.Field( + proto.MESSAGE, + number=6, + oneof='data', + message='ArticleSuggestionData', + ) + faq_answer = proto.Field( + proto.MESSAGE, + number=7, + oneof='data', + message='FaqAnswerData', + ) + smart_reply = proto.Field( + proto.MESSAGE, + number=8, + oneof='data', + message='SmartReplyData', + ) + smart_compose_suggestion = proto.Field( + proto.MESSAGE, + number=9, + oneof='data', + message='SmartComposeSuggestionData', + ) + dialogflow_interaction = proto.Field( + proto.MESSAGE, + number=10, + oneof='data', + message='DialogflowInteractionData', + ) + annotation_id = proto.Field( + proto.STRING, + number=1, + ) + create_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + start_boundary = proto.Field( + proto.MESSAGE, + number=3, + message='AnnotationBoundary', + ) + end_boundary = proto.Field( + proto.MESSAGE, + number=4, + message='AnnotationBoundary', + ) + answer_feedback = proto.Field( + proto.MESSAGE, + number=5, + message='AnswerFeedback', + ) + + +class AnswerFeedback(proto.Message): + r"""The feedback that the customer has about a certain answer in + the conversation. + + Attributes: + correctness_level (google.cloud.contact_center_insights_v1.types.AnswerFeedback.CorrectnessLevel): + The correctness level of an answer. + clicked (bool): + Indicates whether an answer or item was + clicked by the human agent. + displayed (bool): + Indicates whether an answer or item was + displayed to the human agent in the agent + desktop UI. + """ + class CorrectnessLevel(proto.Enum): + r"""The correctness level of an answer.""" + CORRECTNESS_LEVEL_UNSPECIFIED = 0 + NOT_CORRECT = 1 + PARTIALLY_CORRECT = 2 + FULLY_CORRECT = 3 + + correctness_level = proto.Field( + proto.ENUM, + number=1, + enum=CorrectnessLevel, + ) + clicked = proto.Field( + proto.BOOL, + number=2, + ) + displayed = proto.Field( + proto.BOOL, + number=3, + ) + + +class ArticleSuggestionData(proto.Message): + r"""Agent Assist Article Suggestion data. + + Attributes: + title (str): + Article title. + uri (str): + Article URI. + confidence_score (float): + The system's confidence score that this + article is a good match for this conversation, + ranging from 0.0 (completely uncertain) to 1.0 + (completely certain). + metadata (Sequence[google.cloud.contact_center_insights_v1.types.ArticleSuggestionData.MetadataEntry]): + Map that contains metadata about the Article + Suggestion and the document that it originates + from. + query_record (str): + Name of the query record. Format: + projects/{project}/locations/{location}/queryRecords/{query_record} + source (str): + The knowledge document that this answer was extracted from. + Format: + projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} + """ + + title = proto.Field( + proto.STRING, + number=1, + ) + uri = proto.Field( + proto.STRING, + number=2, + ) + confidence_score = proto.Field( + proto.FLOAT, + number=3, + ) + metadata = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + query_record = proto.Field( + proto.STRING, + number=5, + ) + source = proto.Field( + proto.STRING, + number=6, + ) + + +class FaqAnswerData(proto.Message): + r"""Agent Assist frequently-asked-question answer data. + + Attributes: + answer (str): + The piece of text from the ``source`` knowledge base + document. + confidence_score (float): + The system's confidence score that this + answer is a good match for this conversation, + ranging from 0.0 (completely uncertain) to 1.0 + (completely certain). + question (str): + The corresponding FAQ question. + metadata (Sequence[google.cloud.contact_center_insights_v1.types.FaqAnswerData.MetadataEntry]): + Map that contains metadata about the FAQ + answer and the document that it originates from. + query_record (str): + Name of the query record. Format: + projects/{project}/locations/{location}/queryRecords/{query_record}. + source (str): + The knowledge document that this answer was extracted from. + Format: + projects/{project}/knowledgeBases/{knowledge_base}/documents/{document}. + """ + + answer = proto.Field( + proto.STRING, + number=1, + ) + confidence_score = proto.Field( + proto.FLOAT, + number=2, + ) + question = proto.Field( + proto.STRING, + number=3, + ) + metadata = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + query_record = proto.Field( + proto.STRING, + number=5, + ) + source = proto.Field( + proto.STRING, + number=6, + ) + + +class SmartReplyData(proto.Message): + r"""Agent Assist Smart Reply data. + + Attributes: + reply (str): + The content of the reply. + confidence_score (float): + The system's confidence score that this reply + is a good match for this conversation, ranging + from 0.0 (completely uncertain) to 1.0 + (completely certain). + metadata (Sequence[google.cloud.contact_center_insights_v1.types.SmartReplyData.MetadataEntry]): + Map that contains metadata about the Smart + Reply and the document from which it originates. + query_record (str): + Name of the query record. Format: + projects/{project}/locations/{location}/queryRecords/{query_record} + """ + + reply = proto.Field( + proto.STRING, + number=1, + ) + confidence_score = proto.Field( + proto.DOUBLE, + number=2, + ) + metadata = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) + query_record = proto.Field( + proto.STRING, + number=4, + ) + + +class SmartComposeSuggestionData(proto.Message): + r"""Agent Assist Smart Compose suggestion data. + + Attributes: + suggestion (str): + The content of the suggestion. + confidence_score (float): + The system's confidence score that this + suggestion is a good match for this + conversation, ranging from 0.0 (completely + uncertain) to 1.0 (completely certain). + metadata (Sequence[google.cloud.contact_center_insights_v1.types.SmartComposeSuggestionData.MetadataEntry]): + Map that contains metadata about the Smart + Compose suggestion and the document from which + it originates. + query_record (str): + Name of the query record. Format: + projects/{project}/locations/{location}/queryRecords/{query_record} + """ + + suggestion = proto.Field( + proto.STRING, + number=1, + ) + confidence_score = proto.Field( + proto.DOUBLE, + number=2, + ) + metadata = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) + query_record = proto.Field( + proto.STRING, + number=4, + ) + + +class DialogflowInteractionData(proto.Message): + r"""Dialogflow interaction data. + + Attributes: + dialogflow_intent_id (str): + The Dialogflow intent resource path. Format: + projects/{project}/agent/{agent}/intents/{intent} + confidence (float): + The confidence of the match ranging from 0.0 + (completely uncertain) to 1.0 (completely + certain). + """ + + dialogflow_intent_id = proto.Field( + proto.STRING, + number=1, + ) + confidence = proto.Field( + proto.FLOAT, + number=2, + ) + + +class ConversationParticipant(proto.Message): + r"""The call participant speaking for a given utterance. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + dialogflow_participant_name (str): + The name of the participant provided by + Dialogflow. Format: + projects/{project}/locations/{location}/conversations/{conversation}/participants/{participant} + + This field is a member of `oneof`_ ``participant``. + user_id (str): + A user-specified ID representing the + participant. + + This field is a member of `oneof`_ ``participant``. + dialogflow_participant (str): + Deprecated. Use ``dialogflow_participant_name`` instead. The + name of the Dialogflow participant. Format: + projects/{project}/locations/{location}/conversations/{conversation}/participants/{participant} + obfuscated_external_user_id (str): + Obfuscated user ID from Dialogflow. + role (google.cloud.contact_center_insights_v1.types.ConversationParticipant.Role): + The role of the participant. + """ + class Role(proto.Enum): + r"""The role of the participant.""" + ROLE_UNSPECIFIED = 0 + HUMAN_AGENT = 1 + AUTOMATED_AGENT = 2 + END_USER = 3 + ANY_AGENT = 4 + + dialogflow_participant_name = proto.Field( + proto.STRING, + number=5, + oneof='participant', + ) + user_id = proto.Field( + proto.STRING, + number=6, + oneof='participant', + ) + dialogflow_participant = proto.Field( + proto.STRING, + number=1, + ) + obfuscated_external_user_id = proto.Field( + proto.STRING, + number=3, + ) + role = proto.Field( + proto.ENUM, + number=2, + enum=Role, + ) + + +class View(proto.Message): + r"""The View resource. + + Attributes: + name (str): + Immutable. The resource name of the view. + Format: + projects/{project}/locations/{location}/views/{view} + display_name (str): + The human-readable display name of the view. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this view was + created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + the view was updated. + value (str): + String with specific view properties. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + value = proto.Field( + proto.STRING, + number=5, + ) + + +__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..bbfce4b --- /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', '3.10']) +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/contact_center_insights_v1/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python='3.9') +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', '3.8', '3.9']) +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.9') +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_contact_center_insights_v1_keywords.py b/owl-bot-staging/v1/scripts/fixup_contact_center_insights_v1_keywords.py new file mode 100644 index 0000000..85bfa34 --- /dev/null +++ b/owl-bot-staging/v1/scripts/fixup_contact_center_insights_v1_keywords.py @@ -0,0 +1,209 @@ +#! /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 contact_center_insightsCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'calculate_issue_model_stats': ('issue_model', ), + 'calculate_stats': ('location', 'filter', ), + 'create_analysis': ('parent', 'analysis', ), + 'create_conversation': ('parent', 'conversation', 'conversation_id', ), + 'create_issue_model': ('parent', 'issue_model', ), + 'create_phrase_matcher': ('parent', 'phrase_matcher', ), + 'create_view': ('parent', 'view', ), + 'delete_analysis': ('name', ), + 'delete_conversation': ('name', 'force', ), + 'delete_issue_model': ('name', ), + 'delete_phrase_matcher': ('name', ), + 'delete_view': ('name', ), + 'deploy_issue_model': ('name', ), + 'export_insights_data': ('parent', 'big_query_destination', 'filter', 'kms_key', 'write_disposition', ), + 'get_analysis': ('name', ), + 'get_conversation': ('name', 'view', ), + 'get_issue': ('name', ), + 'get_issue_model': ('name', ), + 'get_phrase_matcher': ('name', ), + 'get_settings': ('name', ), + 'get_view': ('name', ), + 'list_analyses': ('parent', 'page_size', 'page_token', 'filter', ), + 'list_conversations': ('parent', 'page_size', 'page_token', 'filter', 'view', ), + 'list_issue_models': ('parent', ), + 'list_issues': ('parent', ), + 'list_phrase_matchers': ('parent', 'page_size', 'page_token', 'filter', ), + 'list_views': ('parent', 'page_size', 'page_token', ), + 'undeploy_issue_model': ('name', ), + 'update_conversation': ('conversation', 'update_mask', ), + 'update_issue': ('issue', 'update_mask', ), + 'update_issue_model': ('issue_model', 'update_mask', ), + 'update_phrase_matcher': ('phrase_matcher', 'update_mask', ), + 'update_settings': ('settings', 'update_mask', ), + 'update_view': ('view', '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=contact_center_insightsCallTransformer(), +): + """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 contact_center_insights 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..9cbdeac --- /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-contact-center-insights', + 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.28.0, < 3.0.0dev', + 'libcst >= 0.2.5', + 'proto-plus >= 1.19.7', + ), + 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/contact_center_insights_v1/__init__.py b/owl-bot-staging/v1/tests/unit/gapic/contact_center_insights_v1/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/contact_center_insights_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/contact_center_insights_v1/test_contact_center_insights.py b/owl-bot-staging/v1/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py new file mode 100644 index 0000000..a3a0c1e --- /dev/null +++ b/owl-bot-staging/v1/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py @@ -0,0 +1,10155 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 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.contact_center_insights_v1.services.contact_center_insights import ContactCenterInsightsAsyncClient +from google.cloud.contact_center_insights_v1.services.contact_center_insights import ContactCenterInsightsClient +from google.cloud.contact_center_insights_v1.services.contact_center_insights import pagers +from google.cloud.contact_center_insights_v1.services.contact_center_insights import transports +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert ContactCenterInsightsClient._get_default_mtls_endpoint(None) is None + assert ContactCenterInsightsClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert ContactCenterInsightsClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert ContactCenterInsightsClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert ContactCenterInsightsClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert ContactCenterInsightsClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class", [ + ContactCenterInsightsClient, + ContactCenterInsightsAsyncClient, +]) +def test_contact_center_insights_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 == 'contactcenterinsights.googleapis.com:443' + + +@pytest.mark.parametrize("transport_class,transport_name", [ + (transports.ContactCenterInsightsGrpcTransport, "grpc"), + (transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_contact_center_insights_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", [ + ContactCenterInsightsClient, + ContactCenterInsightsAsyncClient, +]) +def test_contact_center_insights_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 == 'contactcenterinsights.googleapis.com:443' + + +def test_contact_center_insights_client_get_transport_class(): + transport = ContactCenterInsightsClient.get_transport_class() + available_transports = [ + transports.ContactCenterInsightsGrpcTransport, + ] + assert transport in available_transports + + transport = ContactCenterInsightsClient.get_transport_class("grpc") + assert transport == transports.ContactCenterInsightsGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc"), + (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(ContactCenterInsightsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsClient)) +@mock.patch.object(ContactCenterInsightsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsAsyncClient)) +def test_contact_center_insights_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(ContactCenterInsightsClient, '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(ContactCenterInsightsClient, 'get_transport_class') as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name, client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class(transport=transport_name) + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class(transport=transport_name) + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc", "true"), + (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc", "false"), + (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(ContactCenterInsightsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsClient)) +@mock.patch.object(ContactCenterInsightsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_contact_center_insights_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc"), + (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_contact_center_insights_client_client_options_scopes(client_class, transport_class, transport_name): + # Check the case scopes are provided. + options = client_options.ClientOptions( + scopes=["1", "2"], + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc"), + (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_contact_center_insights_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, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + +def test_contact_center_insights_client_client_options_from_dict(): + with mock.patch('google.cloud.contact_center_insights_v1.services.contact_center_insights.transports.ContactCenterInsightsGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = ContactCenterInsightsClient( + 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, + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreateConversationRequest, + dict, +]) +def test_create_conversation(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + call_metadata=resources.Conversation.CallMetadata(customer_channel=1706), + expire_time=timestamp_pb2.Timestamp(seconds=751), + ) + response = client.create_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +def test_create_conversation_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_conversation), + '__call__') as call: + client.create_conversation() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateConversationRequest() + + +@pytest.mark.asyncio +async def test_create_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreateConversationRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + )) + response = await client.create_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +@pytest.mark.asyncio +async def test_create_conversation_async_from_dict(): + await test_create_conversation_async(request_type=dict) + + +def test_create_conversation_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateConversationRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), + '__call__') as call: + call.return_value = resources.Conversation() + client.create_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_conversation_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateConversationRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) + await client.create_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_conversation_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_conversation( + parent='parent_value', + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + conversation_id='conversation_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].conversation + mock_val = resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)) + assert arg == mock_val + arg = args[0].conversation_id + mock_val = 'conversation_id_value' + assert arg == mock_val + + +def test_create_conversation_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_conversation( + contact_center_insights.CreateConversationRequest(), + parent='parent_value', + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + conversation_id='conversation_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_conversation_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_conversation( + parent='parent_value', + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + conversation_id='conversation_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].conversation + mock_val = resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)) + assert arg == mock_val + arg = args[0].conversation_id + mock_val = 'conversation_id_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_conversation_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_conversation( + contact_center_insights.CreateConversationRequest(), + parent='parent_value', + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + conversation_id='conversation_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateConversationRequest, + dict, +]) +def test_update_conversation(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + call_metadata=resources.Conversation.CallMetadata(customer_channel=1706), + expire_time=timestamp_pb2.Timestamp(seconds=751), + ) + response = client.update_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +def test_update_conversation_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_conversation), + '__call__') as call: + client.update_conversation() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateConversationRequest() + + +@pytest.mark.asyncio +async def test_update_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateConversationRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + )) + response = await client.update_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +@pytest.mark.asyncio +async def test_update_conversation_async_from_dict(): + await test_update_conversation_async(request_type=dict) + + +def test_update_conversation_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateConversationRequest() + + request.conversation.name = 'conversation.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), + '__call__') as call: + call.return_value = resources.Conversation() + client.update_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'conversation.name=conversation.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_conversation_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateConversationRequest() + + request.conversation.name = 'conversation.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) + await client.update_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'conversation.name=conversation.name/value', + ) in kw['metadata'] + + +def test_update_conversation_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_conversation( + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].conversation + mock_val = resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)) + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_conversation_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_conversation( + contact_center_insights.UpdateConversationRequest(), + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_conversation_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_conversation( + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].conversation + mock_val = resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)) + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_conversation_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_conversation( + contact_center_insights.UpdateConversationRequest(), + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetConversationRequest, + dict, +]) +def test_get_conversation(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + call_metadata=resources.Conversation.CallMetadata(customer_channel=1706), + expire_time=timestamp_pb2.Timestamp(seconds=751), + ) + response = client.get_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +def test_get_conversation_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_conversation), + '__call__') as call: + client.get_conversation() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetConversationRequest() + + +@pytest.mark.asyncio +async def test_get_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetConversationRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + )) + response = await client.get_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +@pytest.mark.asyncio +async def test_get_conversation_async_from_dict(): + await test_get_conversation_async(request_type=dict) + + +def test_get_conversation_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetConversationRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversation), + '__call__') as call: + call.return_value = resources.Conversation() + client.get_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_conversation_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetConversationRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversation), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) + await client.get_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_conversation_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_conversation( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_conversation_flattened_error(): + client = ContactCenterInsightsClient( + 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_conversation( + contact_center_insights.GetConversationRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_conversation_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_conversation( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_conversation_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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_conversation( + contact_center_insights.GetConversationRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListConversationsRequest, + dict, +]) +def test_list_conversations(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListConversationsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListConversationsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListConversationsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_conversations_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_conversations), + '__call__') as call: + client.list_conversations() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListConversationsRequest() + + +@pytest.mark.asyncio +async def test_list_conversations_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListConversationsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListConversationsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListConversationsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListConversationsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_conversations_async_from_dict(): + await test_list_conversations_async(request_type=dict) + + +def test_list_conversations_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListConversationsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + call.return_value = contact_center_insights.ListConversationsResponse() + client.list_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_conversations_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListConversationsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListConversationsResponse()) + await client.list_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_conversations_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListConversationsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_conversations( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_conversations_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_conversations( + contact_center_insights.ListConversationsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_conversations_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListConversationsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListConversationsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_conversations( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_conversations_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_conversations( + contact_center_insights.ListConversationsRequest(), + parent='parent_value', + ) + + +def test_list_conversations_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + resources.Conversation(), + ], + next_page_token='abc', + ), + contact_center_insights.ListConversationsResponse( + conversations=[], + next_page_token='def', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_conversations(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.Conversation) + for i in results) +def test_list_conversations_pages(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + resources.Conversation(), + ], + next_page_token='abc', + ), + contact_center_insights.ListConversationsResponse( + conversations=[], + next_page_token='def', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + ], + ), + RuntimeError, + ) + pages = list(client.list_conversations(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_conversations_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + resources.Conversation(), + ], + next_page_token='abc', + ), + contact_center_insights.ListConversationsResponse( + conversations=[], + next_page_token='def', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_conversations(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.Conversation) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_conversations_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + resources.Conversation(), + ], + next_page_token='abc', + ), + contact_center_insights.ListConversationsResponse( + conversations=[], + next_page_token='def', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_conversations(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteConversationRequest, + dict, +]) +def test_delete_conversation(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteConversationRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_conversation_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_conversation), + '__call__') as call: + client.delete_conversation() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteConversationRequest() + + +@pytest.mark.asyncio +async def test_delete_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteConversationRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteConversationRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_conversation_async_from_dict(): + await test_delete_conversation_async(request_type=dict) + + +def test_delete_conversation_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteConversationRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), + '__call__') as call: + call.return_value = None + client.delete_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_conversation_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteConversationRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_conversation_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), + '__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_conversation( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_conversation_flattened_error(): + client = ContactCenterInsightsClient( + 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_conversation( + contact_center_insights.DeleteConversationRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_conversation_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), + '__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_conversation( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_conversation_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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_conversation( + contact_center_insights.DeleteConversationRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreateAnalysisRequest, + dict, +]) +def test_create_analysis(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateAnalysisRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_analysis_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_analysis), + '__call__') as call: + client.create_analysis() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateAnalysisRequest() + + +@pytest.mark.asyncio +async def test_create_analysis_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreateAnalysisRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_analysis), + '__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_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateAnalysisRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_analysis_async_from_dict(): + await test_create_analysis_async(request_type=dict) + + +def test_create_analysis_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateAnalysisRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_analysis_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateAnalysisRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_analysis_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_analysis( + parent='parent_value', + analysis=resources.Analysis(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].analysis + mock_val = resources.Analysis(name='name_value') + assert arg == mock_val + + +def test_create_analysis_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_analysis( + contact_center_insights.CreateAnalysisRequest(), + parent='parent_value', + analysis=resources.Analysis(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_analysis_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_analysis( + parent='parent_value', + analysis=resources.Analysis(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].analysis + mock_val = resources.Analysis(name='name_value') + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_analysis_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_analysis( + contact_center_insights.CreateAnalysisRequest(), + parent='parent_value', + analysis=resources.Analysis(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetAnalysisRequest, + dict, +]) +def test_get_analysis(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Analysis( + name='name_value', + ) + response = client.get_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetAnalysisRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Analysis) + assert response.name == 'name_value' + + +def test_get_analysis_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_analysis), + '__call__') as call: + client.get_analysis() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetAnalysisRequest() + + +@pytest.mark.asyncio +async def test_get_analysis_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetAnalysisRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Analysis( + name='name_value', + )) + response = await client.get_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetAnalysisRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Analysis) + assert response.name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_analysis_async_from_dict(): + await test_get_analysis_async(request_type=dict) + + +def test_get_analysis_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetAnalysisRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis), + '__call__') as call: + call.return_value = resources.Analysis() + client.get_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_analysis_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetAnalysisRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Analysis()) + await client.get_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_analysis_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Analysis() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_analysis( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_analysis_flattened_error(): + client = ContactCenterInsightsClient( + 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_analysis( + contact_center_insights.GetAnalysisRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_analysis_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Analysis() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Analysis()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_analysis( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_analysis_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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_analysis( + contact_center_insights.GetAnalysisRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListAnalysesRequest, + dict, +]) +def test_list_analyses(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_analyses), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListAnalysesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_analyses(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListAnalysesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAnalysesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_analyses_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_analyses), + '__call__') as call: + client.list_analyses() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListAnalysesRequest() + + +@pytest.mark.asyncio +async def test_list_analyses_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListAnalysesRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_analyses), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListAnalysesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_analyses(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListAnalysesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAnalysesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_analyses_async_from_dict(): + await test_list_analyses_async(request_type=dict) + + +def test_list_analyses_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListAnalysesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + call.return_value = contact_center_insights.ListAnalysesResponse() + client.list_analyses(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_analyses_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListAnalysesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListAnalysesResponse()) + await client.list_analyses(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_analyses_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListAnalysesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_analyses( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_analyses_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_analyses( + contact_center_insights.ListAnalysesRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_analyses_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListAnalysesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListAnalysesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_analyses( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_analyses_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_analyses( + contact_center_insights.ListAnalysesRequest(), + parent='parent_value', + ) + + +def test_list_analyses_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + resources.Analysis(), + ], + next_page_token='abc', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[], + next_page_token='def', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_analyses(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.Analysis) + for i in results) +def test_list_analyses_pages(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + resources.Analysis(), + ], + next_page_token='abc', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[], + next_page_token='def', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + ], + ), + RuntimeError, + ) + pages = list(client.list_analyses(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_analyses_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + resources.Analysis(), + ], + next_page_token='abc', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[], + next_page_token='def', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_analyses(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.Analysis) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_analyses_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + resources.Analysis(), + ], + next_page_token='abc', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[], + next_page_token='def', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_analyses(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteAnalysisRequest, + dict, +]) +def test_delete_analysis(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteAnalysisRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_analysis_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_analysis), + '__call__') as call: + client.delete_analysis() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteAnalysisRequest() + + +@pytest.mark.asyncio +async def test_delete_analysis_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteAnalysisRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteAnalysisRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_analysis_async_from_dict(): + await test_delete_analysis_async(request_type=dict) + + +def test_delete_analysis_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteAnalysisRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis), + '__call__') as call: + call.return_value = None + client.delete_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_analysis_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteAnalysisRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_analysis_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis), + '__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_analysis( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_analysis_flattened_error(): + client = ContactCenterInsightsClient( + 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_analysis( + contact_center_insights.DeleteAnalysisRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_analysis_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis), + '__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_analysis( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_analysis_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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_analysis( + contact_center_insights.DeleteAnalysisRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ExportInsightsDataRequest, + dict, +]) +def test_export_insights_data(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.export_insights_data(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ExportInsightsDataRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_export_insights_data_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + client.export_insights_data() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ExportInsightsDataRequest() + + +@pytest.mark.asyncio +async def test_export_insights_data_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ExportInsightsDataRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__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.export_insights_data(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ExportInsightsDataRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_export_insights_data_async_from_dict(): + await test_export_insights_data_async(request_type=dict) + + +def test_export_insights_data_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ExportInsightsDataRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.export_insights_data(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_export_insights_data_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ExportInsightsDataRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.export_insights_data(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_export_insights_data_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.export_insights_data( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_export_insights_data_flattened_error(): + client = ContactCenterInsightsClient( + 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.export_insights_data( + contact_center_insights.ExportInsightsDataRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_export_insights_data_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.export_insights_data( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_export_insights_data_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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.export_insights_data( + contact_center_insights.ExportInsightsDataRequest(), + parent='parent_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreateIssueModelRequest, + dict, +]) +def test_create_issue_model(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_issue_model), + '__call__') as call: + client.create_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateIssueModelRequest() + + +@pytest.mark.asyncio +async def test_create_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreateIssueModelRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue_model), + '__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_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_issue_model_async_from_dict(): + await test_create_issue_model_async(request_type=dict) + + +def test_create_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateIssueModelRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateIssueModelRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_issue_model( + parent='parent_value', + issue_model=resources.IssueModel(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].issue_model + mock_val = resources.IssueModel(name='name_value') + assert arg == mock_val + + +def test_create_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_issue_model( + contact_center_insights.CreateIssueModelRequest(), + parent='parent_value', + issue_model=resources.IssueModel(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_issue_model( + parent='parent_value', + issue_model=resources.IssueModel(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].issue_model + mock_val = resources.IssueModel(name='name_value') + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_issue_model( + contact_center_insights.CreateIssueModelRequest(), + parent='parent_value', + issue_model=resources.IssueModel(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateIssueModelRequest, + dict, +]) +def test_update_issue_model(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel( + name='name_value', + display_name='display_name_value', + state=resources.IssueModel.State.UNDEPLOYED, + ) + response = client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.state == resources.IssueModel.State.UNDEPLOYED + + +def test_update_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_issue_model), + '__call__') as call: + client.update_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueModelRequest() + + +@pytest.mark.asyncio +async def test_update_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateIssueModelRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel( + name='name_value', + display_name='display_name_value', + state=resources.IssueModel.State.UNDEPLOYED, + )) + response = await client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.state == resources.IssueModel.State.UNDEPLOYED + + +@pytest.mark.asyncio +async def test_update_issue_model_async_from_dict(): + await test_update_issue_model_async(request_type=dict) + + +def test_update_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateIssueModelRequest() + + request.issue_model.name = 'issue_model.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), + '__call__') as call: + call.return_value = resources.IssueModel() + client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'issue_model.name=issue_model.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateIssueModelRequest() + + request.issue_model.name = 'issue_model.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel()) + await client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'issue_model.name=issue_model.name/value', + ) in kw['metadata'] + + +def test_update_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_issue_model( + issue_model=resources.IssueModel(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].issue_model + mock_val = resources.IssueModel(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue_model( + contact_center_insights.UpdateIssueModelRequest(), + issue_model=resources.IssueModel(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_issue_model( + issue_model=resources.IssueModel(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].issue_model + mock_val = resources.IssueModel(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_issue_model( + contact_center_insights.UpdateIssueModelRequest(), + issue_model=resources.IssueModel(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetIssueModelRequest, + dict, +]) +def test_get_issue_model(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel( + name='name_value', + display_name='display_name_value', + state=resources.IssueModel.State.UNDEPLOYED, + ) + response = client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.state == resources.IssueModel.State.UNDEPLOYED + + +def test_get_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_issue_model), + '__call__') as call: + client.get_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueModelRequest() + + +@pytest.mark.asyncio +async def test_get_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetIssueModelRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel( + name='name_value', + display_name='display_name_value', + state=resources.IssueModel.State.UNDEPLOYED, + )) + response = await client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.state == resources.IssueModel.State.UNDEPLOYED + + +@pytest.mark.asyncio +async def test_get_issue_model_async_from_dict(): + await test_get_issue_model_async(request_type=dict) + + +def test_get_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetIssueModelRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_model), + '__call__') as call: + call.return_value = resources.IssueModel() + client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetIssueModelRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_model), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel()) + await client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + 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_issue_model( + contact_center_insights.GetIssueModelRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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_issue_model( + contact_center_insights.GetIssueModelRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListIssueModelsRequest, + dict, +]) +def test_list_issue_models(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue_models), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssueModelsResponse( + ) + response = client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssueModelsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssueModelsResponse) + + +def test_list_issue_models_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_issue_models), + '__call__') as call: + client.list_issue_models() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssueModelsRequest() + + +@pytest.mark.asyncio +async def test_list_issue_models_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListIssueModelsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue_models), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssueModelsResponse( + )) + response = await client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssueModelsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssueModelsResponse) + + +@pytest.mark.asyncio +async def test_list_issue_models_async_from_dict(): + await test_list_issue_models_async(request_type=dict) + + +def test_list_issue_models_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListIssueModelsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), + '__call__') as call: + call.return_value = contact_center_insights.ListIssueModelsResponse() + client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_issue_models_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListIssueModelsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssueModelsResponse()) + await client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_issue_models_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssueModelsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_issue_models( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_issue_models_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issue_models( + contact_center_insights.ListIssueModelsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_issue_models_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssueModelsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssueModelsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_issue_models( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_issue_models_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_issue_models( + contact_center_insights.ListIssueModelsRequest(), + parent='parent_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteIssueModelRequest, + dict, +]) +def test_delete_issue_model(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_issue_model), + '__call__') as call: + client.delete_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteIssueModelRequest() + + +@pytest.mark.asyncio +async def test_delete_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteIssueModelRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.delete_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_issue_model_async_from_dict(): + await test_delete_issue_model_async(request_type=dict) + + +def test_delete_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteIssueModelRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteIssueModelRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + 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_issue_model( + contact_center_insights.DeleteIssueModelRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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_issue_model( + contact_center_insights.DeleteIssueModelRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeployIssueModelRequest, + dict, +]) +def test_deploy_issue_model(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.deploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeployIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_deploy_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + client.deploy_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeployIssueModelRequest() + + +@pytest.mark.asyncio +async def test_deploy_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeployIssueModelRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__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.deploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeployIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_deploy_issue_model_async_from_dict(): + await test_deploy_issue_model_async(request_type=dict) + + +def test_deploy_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeployIssueModelRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.deploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_deploy_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeployIssueModelRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.deploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_deploy_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.deploy_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_deploy_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + 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.deploy_issue_model( + contact_center_insights.DeployIssueModelRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_deploy_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.deploy_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_deploy_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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.deploy_issue_model( + contact_center_insights.DeployIssueModelRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UndeployIssueModelRequest, + dict, +]) +def test_undeploy_issue_model(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.undeploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UndeployIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_undeploy_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + client.undeploy_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UndeployIssueModelRequest() + + +@pytest.mark.asyncio +async def test_undeploy_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UndeployIssueModelRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__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.undeploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UndeployIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_undeploy_issue_model_async_from_dict(): + await test_undeploy_issue_model_async(request_type=dict) + + +def test_undeploy_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UndeployIssueModelRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.undeploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_undeploy_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UndeployIssueModelRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.undeploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_undeploy_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.undeploy_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_undeploy_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + 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.undeploy_issue_model( + contact_center_insights.UndeployIssueModelRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_undeploy_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.undeploy_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_undeploy_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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.undeploy_issue_model( + contact_center_insights.UndeployIssueModelRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetIssueRequest, + dict, +]) +def test_get_issue(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue( + name='name_value', + display_name='display_name_value', + ) + response = client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + + +def test_get_issue_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_issue), + '__call__') as call: + client.get_issue() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueRequest() + + +@pytest.mark.asyncio +async def test_get_issue_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetIssueRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue( + name='name_value', + display_name='display_name_value', + )) + response = await client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_get_issue_async_from_dict(): + await test_get_issue_async(request_type=dict) + + +def test_get_issue_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetIssueRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue), + '__call__') as call: + call.return_value = resources.Issue() + client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_issue_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetIssueRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) + await client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_issue_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_issue( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_issue_flattened_error(): + client = ContactCenterInsightsClient( + 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_issue( + contact_center_insights.GetIssueRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_issue_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_issue( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_issue_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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_issue( + contact_center_insights.GetIssueRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListIssuesRequest, + dict, +]) +def test_list_issues(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issues), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssuesResponse( + ) + response = client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssuesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssuesResponse) + + +def test_list_issues_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_issues), + '__call__') as call: + client.list_issues() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssuesRequest() + + +@pytest.mark.asyncio +async def test_list_issues_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListIssuesRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issues), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssuesResponse( + )) + response = await client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssuesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssuesResponse) + + +@pytest.mark.asyncio +async def test_list_issues_async_from_dict(): + await test_list_issues_async(request_type=dict) + + +def test_list_issues_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListIssuesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), + '__call__') as call: + call.return_value = contact_center_insights.ListIssuesResponse() + client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_issues_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListIssuesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssuesResponse()) + await client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_issues_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssuesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_issues( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_issues_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issues( + contact_center_insights.ListIssuesRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_issues_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssuesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssuesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_issues( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_issues_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_issues( + contact_center_insights.ListIssuesRequest(), + parent='parent_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateIssueRequest, + dict, +]) +def test_update_issue(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue( + name='name_value', + display_name='display_name_value', + ) + response = client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + + +def test_update_issue_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_issue), + '__call__') as call: + client.update_issue() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueRequest() + + +@pytest.mark.asyncio +async def test_update_issue_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateIssueRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue( + name='name_value', + display_name='display_name_value', + )) + response = await client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_update_issue_async_from_dict(): + await test_update_issue_async(request_type=dict) + + +def test_update_issue_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateIssueRequest() + + request.issue.name = 'issue.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue), + '__call__') as call: + call.return_value = resources.Issue() + client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'issue.name=issue.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_issue_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateIssueRequest() + + request.issue.name = 'issue.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) + await client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'issue.name=issue.name/value', + ) in kw['metadata'] + + +def test_update_issue_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_issue( + issue=resources.Issue(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].issue + mock_val = resources.Issue(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_issue_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue( + contact_center_insights.UpdateIssueRequest(), + issue=resources.Issue(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_issue_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_issue( + issue=resources.Issue(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].issue + mock_val = resources.Issue(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_issue_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_issue( + contact_center_insights.UpdateIssueRequest(), + issue=resources.Issue(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CalculateIssueModelStatsRequest, + dict, +]) +def test_calculate_issue_model_stats(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.CalculateIssueModelStatsResponse( + ) + response = client.calculate_issue_model_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CalculateIssueModelStatsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.CalculateIssueModelStatsResponse) + + +def test_calculate_issue_model_stats_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + client.calculate_issue_model_stats() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CalculateIssueModelStatsRequest() + + +@pytest.mark.asyncio +async def test_calculate_issue_model_stats_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CalculateIssueModelStatsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateIssueModelStatsResponse( + )) + response = await client.calculate_issue_model_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CalculateIssueModelStatsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.CalculateIssueModelStatsResponse) + + +@pytest.mark.asyncio +async def test_calculate_issue_model_stats_async_from_dict(): + await test_calculate_issue_model_stats_async(request_type=dict) + + +def test_calculate_issue_model_stats_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CalculateIssueModelStatsRequest() + + request.issue_model = 'issue_model/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + call.return_value = contact_center_insights.CalculateIssueModelStatsResponse() + client.calculate_issue_model_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'issue_model=issue_model/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_calculate_issue_model_stats_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CalculateIssueModelStatsRequest() + + request.issue_model = 'issue_model/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateIssueModelStatsResponse()) + await client.calculate_issue_model_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'issue_model=issue_model/value', + ) in kw['metadata'] + + +def test_calculate_issue_model_stats_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.CalculateIssueModelStatsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.calculate_issue_model_stats( + issue_model='issue_model_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].issue_model + mock_val = 'issue_model_value' + assert arg == mock_val + + +def test_calculate_issue_model_stats_flattened_error(): + client = ContactCenterInsightsClient( + 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.calculate_issue_model_stats( + contact_center_insights.CalculateIssueModelStatsRequest(), + issue_model='issue_model_value', + ) + + +@pytest.mark.asyncio +async def test_calculate_issue_model_stats_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.CalculateIssueModelStatsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateIssueModelStatsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.calculate_issue_model_stats( + issue_model='issue_model_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].issue_model + mock_val = 'issue_model_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_calculate_issue_model_stats_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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.calculate_issue_model_stats( + contact_center_insights.CalculateIssueModelStatsRequest(), + issue_model='issue_model_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreatePhraseMatcherRequest, + dict, +]) +def test_create_phrase_matcher(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + response = client.create_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreatePhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +def test_create_phrase_matcher_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_phrase_matcher), + '__call__') as call: + client.create_phrase_matcher() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreatePhraseMatcherRequest() + + +@pytest.mark.asyncio +async def test_create_phrase_matcher_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreatePhraseMatcherRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + )) + response = await client.create_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreatePhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +@pytest.mark.asyncio +async def test_create_phrase_matcher_async_from_dict(): + await test_create_phrase_matcher_async(request_type=dict) + + +def test_create_phrase_matcher_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreatePhraseMatcherRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), + '__call__') as call: + call.return_value = resources.PhraseMatcher() + client.create_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_phrase_matcher_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreatePhraseMatcherRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) + await client.create_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_phrase_matcher_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_phrase_matcher( + parent='parent_value', + phrase_matcher=resources.PhraseMatcher(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].phrase_matcher + mock_val = resources.PhraseMatcher(name='name_value') + assert arg == mock_val + + +def test_create_phrase_matcher_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_phrase_matcher( + contact_center_insights.CreatePhraseMatcherRequest(), + parent='parent_value', + phrase_matcher=resources.PhraseMatcher(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_phrase_matcher_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_phrase_matcher( + parent='parent_value', + phrase_matcher=resources.PhraseMatcher(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].phrase_matcher + mock_val = resources.PhraseMatcher(name='name_value') + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_phrase_matcher_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_phrase_matcher( + contact_center_insights.CreatePhraseMatcherRequest(), + parent='parent_value', + phrase_matcher=resources.PhraseMatcher(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetPhraseMatcherRequest, + dict, +]) +def test_get_phrase_matcher(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + response = client.get_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetPhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +def test_get_phrase_matcher_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_phrase_matcher), + '__call__') as call: + client.get_phrase_matcher() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetPhraseMatcherRequest() + + +@pytest.mark.asyncio +async def test_get_phrase_matcher_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetPhraseMatcherRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + )) + response = await client.get_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetPhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +@pytest.mark.asyncio +async def test_get_phrase_matcher_async_from_dict(): + await test_get_phrase_matcher_async(request_type=dict) + + +def test_get_phrase_matcher_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetPhraseMatcherRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), + '__call__') as call: + call.return_value = resources.PhraseMatcher() + client.get_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_phrase_matcher_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetPhraseMatcherRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) + await client.get_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_phrase_matcher_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_phrase_matcher( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_phrase_matcher_flattened_error(): + client = ContactCenterInsightsClient( + 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_phrase_matcher( + contact_center_insights.GetPhraseMatcherRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_phrase_matcher_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_phrase_matcher( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_phrase_matcher_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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_phrase_matcher( + contact_center_insights.GetPhraseMatcherRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListPhraseMatchersRequest, + dict, +]) +def test_list_phrase_matchers(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_phrase_matchers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListPhraseMatchersResponse( + next_page_token='next_page_token_value', + ) + response = client.list_phrase_matchers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListPhraseMatchersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPhraseMatchersPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_phrase_matchers_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_phrase_matchers), + '__call__') as call: + client.list_phrase_matchers() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListPhraseMatchersRequest() + + +@pytest.mark.asyncio +async def test_list_phrase_matchers_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListPhraseMatchersRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_phrase_matchers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListPhraseMatchersResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_phrase_matchers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListPhraseMatchersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPhraseMatchersAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_phrase_matchers_async_from_dict(): + await test_list_phrase_matchers_async(request_type=dict) + + +def test_list_phrase_matchers_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListPhraseMatchersRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + call.return_value = contact_center_insights.ListPhraseMatchersResponse() + client.list_phrase_matchers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_phrase_matchers_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListPhraseMatchersRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListPhraseMatchersResponse()) + await client.list_phrase_matchers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_phrase_matchers_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListPhraseMatchersResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_phrase_matchers( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_phrase_matchers_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_phrase_matchers( + contact_center_insights.ListPhraseMatchersRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_phrase_matchers_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListPhraseMatchersResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListPhraseMatchersResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_phrase_matchers( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_phrase_matchers_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_phrase_matchers( + contact_center_insights.ListPhraseMatchersRequest(), + parent='parent_value', + ) + + +def test_list_phrase_matchers_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + next_page_token='abc', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[], + next_page_token='def', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_phrase_matchers(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.PhraseMatcher) + for i in results) +def test_list_phrase_matchers_pages(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + next_page_token='abc', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[], + next_page_token='def', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + ), + RuntimeError, + ) + pages = list(client.list_phrase_matchers(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_phrase_matchers_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + next_page_token='abc', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[], + next_page_token='def', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_phrase_matchers(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.PhraseMatcher) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_phrase_matchers_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + next_page_token='abc', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[], + next_page_token='def', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_phrase_matchers(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeletePhraseMatcherRequest, + dict, +]) +def test_delete_phrase_matcher(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeletePhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_phrase_matcher_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_phrase_matcher), + '__call__') as call: + client.delete_phrase_matcher() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeletePhraseMatcherRequest() + + +@pytest.mark.asyncio +async def test_delete_phrase_matcher_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeletePhraseMatcherRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeletePhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_phrase_matcher_async_from_dict(): + await test_delete_phrase_matcher_async(request_type=dict) + + +def test_delete_phrase_matcher_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeletePhraseMatcherRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), + '__call__') as call: + call.return_value = None + client.delete_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_phrase_matcher_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeletePhraseMatcherRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_phrase_matcher_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), + '__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_phrase_matcher( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_phrase_matcher_flattened_error(): + client = ContactCenterInsightsClient( + 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_phrase_matcher( + contact_center_insights.DeletePhraseMatcherRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_phrase_matcher_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), + '__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_phrase_matcher( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_phrase_matcher_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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_phrase_matcher( + contact_center_insights.DeletePhraseMatcherRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdatePhraseMatcherRequest, + dict, +]) +def test_update_phrase_matcher(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + response = client.update_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdatePhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +def test_update_phrase_matcher_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_phrase_matcher), + '__call__') as call: + client.update_phrase_matcher() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdatePhraseMatcherRequest() + + +@pytest.mark.asyncio +async def test_update_phrase_matcher_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdatePhraseMatcherRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + )) + response = await client.update_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdatePhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +@pytest.mark.asyncio +async def test_update_phrase_matcher_async_from_dict(): + await test_update_phrase_matcher_async(request_type=dict) + + +def test_update_phrase_matcher_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdatePhraseMatcherRequest() + + request.phrase_matcher.name = 'phrase_matcher.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), + '__call__') as call: + call.return_value = resources.PhraseMatcher() + client.update_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'phrase_matcher.name=phrase_matcher.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_phrase_matcher_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdatePhraseMatcherRequest() + + request.phrase_matcher.name = 'phrase_matcher.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) + await client.update_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'phrase_matcher.name=phrase_matcher.name/value', + ) in kw['metadata'] + + +def test_update_phrase_matcher_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_phrase_matcher( + phrase_matcher=resources.PhraseMatcher(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].phrase_matcher + mock_val = resources.PhraseMatcher(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_phrase_matcher_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_phrase_matcher( + contact_center_insights.UpdatePhraseMatcherRequest(), + phrase_matcher=resources.PhraseMatcher(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_phrase_matcher_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_phrase_matcher( + phrase_matcher=resources.PhraseMatcher(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].phrase_matcher + mock_val = resources.PhraseMatcher(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_phrase_matcher_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_phrase_matcher( + contact_center_insights.UpdatePhraseMatcherRequest(), + phrase_matcher=resources.PhraseMatcher(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CalculateStatsRequest, + dict, +]) +def test_calculate_stats(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.CalculateStatsResponse( + average_turn_count=1931, + conversation_count=1955, + ) + response = client.calculate_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CalculateStatsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.CalculateStatsResponse) + assert response.average_turn_count == 1931 + assert response.conversation_count == 1955 + + +def test_calculate_stats_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + client.calculate_stats() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CalculateStatsRequest() + + +@pytest.mark.asyncio +async def test_calculate_stats_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CalculateStatsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateStatsResponse( + average_turn_count=1931, + conversation_count=1955, + )) + response = await client.calculate_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CalculateStatsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.CalculateStatsResponse) + assert response.average_turn_count == 1931 + assert response.conversation_count == 1955 + + +@pytest.mark.asyncio +async def test_calculate_stats_async_from_dict(): + await test_calculate_stats_async(request_type=dict) + + +def test_calculate_stats_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CalculateStatsRequest() + + request.location = 'location/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + call.return_value = contact_center_insights.CalculateStatsResponse() + client.calculate_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'location=location/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_calculate_stats_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CalculateStatsRequest() + + request.location = 'location/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateStatsResponse()) + await client.calculate_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'location=location/value', + ) in kw['metadata'] + + +def test_calculate_stats_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.CalculateStatsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.calculate_stats( + location='location_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].location + mock_val = 'location_value' + assert arg == mock_val + + +def test_calculate_stats_flattened_error(): + client = ContactCenterInsightsClient( + 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.calculate_stats( + contact_center_insights.CalculateStatsRequest(), + location='location_value', + ) + + +@pytest.mark.asyncio +async def test_calculate_stats_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.CalculateStatsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateStatsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.calculate_stats( + location='location_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].location + mock_val = 'location_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_calculate_stats_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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.calculate_stats( + contact_center_insights.CalculateStatsRequest(), + location='location_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetSettingsRequest, + dict, +]) +def test_get_settings(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Settings( + name='name_value', + language_code='language_code_value', + ) + response = client.get_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] == contact_center_insights.GetSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Settings) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + + +def test_get_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 = ContactCenterInsightsClient( + credentials=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_settings), + '__call__') as call: + client.get_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetSettingsRequest() + + +@pytest.mark.asyncio +async def test_get_settings_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetSettingsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings( + name='name_value', + language_code='language_code_value', + )) + response = await client.get_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Settings) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + + +@pytest.mark.asyncio +async def test_get_settings_async_from_dict(): + await test_get_settings_async(request_type=dict) + + +def test_get_settings_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetSettingsRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_settings), + '__call__') as call: + call.return_value = resources.Settings() + client.get_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_get_settings_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetSettingsRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_settings), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings()) + await client.get_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_get_settings_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Settings() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_settings( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_settings_flattened_error(): + client = ContactCenterInsightsClient( + 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_settings( + contact_center_insights.GetSettingsRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_settings_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Settings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_settings( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_settings_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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_settings( + contact_center_insights.GetSettingsRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateSettingsRequest, + dict, +]) +def test_update_settings(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Settings( + name='name_value', + language_code='language_code_value', + ) + response = client.update_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] == contact_center_insights.UpdateSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Settings) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + + +def test_update_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 = ContactCenterInsightsClient( + credentials=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_settings), + '__call__') as call: + client.update_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateSettingsRequest() + + +@pytest.mark.asyncio +async def test_update_settings_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateSettingsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings( + name='name_value', + language_code='language_code_value', + )) + response = await client.update_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Settings) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + + +@pytest.mark.asyncio +async def test_update_settings_async_from_dict(): + await test_update_settings_async(request_type=dict) + + +def test_update_settings_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateSettingsRequest() + + request.settings.name = 'settings.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_settings), + '__call__') as call: + call.return_value = resources.Settings() + client.update_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', + 'settings.name=settings.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_settings_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateSettingsRequest() + + request.settings.name = 'settings.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_settings), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings()) + await client.update_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', + 'settings.name=settings.name/value', + ) in kw['metadata'] + + +def test_update_settings_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Settings() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_settings( + settings=resources.Settings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].settings + mock_val = resources.Settings(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_settings_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_settings( + contact_center_insights.UpdateSettingsRequest(), + settings=resources.Settings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_settings_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Settings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_settings( + settings=resources.Settings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].settings + mock_val = resources.Settings(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_settings_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_settings( + contact_center_insights.UpdateSettingsRequest(), + settings=resources.Settings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreateViewRequest, + dict, +]) +def test_create_view(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + ) + response = client.create_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateViewRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +def test_create_view_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_view), + '__call__') as call: + client.create_view() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateViewRequest() + + +@pytest.mark.asyncio +async def test_create_view_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreateViewRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + )) + response = await client.create_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateViewRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +@pytest.mark.asyncio +async def test_create_view_async_from_dict(): + await test_create_view_async(request_type=dict) + + +def test_create_view_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateViewRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_view), + '__call__') as call: + call.return_value = resources.View() + client.create_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_view_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateViewRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_view), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + await client.create_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_view_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_view( + parent='parent_value', + view=resources.View(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].view + mock_val = resources.View(name='name_value') + assert arg == mock_val + + +def test_create_view_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_view( + contact_center_insights.CreateViewRequest(), + parent='parent_value', + view=resources.View(name='name_value'), + ) + + +@pytest.mark.asyncio +async def test_create_view_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_view( + parent='parent_value', + view=resources.View(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].view + mock_val = resources.View(name='name_value') + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_view_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_view( + contact_center_insights.CreateViewRequest(), + parent='parent_value', + view=resources.View(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetViewRequest, + dict, +]) +def test_get_view(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + ) + response = client.get_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetViewRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +def test_get_view_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_view), + '__call__') as call: + client.get_view() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetViewRequest() + + +@pytest.mark.asyncio +async def test_get_view_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetViewRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + )) + response = await client.get_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetViewRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +@pytest.mark.asyncio +async def test_get_view_async_from_dict(): + await test_get_view_async(request_type=dict) + + +def test_get_view_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetViewRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_view), + '__call__') as call: + call.return_value = resources.View() + client.get_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_view_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetViewRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_view), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + await client.get_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_view_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_view( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_view_flattened_error(): + client = ContactCenterInsightsClient( + 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_view( + contact_center_insights.GetViewRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_view_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_view( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_view_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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_view( + contact_center_insights.GetViewRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListViewsRequest, + dict, +]) +def test_list_views(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_views), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListViewsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_views(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListViewsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListViewsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_views_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_views), + '__call__') as call: + client.list_views() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListViewsRequest() + + +@pytest.mark.asyncio +async def test_list_views_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListViewsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_views), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListViewsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_views(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListViewsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListViewsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_views_async_from_dict(): + await test_list_views_async(request_type=dict) + + +def test_list_views_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListViewsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + call.return_value = contact_center_insights.ListViewsResponse() + client.list_views(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_views_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListViewsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListViewsResponse()) + await client.list_views(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_views_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListViewsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_views( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_views_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_views( + contact_center_insights.ListViewsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_views_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListViewsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListViewsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_views( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_views_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_views( + contact_center_insights.ListViewsRequest(), + parent='parent_value', + ) + + +def test_list_views_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token='abc', + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token='def', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_views(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, resources.View) + for i in results) +def test_list_views_pages(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token='abc', + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token='def', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + RuntimeError, + ) + pages = list(client.list_views(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_views_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token='abc', + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token='def', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_views(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.View) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_views_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token='abc', + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token='def', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_views(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateViewRequest, + dict, +]) +def test_update_view(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + ) + response = client.update_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateViewRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +def test_update_view_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_view), + '__call__') as call: + client.update_view() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateViewRequest() + + +@pytest.mark.asyncio +async def test_update_view_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateViewRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + )) + response = await client.update_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateViewRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +@pytest.mark.asyncio +async def test_update_view_async_from_dict(): + await test_update_view_async(request_type=dict) + + +def test_update_view_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateViewRequest() + + request.view.name = 'view.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_view), + '__call__') as call: + call.return_value = resources.View() + client.update_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'view.name=view.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_view_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateViewRequest() + + request.view.name = 'view.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_view), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + await client.update_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'view.name=view.name/value', + ) in kw['metadata'] + + +def test_update_view_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_view( + view=resources.View(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].view + mock_val = resources.View(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_view_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_view( + contact_center_insights.UpdateViewRequest(), + view=resources.View(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_view_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_view( + view=resources.View(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].view + mock_val = resources.View(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_view_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_view( + contact_center_insights.UpdateViewRequest(), + view=resources.View(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteViewRequest, + dict, +]) +def test_delete_view(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteViewRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_view_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=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_view), + '__call__') as call: + client.delete_view() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteViewRequest() + + +@pytest.mark.asyncio +async def test_delete_view_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteViewRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteViewRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_view_async_from_dict(): + await test_delete_view_async(request_type=dict) + + +def test_delete_view_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteViewRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_view), + '__call__') as call: + call.return_value = None + client.delete_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_view_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteViewRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_view), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_view_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_view), + '__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_view( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_view_flattened_error(): + client = ContactCenterInsightsClient( + 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_view( + contact_center_insights.DeleteViewRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_view_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_view), + '__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_view( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_view_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + 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_view( + contact_center_insights.DeleteViewRequest(), + name='name_value', + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = ContactCenterInsightsClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.ContactCenterInsightsGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.ContactCenterInsightsGrpcTransport, + transports.ContactCenterInsightsGrpcAsyncIOTransport, +]) +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 = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.ContactCenterInsightsGrpcTransport, + ) + +def test_contact_center_insights_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.ContactCenterInsightsTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_contact_center_insights_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.contact_center_insights_v1.services.contact_center_insights.transports.ContactCenterInsightsTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.ContactCenterInsightsTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_conversation', + 'update_conversation', + 'get_conversation', + 'list_conversations', + 'delete_conversation', + 'create_analysis', + 'get_analysis', + 'list_analyses', + 'delete_analysis', + 'export_insights_data', + 'create_issue_model', + 'update_issue_model', + 'get_issue_model', + 'list_issue_models', + 'delete_issue_model', + 'deploy_issue_model', + 'undeploy_issue_model', + 'get_issue', + 'list_issues', + 'update_issue', + 'calculate_issue_model_stats', + 'create_phrase_matcher', + 'get_phrase_matcher', + 'list_phrase_matchers', + 'delete_phrase_matcher', + 'update_phrase_matcher', + 'calculate_stats', + 'get_settings', + 'update_settings', + 'create_view', + 'get_view', + 'list_views', + 'update_view', + 'delete_view', + ) + 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 + + +def test_contact_center_insights_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.contact_center_insights_v1.services.contact_center_insights.transports.ContactCenterInsightsTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.ContactCenterInsightsTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +def test_contact_center_insights_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.contact_center_insights_v1.services.contact_center_insights.transports.ContactCenterInsightsTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.ContactCenterInsightsTransport() + adc.assert_called_once() + + +def test_contact_center_insights_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) + ContactCenterInsightsClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.ContactCenterInsightsGrpcTransport, + transports.ContactCenterInsightsGrpcAsyncIOTransport, + ], +) +def test_contact_center_insights_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ContactCenterInsightsGrpcTransport, grpc_helpers), + (transports.ContactCenterInsightsGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_contact_center_insights_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( + "contactcenterinsights.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=["1", "2"], + default_host="contactcenterinsights.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.ContactCenterInsightsGrpcTransport, transports.ContactCenterInsightsGrpcAsyncIOTransport]) +def test_contact_center_insights_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_contact_center_insights_host_no_port(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='contactcenterinsights.googleapis.com'), + ) + assert client.transport._host == 'contactcenterinsights.googleapis.com:443' + + +def test_contact_center_insights_host_with_port(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='contactcenterinsights.googleapis.com:8000'), + ) + assert client.transport._host == 'contactcenterinsights.googleapis.com:8000' + +def test_contact_center_insights_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.ContactCenterInsightsGrpcTransport( + 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_contact_center_insights_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.ContactCenterInsightsGrpcAsyncIOTransport( + 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.ContactCenterInsightsGrpcTransport, transports.ContactCenterInsightsGrpcAsyncIOTransport]) +def test_contact_center_insights_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.ContactCenterInsightsGrpcTransport, transports.ContactCenterInsightsGrpcAsyncIOTransport]) +def test_contact_center_insights_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_contact_center_insights_grpc_lro_client(): + client = ContactCenterInsightsClient( + 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_contact_center_insights_grpc_lro_async_client(): + client = ContactCenterInsightsAsyncClient( + 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_analysis_path(): + project = "squid" + location = "clam" + conversation = "whelk" + analysis = "octopus" + expected = "projects/{project}/locations/{location}/conversations/{conversation}/analyses/{analysis}".format(project=project, location=location, conversation=conversation, analysis=analysis, ) + actual = ContactCenterInsightsClient.analysis_path(project, location, conversation, analysis) + assert expected == actual + + +def test_parse_analysis_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "conversation": "cuttlefish", + "analysis": "mussel", + } + path = ContactCenterInsightsClient.analysis_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_analysis_path(path) + assert expected == actual + +def test_conversation_path(): + project = "winkle" + location = "nautilus" + conversation = "scallop" + expected = "projects/{project}/locations/{location}/conversations/{conversation}".format(project=project, location=location, conversation=conversation, ) + actual = ContactCenterInsightsClient.conversation_path(project, location, conversation) + assert expected == actual + + +def test_parse_conversation_path(): + expected = { + "project": "abalone", + "location": "squid", + "conversation": "clam", + } + path = ContactCenterInsightsClient.conversation_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_conversation_path(path) + assert expected == actual + +def test_issue_path(): + project = "whelk" + location = "octopus" + issue_model = "oyster" + issue = "nudibranch" + expected = "projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue}".format(project=project, location=location, issue_model=issue_model, issue=issue, ) + actual = ContactCenterInsightsClient.issue_path(project, location, issue_model, issue) + assert expected == actual + + +def test_parse_issue_path(): + expected = { + "project": "cuttlefish", + "location": "mussel", + "issue_model": "winkle", + "issue": "nautilus", + } + path = ContactCenterInsightsClient.issue_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_issue_path(path) + assert expected == actual + +def test_issue_model_path(): + project = "scallop" + location = "abalone" + issue_model = "squid" + expected = "projects/{project}/locations/{location}/issueModels/{issue_model}".format(project=project, location=location, issue_model=issue_model, ) + actual = ContactCenterInsightsClient.issue_model_path(project, location, issue_model) + assert expected == actual + + +def test_parse_issue_model_path(): + expected = { + "project": "clam", + "location": "whelk", + "issue_model": "octopus", + } + path = ContactCenterInsightsClient.issue_model_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_issue_model_path(path) + assert expected == actual + +def test_participant_path(): + project = "oyster" + conversation = "nudibranch" + participant = "cuttlefish" + expected = "projects/{project}/conversations/{conversation}/participants/{participant}".format(project=project, conversation=conversation, participant=participant, ) + actual = ContactCenterInsightsClient.participant_path(project, conversation, participant) + assert expected == actual + + +def test_parse_participant_path(): + expected = { + "project": "mussel", + "conversation": "winkle", + "participant": "nautilus", + } + path = ContactCenterInsightsClient.participant_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_participant_path(path) + assert expected == actual + +def test_phrase_matcher_path(): + project = "scallop" + location = "abalone" + phrase_matcher = "squid" + expected = "projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher}".format(project=project, location=location, phrase_matcher=phrase_matcher, ) + actual = ContactCenterInsightsClient.phrase_matcher_path(project, location, phrase_matcher) + assert expected == actual + + +def test_parse_phrase_matcher_path(): + expected = { + "project": "clam", + "location": "whelk", + "phrase_matcher": "octopus", + } + path = ContactCenterInsightsClient.phrase_matcher_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_phrase_matcher_path(path) + assert expected == actual + +def test_settings_path(): + project = "oyster" + location = "nudibranch" + expected = "projects/{project}/locations/{location}/settings".format(project=project, location=location, ) + actual = ContactCenterInsightsClient.settings_path(project, location) + assert expected == actual + + +def test_parse_settings_path(): + expected = { + "project": "cuttlefish", + "location": "mussel", + } + path = ContactCenterInsightsClient.settings_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_settings_path(path) + assert expected == actual + +def test_view_path(): + project = "winkle" + location = "nautilus" + view = "scallop" + expected = "projects/{project}/locations/{location}/views/{view}".format(project=project, location=location, view=view, ) + actual = ContactCenterInsightsClient.view_path(project, location, view) + assert expected == actual + + +def test_parse_view_path(): + expected = { + "project": "abalone", + "location": "squid", + "view": "clam", + } + path = ContactCenterInsightsClient.view_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_view_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "whelk" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = ContactCenterInsightsClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "octopus", + } + path = ContactCenterInsightsClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "oyster" + expected = "folders/{folder}".format(folder=folder, ) + actual = ContactCenterInsightsClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nudibranch", + } + path = ContactCenterInsightsClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "cuttlefish" + expected = "organizations/{organization}".format(organization=organization, ) + actual = ContactCenterInsightsClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "mussel", + } + path = ContactCenterInsightsClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "winkle" + expected = "projects/{project}".format(project=project, ) + actual = ContactCenterInsightsClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nautilus", + } + path = ContactCenterInsightsClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "scallop" + location = "abalone" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = ContactCenterInsightsClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "squid", + "location": "clam", + } + path = ContactCenterInsightsClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_with_default_client_info(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.ContactCenterInsightsTransport, '_prep_wrapped_messages') as prep: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.ContactCenterInsightsTransport, '_prep_wrapped_messages') as prep: + transport_class = ContactCenterInsightsClient.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 = ContactCenterInsightsAsyncClient( + 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 = ContactCenterInsightsClient( + 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 = ContactCenterInsightsClient( + 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()