From 35dccef842f8b212c5e7d7cdfa66ece8f42aa87e Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Sat, 30 Oct 2021 02:19:46 +0000 Subject: [PATCH 1/4] chore: use gapic-generator-python 0.53.4 docs: list oneofs in docstring committer: busunkim96@ PiperOrigin-RevId: 406468269 Source-Link: https://github.com/googleapis/googleapis/commit/83d81b0c8fc22291a13398d6d77f02dc97a5b6f4 Source-Link: https://github.com/googleapis/googleapis-gen/commit/2ff001fbacb9e77e71d734de5f955c05fdae8526 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9 --- owl-bot-staging/v1alpha1/.coveragerc | 17 + owl-bot-staging/v1alpha1/MANIFEST.in | 2 + owl-bot-staging/v1alpha1/README.rst | 49 + owl-bot-staging/v1alpha1/docs/conf.py | 376 + .../docs/datastream_v1alpha1/datastream.rst | 10 + .../docs/datastream_v1alpha1/services.rst | 6 + .../docs/datastream_v1alpha1/types.rst | 7 + owl-bot-staging/v1alpha1/docs/index.rst | 7 + .../google/cloud/datastream/__init__.py | 149 + .../v1alpha1/google/cloud/datastream/py.typed | 2 + .../cloud/datastream_v1alpha1/__init__.py | 150 + .../datastream_v1alpha1/gapic_metadata.json | 233 + .../google/cloud/datastream_v1alpha1/py.typed | 2 + .../datastream_v1alpha1/services/__init__.py | 15 + .../services/datastream/__init__.py | 22 + .../services/datastream/async_client.py | 2029 +++++ .../services/datastream/client.py | 2255 ++++++ .../services/datastream/pagers.py | 629 ++ .../datastream/transports/__init__.py | 33 + .../services/datastream/transports/base.py | 434 ++ .../services/datastream/transports/grpc.py | 814 ++ .../datastream/transports/grpc_asyncio.py | 818 ++ .../datastream_v1alpha1/types/__init__.py | 148 + .../datastream_v1alpha1/types/datastream.py | 1195 +++ .../types/datastream_resources.py | 1311 ++++ owl-bot-staging/v1alpha1/mypy.ini | 3 + owl-bot-staging/v1alpha1/noxfile.py | 132 + .../fixup_datastream_v1alpha1_keywords.py | 196 + owl-bot-staging/v1alpha1/setup.py | 54 + owl-bot-staging/v1alpha1/tests/__init__.py | 16 + .../v1alpha1/tests/unit/__init__.py | 16 + .../v1alpha1/tests/unit/gapic/__init__.py | 16 + .../gapic/datastream_v1alpha1/__init__.py | 16 + .../datastream_v1alpha1/test_datastream.py | 6756 +++++++++++++++++ 34 files changed, 17918 insertions(+) create mode 100644 owl-bot-staging/v1alpha1/.coveragerc create mode 100644 owl-bot-staging/v1alpha1/MANIFEST.in create mode 100644 owl-bot-staging/v1alpha1/README.rst create mode 100644 owl-bot-staging/v1alpha1/docs/conf.py create mode 100644 owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/datastream.rst create mode 100644 owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/services.rst create mode 100644 owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/types.rst create mode 100644 owl-bot-staging/v1alpha1/docs/index.rst create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream/__init__.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream/py.typed create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/__init__.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/gapic_metadata.json create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/py.typed create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/__init__.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/__init__.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/async_client.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/client.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/pagers.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/__init__.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/__init__.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream.py create mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream_resources.py create mode 100644 owl-bot-staging/v1alpha1/mypy.ini create mode 100644 owl-bot-staging/v1alpha1/noxfile.py create mode 100644 owl-bot-staging/v1alpha1/scripts/fixup_datastream_v1alpha1_keywords.py create mode 100644 owl-bot-staging/v1alpha1/setup.py create mode 100644 owl-bot-staging/v1alpha1/tests/__init__.py create mode 100644 owl-bot-staging/v1alpha1/tests/unit/__init__.py create mode 100644 owl-bot-staging/v1alpha1/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/__init__.py create mode 100644 owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/test_datastream.py diff --git a/owl-bot-staging/v1alpha1/.coveragerc b/owl-bot-staging/v1alpha1/.coveragerc new file mode 100644 index 0000000..5f7f329 --- /dev/null +++ b/owl-bot-staging/v1alpha1/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/datastream/__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/v1alpha1/MANIFEST.in b/owl-bot-staging/v1alpha1/MANIFEST.in new file mode 100644 index 0000000..9b55389 --- /dev/null +++ b/owl-bot-staging/v1alpha1/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/datastream *.py +recursive-include google/cloud/datastream_v1alpha1 *.py diff --git a/owl-bot-staging/v1alpha1/README.rst b/owl-bot-staging/v1alpha1/README.rst new file mode 100644 index 0000000..9a1922d --- /dev/null +++ b/owl-bot-staging/v1alpha1/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Datastream 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 Datastream 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/v1alpha1/docs/conf.py b/owl-bot-staging/v1alpha1/docs/conf.py new file mode 100644 index 0000000..d2e8d45 --- /dev/null +++ b/owl-bot-staging/v1alpha1/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-datastream 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-datastream" +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-datastream-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-datastream.tex", + u"google-cloud-datastream 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-datastream", + u"Google Cloud Datastream 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-datastream", + u"google-cloud-datastream Documentation", + author, + "google-cloud-datastream", + "GAPIC library for Google Cloud Datastream 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/v1alpha1/docs/datastream_v1alpha1/datastream.rst b/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/datastream.rst new file mode 100644 index 0000000..507205d --- /dev/null +++ b/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/datastream.rst @@ -0,0 +1,10 @@ +Datastream +---------------------------- + +.. automodule:: google.cloud.datastream_v1alpha1.services.datastream + :members: + :inherited-members: + +.. automodule:: google.cloud.datastream_v1alpha1.services.datastream.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/services.rst b/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/services.rst new file mode 100644 index 0000000..1711424 --- /dev/null +++ b/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Datastream v1alpha1 API +================================================= +.. toctree:: + :maxdepth: 2 + + datastream diff --git a/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/types.rst b/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/types.rst new file mode 100644 index 0000000..2c4d392 --- /dev/null +++ b/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Datastream v1alpha1 API +============================================== + +.. automodule:: google.cloud.datastream_v1alpha1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/owl-bot-staging/v1alpha1/docs/index.rst b/owl-bot-staging/v1alpha1/docs/index.rst new file mode 100644 index 0000000..e0c9ba0 --- /dev/null +++ b/owl-bot-staging/v1alpha1/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + datastream_v1alpha1/services + datastream_v1alpha1/types diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream/__init__.py b/owl-bot-staging/v1alpha1/google/cloud/datastream/__init__.py new file mode 100644 index 0000000..7b68728 --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream/__init__.py @@ -0,0 +1,149 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.datastream_v1alpha1.services.datastream.client import DatastreamClient +from google.cloud.datastream_v1alpha1.services.datastream.async_client import DatastreamAsyncClient + +from google.cloud.datastream_v1alpha1.types.datastream import CreateConnectionProfileRequest +from google.cloud.datastream_v1alpha1.types.datastream import CreatePrivateConnectionRequest +from google.cloud.datastream_v1alpha1.types.datastream import CreateRouteRequest +from google.cloud.datastream_v1alpha1.types.datastream import CreateStreamRequest +from google.cloud.datastream_v1alpha1.types.datastream import DeleteConnectionProfileRequest +from google.cloud.datastream_v1alpha1.types.datastream import DeletePrivateConnectionRequest +from google.cloud.datastream_v1alpha1.types.datastream import DeleteRouteRequest +from google.cloud.datastream_v1alpha1.types.datastream import DeleteStreamRequest +from google.cloud.datastream_v1alpha1.types.datastream import DiscoverConnectionProfileRequest +from google.cloud.datastream_v1alpha1.types.datastream import DiscoverConnectionProfileResponse +from google.cloud.datastream_v1alpha1.types.datastream import FetchErrorsRequest +from google.cloud.datastream_v1alpha1.types.datastream import FetchErrorsResponse +from google.cloud.datastream_v1alpha1.types.datastream import FetchStaticIpsRequest +from google.cloud.datastream_v1alpha1.types.datastream import FetchStaticIpsResponse +from google.cloud.datastream_v1alpha1.types.datastream import GetConnectionProfileRequest +from google.cloud.datastream_v1alpha1.types.datastream import GetPrivateConnectionRequest +from google.cloud.datastream_v1alpha1.types.datastream import GetRouteRequest +from google.cloud.datastream_v1alpha1.types.datastream import GetStreamRequest +from google.cloud.datastream_v1alpha1.types.datastream import ListConnectionProfilesRequest +from google.cloud.datastream_v1alpha1.types.datastream import ListConnectionProfilesResponse +from google.cloud.datastream_v1alpha1.types.datastream import ListPrivateConnectionsRequest +from google.cloud.datastream_v1alpha1.types.datastream import ListPrivateConnectionsResponse +from google.cloud.datastream_v1alpha1.types.datastream import ListRoutesRequest +from google.cloud.datastream_v1alpha1.types.datastream import ListRoutesResponse +from google.cloud.datastream_v1alpha1.types.datastream import ListStreamsRequest +from google.cloud.datastream_v1alpha1.types.datastream import ListStreamsResponse +from google.cloud.datastream_v1alpha1.types.datastream import OperationMetadata +from google.cloud.datastream_v1alpha1.types.datastream import UpdateConnectionProfileRequest +from google.cloud.datastream_v1alpha1.types.datastream import UpdateStreamRequest +from google.cloud.datastream_v1alpha1.types.datastream_resources import AvroFileFormat +from google.cloud.datastream_v1alpha1.types.datastream_resources import ConnectionProfile +from google.cloud.datastream_v1alpha1.types.datastream_resources import DestinationConfig +from google.cloud.datastream_v1alpha1.types.datastream_resources import Error +from google.cloud.datastream_v1alpha1.types.datastream_resources import ForwardSshTunnelConnectivity +from google.cloud.datastream_v1alpha1.types.datastream_resources import GcsDestinationConfig +from google.cloud.datastream_v1alpha1.types.datastream_resources import GcsProfile +from google.cloud.datastream_v1alpha1.types.datastream_resources import JsonFileFormat +from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlColumn +from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlDatabase +from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlProfile +from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlRdbms +from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlSourceConfig +from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlSslConfig +from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlTable +from google.cloud.datastream_v1alpha1.types.datastream_resources import NoConnectivitySettings +from google.cloud.datastream_v1alpha1.types.datastream_resources import OracleColumn +from google.cloud.datastream_v1alpha1.types.datastream_resources import OracleProfile +from google.cloud.datastream_v1alpha1.types.datastream_resources import OracleRdbms +from google.cloud.datastream_v1alpha1.types.datastream_resources import OracleSchema +from google.cloud.datastream_v1alpha1.types.datastream_resources import OracleSourceConfig +from google.cloud.datastream_v1alpha1.types.datastream_resources import OracleTable +from google.cloud.datastream_v1alpha1.types.datastream_resources import PrivateConnection +from google.cloud.datastream_v1alpha1.types.datastream_resources import PrivateConnectivity +from google.cloud.datastream_v1alpha1.types.datastream_resources import Route +from google.cloud.datastream_v1alpha1.types.datastream_resources import SourceConfig +from google.cloud.datastream_v1alpha1.types.datastream_resources import StaticServiceIpConnectivity +from google.cloud.datastream_v1alpha1.types.datastream_resources import Stream +from google.cloud.datastream_v1alpha1.types.datastream_resources import Validation +from google.cloud.datastream_v1alpha1.types.datastream_resources import ValidationMessage +from google.cloud.datastream_v1alpha1.types.datastream_resources import ValidationResult +from google.cloud.datastream_v1alpha1.types.datastream_resources import VpcPeeringConfig +from google.cloud.datastream_v1alpha1.types.datastream_resources import GcsFileFormat +from google.cloud.datastream_v1alpha1.types.datastream_resources import SchemaFileFormat + +__all__ = ('DatastreamClient', + 'DatastreamAsyncClient', + 'CreateConnectionProfileRequest', + 'CreatePrivateConnectionRequest', + 'CreateRouteRequest', + 'CreateStreamRequest', + 'DeleteConnectionProfileRequest', + 'DeletePrivateConnectionRequest', + 'DeleteRouteRequest', + 'DeleteStreamRequest', + 'DiscoverConnectionProfileRequest', + 'DiscoverConnectionProfileResponse', + 'FetchErrorsRequest', + 'FetchErrorsResponse', + 'FetchStaticIpsRequest', + 'FetchStaticIpsResponse', + 'GetConnectionProfileRequest', + 'GetPrivateConnectionRequest', + 'GetRouteRequest', + 'GetStreamRequest', + 'ListConnectionProfilesRequest', + 'ListConnectionProfilesResponse', + 'ListPrivateConnectionsRequest', + 'ListPrivateConnectionsResponse', + 'ListRoutesRequest', + 'ListRoutesResponse', + 'ListStreamsRequest', + 'ListStreamsResponse', + 'OperationMetadata', + 'UpdateConnectionProfileRequest', + 'UpdateStreamRequest', + 'AvroFileFormat', + 'ConnectionProfile', + 'DestinationConfig', + 'Error', + 'ForwardSshTunnelConnectivity', + 'GcsDestinationConfig', + 'GcsProfile', + 'JsonFileFormat', + 'MysqlColumn', + 'MysqlDatabase', + 'MysqlProfile', + 'MysqlRdbms', + 'MysqlSourceConfig', + 'MysqlSslConfig', + 'MysqlTable', + 'NoConnectivitySettings', + 'OracleColumn', + 'OracleProfile', + 'OracleRdbms', + 'OracleSchema', + 'OracleSourceConfig', + 'OracleTable', + 'PrivateConnection', + 'PrivateConnectivity', + 'Route', + 'SourceConfig', + 'StaticServiceIpConnectivity', + 'Stream', + 'Validation', + 'ValidationMessage', + 'ValidationResult', + 'VpcPeeringConfig', + 'GcsFileFormat', + 'SchemaFileFormat', +) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream/py.typed b/owl-bot-staging/v1alpha1/google/cloud/datastream/py.typed new file mode 100644 index 0000000..38ae0fa --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-datastream package uses inline types. diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/__init__.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/__init__.py new file mode 100644 index 0000000..671eb8b --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/__init__.py @@ -0,0 +1,150 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.datastream import DatastreamClient +from .services.datastream import DatastreamAsyncClient + +from .types.datastream import CreateConnectionProfileRequest +from .types.datastream import CreatePrivateConnectionRequest +from .types.datastream import CreateRouteRequest +from .types.datastream import CreateStreamRequest +from .types.datastream import DeleteConnectionProfileRequest +from .types.datastream import DeletePrivateConnectionRequest +from .types.datastream import DeleteRouteRequest +from .types.datastream import DeleteStreamRequest +from .types.datastream import DiscoverConnectionProfileRequest +from .types.datastream import DiscoverConnectionProfileResponse +from .types.datastream import FetchErrorsRequest +from .types.datastream import FetchErrorsResponse +from .types.datastream import FetchStaticIpsRequest +from .types.datastream import FetchStaticIpsResponse +from .types.datastream import GetConnectionProfileRequest +from .types.datastream import GetPrivateConnectionRequest +from .types.datastream import GetRouteRequest +from .types.datastream import GetStreamRequest +from .types.datastream import ListConnectionProfilesRequest +from .types.datastream import ListConnectionProfilesResponse +from .types.datastream import ListPrivateConnectionsRequest +from .types.datastream import ListPrivateConnectionsResponse +from .types.datastream import ListRoutesRequest +from .types.datastream import ListRoutesResponse +from .types.datastream import ListStreamsRequest +from .types.datastream import ListStreamsResponse +from .types.datastream import OperationMetadata +from .types.datastream import UpdateConnectionProfileRequest +from .types.datastream import UpdateStreamRequest +from .types.datastream_resources import AvroFileFormat +from .types.datastream_resources import ConnectionProfile +from .types.datastream_resources import DestinationConfig +from .types.datastream_resources import Error +from .types.datastream_resources import ForwardSshTunnelConnectivity +from .types.datastream_resources import GcsDestinationConfig +from .types.datastream_resources import GcsProfile +from .types.datastream_resources import JsonFileFormat +from .types.datastream_resources import MysqlColumn +from .types.datastream_resources import MysqlDatabase +from .types.datastream_resources import MysqlProfile +from .types.datastream_resources import MysqlRdbms +from .types.datastream_resources import MysqlSourceConfig +from .types.datastream_resources import MysqlSslConfig +from .types.datastream_resources import MysqlTable +from .types.datastream_resources import NoConnectivitySettings +from .types.datastream_resources import OracleColumn +from .types.datastream_resources import OracleProfile +from .types.datastream_resources import OracleRdbms +from .types.datastream_resources import OracleSchema +from .types.datastream_resources import OracleSourceConfig +from .types.datastream_resources import OracleTable +from .types.datastream_resources import PrivateConnection +from .types.datastream_resources import PrivateConnectivity +from .types.datastream_resources import Route +from .types.datastream_resources import SourceConfig +from .types.datastream_resources import StaticServiceIpConnectivity +from .types.datastream_resources import Stream +from .types.datastream_resources import Validation +from .types.datastream_resources import ValidationMessage +from .types.datastream_resources import ValidationResult +from .types.datastream_resources import VpcPeeringConfig +from .types.datastream_resources import GcsFileFormat +from .types.datastream_resources import SchemaFileFormat + +__all__ = ( + 'DatastreamAsyncClient', +'AvroFileFormat', +'ConnectionProfile', +'CreateConnectionProfileRequest', +'CreatePrivateConnectionRequest', +'CreateRouteRequest', +'CreateStreamRequest', +'DatastreamClient', +'DeleteConnectionProfileRequest', +'DeletePrivateConnectionRequest', +'DeleteRouteRequest', +'DeleteStreamRequest', +'DestinationConfig', +'DiscoverConnectionProfileRequest', +'DiscoverConnectionProfileResponse', +'Error', +'FetchErrorsRequest', +'FetchErrorsResponse', +'FetchStaticIpsRequest', +'FetchStaticIpsResponse', +'ForwardSshTunnelConnectivity', +'GcsDestinationConfig', +'GcsFileFormat', +'GcsProfile', +'GetConnectionProfileRequest', +'GetPrivateConnectionRequest', +'GetRouteRequest', +'GetStreamRequest', +'JsonFileFormat', +'ListConnectionProfilesRequest', +'ListConnectionProfilesResponse', +'ListPrivateConnectionsRequest', +'ListPrivateConnectionsResponse', +'ListRoutesRequest', +'ListRoutesResponse', +'ListStreamsRequest', +'ListStreamsResponse', +'MysqlColumn', +'MysqlDatabase', +'MysqlProfile', +'MysqlRdbms', +'MysqlSourceConfig', +'MysqlSslConfig', +'MysqlTable', +'NoConnectivitySettings', +'OperationMetadata', +'OracleColumn', +'OracleProfile', +'OracleRdbms', +'OracleSchema', +'OracleSourceConfig', +'OracleTable', +'PrivateConnection', +'PrivateConnectivity', +'Route', +'SchemaFileFormat', +'SourceConfig', +'StaticServiceIpConnectivity', +'Stream', +'UpdateConnectionProfileRequest', +'UpdateStreamRequest', +'Validation', +'ValidationMessage', +'ValidationResult', +'VpcPeeringConfig', +) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/gapic_metadata.json b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/gapic_metadata.json new file mode 100644 index 0000000..a82501e --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/gapic_metadata.json @@ -0,0 +1,233 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.datastream_v1alpha1", + "protoPackage": "google.cloud.datastream.v1alpha1", + "schema": "1.0", + "services": { + "Datastream": { + "clients": { + "grpc": { + "libraryClient": "DatastreamClient", + "rpcs": { + "CreateConnectionProfile": { + "methods": [ + "create_connection_profile" + ] + }, + "CreatePrivateConnection": { + "methods": [ + "create_private_connection" + ] + }, + "CreateRoute": { + "methods": [ + "create_route" + ] + }, + "CreateStream": { + "methods": [ + "create_stream" + ] + }, + "DeleteConnectionProfile": { + "methods": [ + "delete_connection_profile" + ] + }, + "DeletePrivateConnection": { + "methods": [ + "delete_private_connection" + ] + }, + "DeleteRoute": { + "methods": [ + "delete_route" + ] + }, + "DeleteStream": { + "methods": [ + "delete_stream" + ] + }, + "DiscoverConnectionProfile": { + "methods": [ + "discover_connection_profile" + ] + }, + "FetchErrors": { + "methods": [ + "fetch_errors" + ] + }, + "FetchStaticIps": { + "methods": [ + "fetch_static_ips" + ] + }, + "GetConnectionProfile": { + "methods": [ + "get_connection_profile" + ] + }, + "GetPrivateConnection": { + "methods": [ + "get_private_connection" + ] + }, + "GetRoute": { + "methods": [ + "get_route" + ] + }, + "GetStream": { + "methods": [ + "get_stream" + ] + }, + "ListConnectionProfiles": { + "methods": [ + "list_connection_profiles" + ] + }, + "ListPrivateConnections": { + "methods": [ + "list_private_connections" + ] + }, + "ListRoutes": { + "methods": [ + "list_routes" + ] + }, + "ListStreams": { + "methods": [ + "list_streams" + ] + }, + "UpdateConnectionProfile": { + "methods": [ + "update_connection_profile" + ] + }, + "UpdateStream": { + "methods": [ + "update_stream" + ] + } + } + }, + "grpc-async": { + "libraryClient": "DatastreamAsyncClient", + "rpcs": { + "CreateConnectionProfile": { + "methods": [ + "create_connection_profile" + ] + }, + "CreatePrivateConnection": { + "methods": [ + "create_private_connection" + ] + }, + "CreateRoute": { + "methods": [ + "create_route" + ] + }, + "CreateStream": { + "methods": [ + "create_stream" + ] + }, + "DeleteConnectionProfile": { + "methods": [ + "delete_connection_profile" + ] + }, + "DeletePrivateConnection": { + "methods": [ + "delete_private_connection" + ] + }, + "DeleteRoute": { + "methods": [ + "delete_route" + ] + }, + "DeleteStream": { + "methods": [ + "delete_stream" + ] + }, + "DiscoverConnectionProfile": { + "methods": [ + "discover_connection_profile" + ] + }, + "FetchErrors": { + "methods": [ + "fetch_errors" + ] + }, + "FetchStaticIps": { + "methods": [ + "fetch_static_ips" + ] + }, + "GetConnectionProfile": { + "methods": [ + "get_connection_profile" + ] + }, + "GetPrivateConnection": { + "methods": [ + "get_private_connection" + ] + }, + "GetRoute": { + "methods": [ + "get_route" + ] + }, + "GetStream": { + "methods": [ + "get_stream" + ] + }, + "ListConnectionProfiles": { + "methods": [ + "list_connection_profiles" + ] + }, + "ListPrivateConnections": { + "methods": [ + "list_private_connections" + ] + }, + "ListRoutes": { + "methods": [ + "list_routes" + ] + }, + "ListStreams": { + "methods": [ + "list_streams" + ] + }, + "UpdateConnectionProfile": { + "methods": [ + "update_connection_profile" + ] + }, + "UpdateStream": { + "methods": [ + "update_stream" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/py.typed b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/py.typed new file mode 100644 index 0000000..38ae0fa --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-datastream package uses inline types. diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/__init__.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/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/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/__init__.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/__init__.py new file mode 100644 index 0000000..f9ff72b --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/__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 DatastreamClient +from .async_client import DatastreamAsyncClient + +__all__ = ( + 'DatastreamClient', + 'DatastreamAsyncClient', +) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/async_client.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/async_client.py new file mode 100644 index 0000000..47ade10 --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/async_client.py @@ -0,0 +1,2029 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +OptionalRetry = Union[retries.Retry, object] + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.datastream_v1alpha1.services.datastream import pagers +from google.cloud.datastream_v1alpha1.types import datastream +from google.cloud.datastream_v1alpha1.types import datastream_resources +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 DatastreamTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import DatastreamGrpcAsyncIOTransport +from .client import DatastreamClient + + +class DatastreamAsyncClient: + """Datastream service""" + + _client: DatastreamClient + + DEFAULT_ENDPOINT = DatastreamClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = DatastreamClient.DEFAULT_MTLS_ENDPOINT + + connection_profile_path = staticmethod(DatastreamClient.connection_profile_path) + parse_connection_profile_path = staticmethod(DatastreamClient.parse_connection_profile_path) + private_connection_path = staticmethod(DatastreamClient.private_connection_path) + parse_private_connection_path = staticmethod(DatastreamClient.parse_private_connection_path) + route_path = staticmethod(DatastreamClient.route_path) + parse_route_path = staticmethod(DatastreamClient.parse_route_path) + stream_path = staticmethod(DatastreamClient.stream_path) + parse_stream_path = staticmethod(DatastreamClient.parse_stream_path) + common_billing_account_path = staticmethod(DatastreamClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(DatastreamClient.parse_common_billing_account_path) + common_folder_path = staticmethod(DatastreamClient.common_folder_path) + parse_common_folder_path = staticmethod(DatastreamClient.parse_common_folder_path) + common_organization_path = staticmethod(DatastreamClient.common_organization_path) + parse_common_organization_path = staticmethod(DatastreamClient.parse_common_organization_path) + common_project_path = staticmethod(DatastreamClient.common_project_path) + parse_common_project_path = staticmethod(DatastreamClient.parse_common_project_path) + common_location_path = staticmethod(DatastreamClient.common_location_path) + parse_common_location_path = staticmethod(DatastreamClient.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: + DatastreamAsyncClient: The constructed client. + """ + return DatastreamClient.from_service_account_info.__func__(DatastreamAsyncClient, 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: + DatastreamAsyncClient: The constructed client. + """ + return DatastreamClient.from_service_account_file.__func__(DatastreamAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> DatastreamTransport: + """Returns the transport used by the client instance. + + Returns: + DatastreamTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(DatastreamClient).get_transport_class, type(DatastreamClient)) + + def __init__(self, *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, DatastreamTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the datastream 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, ~.DatastreamTransport]): 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 = DatastreamClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def list_connection_profiles(self, + request: Union[datastream.ListConnectionProfilesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListConnectionProfilesAsyncPager: + r"""Use this method to list connection profiles created + in a project and location. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.ListConnectionProfilesRequest, dict]): + The request object. + parent (:class:`str`): + Required. The parent that owns the + collection of connection profiles. + + 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.datastream_v1alpha1.services.datastream.pagers.ListConnectionProfilesAsyncPager: + 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 = datastream.ListConnectionProfilesRequest(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_connection_profiles, + default_timeout=None, + client_info=DEFAULT_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.ListConnectionProfilesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_connection_profile(self, + request: Union[datastream.GetConnectionProfileRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> datastream_resources.ConnectionProfile: + r"""Use this method to get details about a connection + profile. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.GetConnectionProfileRequest, dict]): + The request object. + name (:class:`str`): + Required. The name of the connection + profile 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.datastream_v1alpha1.types.ConnectionProfile: + + """ + # Create or coerce a protobuf request object. + # Sanity 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 = datastream.GetConnectionProfileRequest(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_connection_profile, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_connection_profile(self, + request: Union[datastream.CreateConnectionProfileRequest, dict] = None, + *, + parent: str = None, + connection_profile: datastream_resources.ConnectionProfile = None, + connection_profile_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Use this method to create a connection profile in a + project and location. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.CreateConnectionProfileRequest, dict]): + The request object. + parent (:class:`str`): + Required. The parent that owns the + collection of ConnectionProfiles. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + connection_profile (:class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile`): + Required. The connection profile + resource to create. + + This corresponds to the ``connection_profile`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + connection_profile_id (:class:`str`): + Required. The connection profile + identifier. + + This corresponds to the ``connection_profile_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile` + + """ + # Create or coerce a protobuf request object. + # Sanity 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, connection_profile, connection_profile_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 = datastream.CreateConnectionProfileRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if connection_profile is not None: + request.connection_profile = connection_profile + if connection_profile_id is not None: + request.connection_profile_id = connection_profile_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_connection_profile, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + datastream_resources.ConnectionProfile, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_connection_profile(self, + request: Union[datastream.UpdateConnectionProfileRequest, dict] = None, + *, + connection_profile: datastream_resources.ConnectionProfile = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Use this method to update the parameters of a + connection profile. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.UpdateConnectionProfileRequest, dict]): + The request object. + connection_profile (:class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile`): + Required. The ConnectionProfile to + update. + + This corresponds to the ``connection_profile`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Optional. Field mask is used to specify the fields to be + overwritten in the ConnectionProfile resource by the + update. The fields specified in the update_mask are + relative to the resource, not the full request. A field + will be overwritten if it is in the mask. If the user + does not provide a mask then all fields will be + overwritten. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile` + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([connection_profile, 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 = datastream.UpdateConnectionProfileRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if connection_profile is not None: + request.connection_profile = connection_profile + 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_connection_profile, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("connection_profile.name", request.connection_profile.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, + datastream_resources.ConnectionProfile, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_connection_profile(self, + request: Union[datastream.DeleteConnectionProfileRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Use this method to delete a connection profile.. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.DeleteConnectionProfileRequest, dict]): + The request object. + name (:class:`str`): + Required. The name of the connection + profile resource 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 = datastream.DeleteConnectionProfileRequest(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_connection_profile, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + async def discover_connection_profile(self, + request: Union[datastream.DiscoverConnectionProfileRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> datastream.DiscoverConnectionProfileResponse: + r"""Use this method to discover a connection profile. + The discover API call exposes the data objects and + metadata belonging to the profile. Typically, a request + returns children data objects under a parent data object + that's optionally supplied in the request. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.DiscoverConnectionProfileRequest, dict]): + The request object. Request message for 'discover' + ConnectionProfile request. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.datastream_v1alpha1.types.DiscoverConnectionProfileResponse: + + """ + # Create or coerce a protobuf request object. + request = datastream.DiscoverConnectionProfileRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.discover_connection_profile, + default_timeout=None, + client_info=DEFAULT_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 list_streams(self, + request: Union[datastream.ListStreamsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListStreamsAsyncPager: + r"""Use this method to list streams in a project and + location. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.ListStreamsRequest, dict]): + The request object. + parent (:class:`str`): + Required. The parent that owns the + collection of streams. + + 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.datastream_v1alpha1.services.datastream.pagers.ListStreamsAsyncPager: + 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 = datastream.ListStreamsRequest(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_streams, + default_timeout=None, + client_info=DEFAULT_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.ListStreamsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_stream(self, + request: Union[datastream.GetStreamRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> datastream_resources.Stream: + r"""Use this method to get details about a stream. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.GetStreamRequest, dict]): + The request object. + name (:class:`str`): + Required. The name of the stream + 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.datastream_v1alpha1.types.Stream: + + """ + # Create or coerce a protobuf request object. + # Sanity 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 = datastream.GetStreamRequest(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_stream, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_stream(self, + request: Union[datastream.CreateStreamRequest, dict] = None, + *, + parent: str = None, + stream: datastream_resources.Stream = None, + stream_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Use this method to create a stream. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.CreateStreamRequest, dict]): + The request object. + parent (:class:`str`): + Required. The parent that owns the + collection of streams. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + stream (:class:`google.cloud.datastream_v1alpha1.types.Stream`): + Required. The stream resource to + create. + + This corresponds to the ``stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + stream_id (:class:`str`): + Required. The stream identifier. + This corresponds to the ``stream_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.datastream_v1alpha1.types.Stream` + + """ + # Create or coerce a protobuf request object. + # Sanity 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, stream, stream_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 = datastream.CreateStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if stream is not None: + request.stream = stream + if stream_id is not None: + request.stream_id = stream_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_stream, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + datastream_resources.Stream, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_stream(self, + request: Union[datastream.UpdateStreamRequest, dict] = None, + *, + stream: datastream_resources.Stream = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Use this method to update the configuration of a + stream. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.UpdateStreamRequest, dict]): + The request object. + stream (:class:`google.cloud.datastream_v1alpha1.types.Stream`): + Required. The stream resource to + update. + + This corresponds to the ``stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Optional. Field mask is used to specify the fields to be + overwritten in the stream resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.datastream_v1alpha1.types.Stream` + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([stream, 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 = datastream.UpdateStreamRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if stream is not None: + request.stream = stream + 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_stream, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("stream.name", request.stream.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, + datastream_resources.Stream, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_stream(self, + request: Union[datastream.DeleteStreamRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Use this method to delete a stream. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.DeleteStreamRequest, dict]): + The request object. + name (:class:`str`): + Required. The name of the stream + resource 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 = datastream.DeleteStreamRequest(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_stream, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + async def fetch_errors(self, + request: Union[datastream.FetchErrorsRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Use this method to fetch any errors associated with a + stream. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.FetchErrorsRequest, dict]): + The request object. Request message for 'FetchErrors' + request. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout 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.datastream_v1alpha1.types.FetchErrorsResponse` + Response message for a 'FetchErrors' response. + + """ + # Create or coerce a protobuf request object. + request = datastream.FetchErrorsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.fetch_errors, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("stream", request.stream), + )), + ) + + # 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, + datastream.FetchErrorsResponse, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + async def fetch_static_ips(self, + request: Union[datastream.FetchStaticIpsRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.FetchStaticIpsAsyncPager: + r"""The FetchStaticIps API call exposes the static ips + used by Datastream. Typically, a request returns + children data objects under a parent data object that's + optionally supplied in the request. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.FetchStaticIpsRequest, dict]): + The request object. Request message for 'FetchStaticIps' + request. + name (:class:`str`): + Required. The name resource of the Response type. Must + be in the format ``projects/*/locations/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.datastream_v1alpha1.services.datastream.pagers.FetchStaticIpsAsyncPager: + Response message for a + 'FetchStaticIps' response. + 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([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 = datastream.FetchStaticIpsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.fetch_static_ips, + default_timeout=None, + client_info=DEFAULT_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, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.FetchStaticIpsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_private_connection(self, + request: Union[datastream.CreatePrivateConnectionRequest, dict] = None, + *, + parent: str = None, + private_connection: datastream_resources.PrivateConnection = None, + private_connection_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Use this method to create a private connectivity + configuration. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.CreatePrivateConnectionRequest, dict]): + The request object. + parent (:class:`str`): + Required. The parent that owns the + collection of PrivateConnections. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + private_connection (:class:`google.cloud.datastream_v1alpha1.types.PrivateConnection`): + Required. The Private Connectivity + resource to create. + + This corresponds to the ``private_connection`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + private_connection_id (:class:`str`): + Required. The private connectivity + identifier. + + This corresponds to the ``private_connection_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.datastream_v1alpha1.types.PrivateConnection` The PrivateConnection resource is used to establish private connectivity + between Datastream and a customer's network. + + """ + # Create or coerce a protobuf request object. + # Sanity 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, private_connection, private_connection_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 = datastream.CreatePrivateConnectionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if private_connection is not None: + request.private_connection = private_connection + if private_connection_id is not None: + request.private_connection_id = private_connection_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_private_connection, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + datastream_resources.PrivateConnection, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_private_connection(self, + request: Union[datastream.GetPrivateConnectionRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> datastream_resources.PrivateConnection: + r"""Use this method to get details about a private + connectivity configuration. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.GetPrivateConnectionRequest, dict]): + The request object. + name (:class:`str`): + Required. The name of the private + connectivity configuration 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.datastream_v1alpha1.types.PrivateConnection: + The PrivateConnection resource is + used to establish private connectivity + between Datastream and a customer's + network. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 = datastream.GetPrivateConnectionRequest(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_private_connection, + default_timeout=None, + client_info=DEFAULT_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_private_connections(self, + request: Union[datastream.ListPrivateConnectionsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPrivateConnectionsAsyncPager: + r"""Use this method to list private connectivity + configurations in a project and location. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsRequest, dict]): + The request object. + parent (:class:`str`): + Required. The parent that owns the + collection of private connectivity + configurations. + + 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.datastream_v1alpha1.services.datastream.pagers.ListPrivateConnectionsAsyncPager: + 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 = datastream.ListPrivateConnectionsRequest(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_private_connections, + default_timeout=None, + client_info=DEFAULT_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.ListPrivateConnectionsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_private_connection(self, + request: Union[datastream.DeletePrivateConnectionRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Use this method to delete a private connectivity + configuration. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.DeletePrivateConnectionRequest, dict]): + The request object. + name (:class:`str`): + Required. The name of the private + connectivity configuration 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 = datastream.DeletePrivateConnectionRequest(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_private_connection, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_route(self, + request: Union[datastream.CreateRouteRequest, dict] = None, + *, + parent: str = None, + route: datastream_resources.Route = None, + route_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Use this method to create a route for a private + connectivity in a project and location. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.CreateRouteRequest, dict]): + The request object. route creation request + parent (:class:`str`): + Required. The parent that owns the + collection of Routes. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + route (:class:`google.cloud.datastream_v1alpha1.types.Route`): + Required. The Route resource to + create. + + This corresponds to the ``route`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + route_id (:class:`str`): + Required. The Route identifier. + This corresponds to the ``route_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.datastream_v1alpha1.types.Route` The Route resource is the child of the PrivateConnection resource. + It used to define a route for a PrivateConnection + setup. + + """ + # Create or coerce a protobuf request object. + # Sanity 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, route, route_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 = datastream.CreateRouteRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if route is not None: + request.route = route + if route_id is not None: + request.route_id = route_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_route, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + datastream_resources.Route, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_route(self, + request: Union[datastream.GetRouteRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> datastream_resources.Route: + r"""Use this method to get details about a route. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.GetRouteRequest, dict]): + The request object. route get request + name (:class:`str`): + Required. The name of the Route + 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.datastream_v1alpha1.types.Route: + The Route resource is the child of + the PrivateConnection resource. It used + to define a route for a + PrivateConnection setup. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 = datastream.GetRouteRequest(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_route, + default_timeout=None, + client_info=DEFAULT_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_routes(self, + request: Union[datastream.ListRoutesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListRoutesAsyncPager: + r"""Use this method to list routes created for a private + connectivity in a project and location. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.ListRoutesRequest, dict]): + The request object. route list request + parent (:class:`str`): + Required. The parent that owns the + collection of Routess. + + 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.datastream_v1alpha1.services.datastream.pagers.ListRoutesAsyncPager: + route list response + 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 = datastream.ListRoutesRequest(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_routes, + default_timeout=None, + client_info=DEFAULT_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.ListRoutesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_route(self, + request: Union[datastream.DeleteRouteRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Use this method to delete a route. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.DeleteRouteRequest, dict]): + The request object. route deletion request + name (:class:`str`): + Required. The name of the Route + resource 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 = datastream.DeleteRouteRequest(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_route, + default_timeout=60.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-datastream", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "DatastreamAsyncClient", +) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/client.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/client.py new file mode 100644 index 0000000..e97b5cf --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/client.py @@ -0,0 +1,2255 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +from distutils import util +import os +import re +from typing import Dict, Optional, Sequence, Tuple, Type, Union +import pkg_resources + +from google.api_core import client_options as client_options_lib # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +OptionalRetry = Union[retries.Retry, object] + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.datastream_v1alpha1.services.datastream import pagers +from google.cloud.datastream_v1alpha1.types import datastream +from google.cloud.datastream_v1alpha1.types import datastream_resources +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 DatastreamTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import DatastreamGrpcTransport +from .transports.grpc_asyncio import DatastreamGrpcAsyncIOTransport + + +class DatastreamClientMeta(type): + """Metaclass for the Datastream 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[DatastreamTransport]] + _transport_registry["grpc"] = DatastreamGrpcTransport + _transport_registry["grpc_asyncio"] = DatastreamGrpcAsyncIOTransport + + def get_transport_class(cls, + label: str = None, + ) -> Type[DatastreamTransport]: + """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 DatastreamClient(metaclass=DatastreamClientMeta): + """Datastream service""" + + @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 = "datastream.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: + DatastreamClient: 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: + DatastreamClient: 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) -> DatastreamTransport: + """Returns the transport used by the client instance. + + Returns: + DatastreamTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def connection_profile_path(project: str,location: str,connection_profile: str,) -> str: + """Returns a fully-qualified connection_profile string.""" + return "projects/{project}/locations/{location}/connectionProfiles/{connection_profile}".format(project=project, location=location, connection_profile=connection_profile, ) + + @staticmethod + def parse_connection_profile_path(path: str) -> Dict[str,str]: + """Parses a connection_profile path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/connectionProfiles/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def private_connection_path(project: str,location: str,private_connection: str,) -> str: + """Returns a fully-qualified private_connection string.""" + return "projects/{project}/locations/{location}/privateConnections/{private_connection}".format(project=project, location=location, private_connection=private_connection, ) + + @staticmethod + def parse_private_connection_path(path: str) -> Dict[str,str]: + """Parses a private_connection path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/privateConnections/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def route_path(project: str,location: str,private_connection: str,route: str,) -> str: + """Returns a fully-qualified route string.""" + return "projects/{project}/locations/{location}/privateConnections/{private_connection}/routes/{route}".format(project=project, location=location, private_connection=private_connection, route=route, ) + + @staticmethod + def parse_route_path(path: str) -> Dict[str,str]: + """Parses a route path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/privateConnections/(?P.+?)/routes/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def stream_path(project: str,location: str,stream: str,) -> str: + """Returns a fully-qualified stream string.""" + return "projects/{project}/locations/{location}/streams/{stream}".format(project=project, location=location, stream=stream, ) + + @staticmethod + def parse_stream_path(path: str) -> Dict[str,str]: + """Parses a stream path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/streams/(?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, DatastreamTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the datastream 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, DatastreamTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = client_options_lib.from_dict(client_options) + if client_options is None: + client_options = client_options_lib.ClientOptions() + + # Create SSL credentials for mutual TLS if needed. + use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) + + client_cert_source_func = None + is_mtls = False + if use_client_cert: + if client_options.client_cert_source: + is_mtls = True + client_cert_source_func = client_options.client_cert_source + else: + is_mtls = mtls.has_default_client_cert_source() + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + else: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_mtls_env == "never": + api_endpoint = self.DEFAULT_ENDPOINT + elif use_mtls_env == "always": + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + elif use_mtls_env == "auto": + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT + else: + raise MutualTLSChannelError( + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, DatastreamTransport): + # transport is a DatastreamTransport instance. + if credentials or client_options.credentials_file: + raise ValueError("When providing a transport instance, " + "provide its credentials directly.") + if client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = transport + else: + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=api_endpoint, + scopes=client_options.scopes, + client_cert_source_for_mtls=client_cert_source_func, + quota_project_id=client_options.quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + ) + + def list_connection_profiles(self, + request: Union[datastream.ListConnectionProfilesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListConnectionProfilesPager: + r"""Use this method to list connection profiles created + in a project and location. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.ListConnectionProfilesRequest, dict]): + The request object. + parent (str): + Required. The parent that owns the + collection of connection profiles. + + 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.datastream_v1alpha1.services.datastream.pagers.ListConnectionProfilesPager: + 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 datastream.ListConnectionProfilesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.ListConnectionProfilesRequest): + request = datastream.ListConnectionProfilesRequest(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_connection_profiles] + + # 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.ListConnectionProfilesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_connection_profile(self, + request: Union[datastream.GetConnectionProfileRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> datastream_resources.ConnectionProfile: + r"""Use this method to get details about a connection + profile. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.GetConnectionProfileRequest, dict]): + The request object. + name (str): + Required. The name of the connection + profile 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.datastream_v1alpha1.types.ConnectionProfile: + + """ + # Create or coerce a protobuf request object. + # Sanity 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 datastream.GetConnectionProfileRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.GetConnectionProfileRequest): + request = datastream.GetConnectionProfileRequest(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_connection_profile] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_connection_profile(self, + request: Union[datastream.CreateConnectionProfileRequest, dict] = None, + *, + parent: str = None, + connection_profile: datastream_resources.ConnectionProfile = None, + connection_profile_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Use this method to create a connection profile in a + project and location. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.CreateConnectionProfileRequest, dict]): + The request object. + parent (str): + Required. The parent that owns the + collection of ConnectionProfiles. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile): + Required. The connection profile + resource to create. + + This corresponds to the ``connection_profile`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + connection_profile_id (str): + Required. The connection profile + identifier. + + This corresponds to the ``connection_profile_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile` + + """ + # Create or coerce a protobuf request object. + # Sanity 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, connection_profile, connection_profile_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 datastream.CreateConnectionProfileRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.CreateConnectionProfileRequest): + request = datastream.CreateConnectionProfileRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if connection_profile is not None: + request.connection_profile = connection_profile + if connection_profile_id is not None: + request.connection_profile_id = connection_profile_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_connection_profile] + + # 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, + datastream_resources.ConnectionProfile, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_connection_profile(self, + request: Union[datastream.UpdateConnectionProfileRequest, dict] = None, + *, + connection_profile: datastream_resources.ConnectionProfile = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Use this method to update the parameters of a + connection profile. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.UpdateConnectionProfileRequest, dict]): + The request object. + connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile): + Required. The ConnectionProfile to + update. + + This corresponds to the ``connection_profile`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the ConnectionProfile resource by the + update. The fields specified in the update_mask are + relative to the resource, not the full request. A field + will be overwritten if it is in the mask. If the user + does not provide a mask then all fields will be + overwritten. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile` + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([connection_profile, 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 datastream.UpdateConnectionProfileRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.UpdateConnectionProfileRequest): + request = datastream.UpdateConnectionProfileRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if connection_profile is not None: + request.connection_profile = connection_profile + 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_connection_profile] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("connection_profile.name", request.connection_profile.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, + datastream_resources.ConnectionProfile, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_connection_profile(self, + request: Union[datastream.DeleteConnectionProfileRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Use this method to delete a connection profile.. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.DeleteConnectionProfileRequest, dict]): + The request object. + name (str): + Required. The name of the connection + profile resource 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 datastream.DeleteConnectionProfileRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.DeleteConnectionProfileRequest): + request = datastream.DeleteConnectionProfileRequest(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_connection_profile] + + # Certain fields should be provided 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=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + def discover_connection_profile(self, + request: Union[datastream.DiscoverConnectionProfileRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> datastream.DiscoverConnectionProfileResponse: + r"""Use this method to discover a connection profile. + The discover API call exposes the data objects and + metadata belonging to the profile. Typically, a request + returns children data objects under a parent data object + that's optionally supplied in the request. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.DiscoverConnectionProfileRequest, dict]): + The request object. Request message for 'discover' + ConnectionProfile request. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.datastream_v1alpha1.types.DiscoverConnectionProfileResponse: + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a datastream.DiscoverConnectionProfileRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.DiscoverConnectionProfileRequest): + request = datastream.DiscoverConnectionProfileRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.discover_connection_profile] + + # 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 list_streams(self, + request: Union[datastream.ListStreamsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListStreamsPager: + r"""Use this method to list streams in a project and + location. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.ListStreamsRequest, dict]): + The request object. + parent (str): + Required. The parent that owns the + collection of streams. + + 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.datastream_v1alpha1.services.datastream.pagers.ListStreamsPager: + 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 datastream.ListStreamsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.ListStreamsRequest): + request = datastream.ListStreamsRequest(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_streams] + + # 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.ListStreamsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_stream(self, + request: Union[datastream.GetStreamRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> datastream_resources.Stream: + r"""Use this method to get details about a stream. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.GetStreamRequest, dict]): + The request object. + name (str): + Required. The name of the stream + 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.datastream_v1alpha1.types.Stream: + + """ + # Create or coerce a protobuf request object. + # Sanity 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 datastream.GetStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.GetStreamRequest): + request = datastream.GetStreamRequest(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_stream] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_stream(self, + request: Union[datastream.CreateStreamRequest, dict] = None, + *, + parent: str = None, + stream: datastream_resources.Stream = None, + stream_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Use this method to create a stream. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.CreateStreamRequest, dict]): + The request object. + parent (str): + Required. The parent that owns the + collection of streams. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + stream (google.cloud.datastream_v1alpha1.types.Stream): + Required. The stream resource to + create. + + This corresponds to the ``stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + stream_id (str): + Required. The stream identifier. + This corresponds to the ``stream_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.datastream_v1alpha1.types.Stream` + + """ + # Create or coerce a protobuf request object. + # Sanity 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, stream, stream_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 datastream.CreateStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.CreateStreamRequest): + request = datastream.CreateStreamRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if stream is not None: + request.stream = stream + if stream_id is not None: + request.stream_id = stream_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_stream] + + # 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, + datastream_resources.Stream, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_stream(self, + request: Union[datastream.UpdateStreamRequest, dict] = None, + *, + stream: datastream_resources.Stream = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Use this method to update the configuration of a + stream. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.UpdateStreamRequest, dict]): + The request object. + stream (google.cloud.datastream_v1alpha1.types.Stream): + Required. The stream resource to + update. + + This corresponds to the ``stream`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the stream resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.datastream_v1alpha1.types.Stream` + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([stream, 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 datastream.UpdateStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.UpdateStreamRequest): + request = datastream.UpdateStreamRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if stream is not None: + request.stream = stream + 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_stream] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("stream.name", request.stream.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, + datastream_resources.Stream, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_stream(self, + request: Union[datastream.DeleteStreamRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Use this method to delete a stream. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.DeleteStreamRequest, dict]): + The request object. + name (str): + Required. The name of the stream + resource 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 datastream.DeleteStreamRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.DeleteStreamRequest): + request = datastream.DeleteStreamRequest(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_stream] + + # Certain fields should be provided 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=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + def fetch_errors(self, + request: Union[datastream.FetchErrorsRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Use this method to fetch any errors associated with a + stream. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.FetchErrorsRequest, dict]): + The request object. Request message for 'FetchErrors' + request. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout 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.datastream_v1alpha1.types.FetchErrorsResponse` + Response message for a 'FetchErrors' response. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a datastream.FetchErrorsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.FetchErrorsRequest): + request = datastream.FetchErrorsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.fetch_errors] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("stream", request.stream), + )), + ) + + # 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, + datastream.FetchErrorsResponse, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + def fetch_static_ips(self, + request: Union[datastream.FetchStaticIpsRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.FetchStaticIpsPager: + r"""The FetchStaticIps API call exposes the static ips + used by Datastream. Typically, a request returns + children data objects under a parent data object that's + optionally supplied in the request. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.FetchStaticIpsRequest, dict]): + The request object. Request message for 'FetchStaticIps' + request. + name (str): + Required. The name resource of the Response type. Must + be in the format ``projects/*/locations/*``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.datastream_v1alpha1.services.datastream.pagers.FetchStaticIpsPager: + Response message for a + 'FetchStaticIps' response. + 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([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 datastream.FetchStaticIpsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.FetchStaticIpsRequest): + request = datastream.FetchStaticIpsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.fetch_static_ips] + + # Certain fields should be provided 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, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.FetchStaticIpsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_private_connection(self, + request: Union[datastream.CreatePrivateConnectionRequest, dict] = None, + *, + parent: str = None, + private_connection: datastream_resources.PrivateConnection = None, + private_connection_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Use this method to create a private connectivity + configuration. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.CreatePrivateConnectionRequest, dict]): + The request object. + parent (str): + Required. The parent that owns the + collection of PrivateConnections. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + private_connection (google.cloud.datastream_v1alpha1.types.PrivateConnection): + Required. The Private Connectivity + resource to create. + + This corresponds to the ``private_connection`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + private_connection_id (str): + Required. The private connectivity + identifier. + + This corresponds to the ``private_connection_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.datastream_v1alpha1.types.PrivateConnection` The PrivateConnection resource is used to establish private connectivity + between Datastream and a customer's network. + + """ + # Create or coerce a protobuf request object. + # Sanity 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, private_connection, private_connection_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 datastream.CreatePrivateConnectionRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.CreatePrivateConnectionRequest): + request = datastream.CreatePrivateConnectionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if private_connection is not None: + request.private_connection = private_connection + if private_connection_id is not None: + request.private_connection_id = private_connection_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_private_connection] + + # 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, + datastream_resources.PrivateConnection, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_private_connection(self, + request: Union[datastream.GetPrivateConnectionRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> datastream_resources.PrivateConnection: + r"""Use this method to get details about a private + connectivity configuration. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.GetPrivateConnectionRequest, dict]): + The request object. + name (str): + Required. The name of the private + connectivity configuration 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.datastream_v1alpha1.types.PrivateConnection: + The PrivateConnection resource is + used to establish private connectivity + between Datastream and a customer's + network. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 datastream.GetPrivateConnectionRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.GetPrivateConnectionRequest): + request = datastream.GetPrivateConnectionRequest(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_private_connection] + + # Certain fields should be provided 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_private_connections(self, + request: Union[datastream.ListPrivateConnectionsRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPrivateConnectionsPager: + r"""Use this method to list private connectivity + configurations in a project and location. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsRequest, dict]): + The request object. + parent (str): + Required. The parent that owns the + collection of private connectivity + configurations. + + 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.datastream_v1alpha1.services.datastream.pagers.ListPrivateConnectionsPager: + 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 datastream.ListPrivateConnectionsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.ListPrivateConnectionsRequest): + request = datastream.ListPrivateConnectionsRequest(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_private_connections] + + # 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.ListPrivateConnectionsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_private_connection(self, + request: Union[datastream.DeletePrivateConnectionRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Use this method to delete a private connectivity + configuration. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.DeletePrivateConnectionRequest, dict]): + The request object. + name (str): + Required. The name of the private + connectivity configuration 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 datastream.DeletePrivateConnectionRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.DeletePrivateConnectionRequest): + request = datastream.DeletePrivateConnectionRequest(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_private_connection] + + # Certain fields should be provided 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=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_route(self, + request: Union[datastream.CreateRouteRequest, dict] = None, + *, + parent: str = None, + route: datastream_resources.Route = None, + route_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Use this method to create a route for a private + connectivity in a project and location. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.CreateRouteRequest, dict]): + The request object. route creation request + parent (str): + Required. The parent that owns the + collection of Routes. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + route (google.cloud.datastream_v1alpha1.types.Route): + Required. The Route resource to + create. + + This corresponds to the ``route`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + route_id (str): + Required. The Route identifier. + This corresponds to the ``route_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.datastream_v1alpha1.types.Route` The Route resource is the child of the PrivateConnection resource. + It used to define a route for a PrivateConnection + setup. + + """ + # Create or coerce a protobuf request object. + # Sanity 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, route, route_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 datastream.CreateRouteRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.CreateRouteRequest): + request = datastream.CreateRouteRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if route is not None: + request.route = route + if route_id is not None: + request.route_id = route_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_route] + + # 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, + datastream_resources.Route, + metadata_type=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_route(self, + request: Union[datastream.GetRouteRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> datastream_resources.Route: + r"""Use this method to get details about a route. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.GetRouteRequest, dict]): + The request object. route get request + name (str): + Required. The name of the Route + 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.datastream_v1alpha1.types.Route: + The Route resource is the child of + the PrivateConnection resource. It used + to define a route for a + PrivateConnection setup. + + """ + # Create or coerce a protobuf request object. + # Sanity 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 datastream.GetRouteRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.GetRouteRequest): + request = datastream.GetRouteRequest(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_route] + + # Certain fields should be provided 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_routes(self, + request: Union[datastream.ListRoutesRequest, dict] = None, + *, + parent: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListRoutesPager: + r"""Use this method to list routes created for a private + connectivity in a project and location. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.ListRoutesRequest, dict]): + The request object. route list request + parent (str): + Required. The parent that owns the + collection of Routess. + + 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.datastream_v1alpha1.services.datastream.pagers.ListRoutesPager: + route list response + 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 datastream.ListRoutesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.ListRoutesRequest): + request = datastream.ListRoutesRequest(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_routes] + + # 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.ListRoutesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_route(self, + request: Union[datastream.DeleteRouteRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Use this method to delete a route. + + Args: + request (Union[google.cloud.datastream_v1alpha1.types.DeleteRouteRequest, dict]): + The request object. route deletion request + name (str): + Required. The name of the Route + resource 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 datastream.DeleteRouteRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, datastream.DeleteRouteRequest): + request = datastream.DeleteRouteRequest(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_route] + + # Certain fields should be provided 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=datastream.OperationMetadata, + ) + + # Done; return the response. + return response + + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-datastream", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ( + "DatastreamClient", +) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/pagers.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/pagers.py new file mode 100644 index 0000000..f6aa368 --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/pagers.py @@ -0,0 +1,629 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator + +from google.cloud.datastream_v1alpha1.types import datastream +from google.cloud.datastream_v1alpha1.types import datastream_resources + + +class ListConnectionProfilesPager: + """A pager for iterating through ``list_connection_profiles`` requests. + + This class thinly wraps an initial + :class:`google.cloud.datastream_v1alpha1.types.ListConnectionProfilesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``connection_profiles`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListConnectionProfiles`` requests and continue to iterate + through the ``connection_profiles`` field on the + corresponding responses. + + All the usual :class:`google.cloud.datastream_v1alpha1.types.ListConnectionProfilesResponse` + 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[..., datastream.ListConnectionProfilesResponse], + request: datastream.ListConnectionProfilesRequest, + response: datastream.ListConnectionProfilesResponse, + *, + 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.datastream_v1alpha1.types.ListConnectionProfilesRequest): + The initial request object. + response (google.cloud.datastream_v1alpha1.types.ListConnectionProfilesResponse): + 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 = datastream.ListConnectionProfilesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[datastream.ListConnectionProfilesResponse]: + 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[datastream_resources.ConnectionProfile]: + for page in self.pages: + yield from page.connection_profiles + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListConnectionProfilesAsyncPager: + """A pager for iterating through ``list_connection_profiles`` requests. + + This class thinly wraps an initial + :class:`google.cloud.datastream_v1alpha1.types.ListConnectionProfilesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``connection_profiles`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListConnectionProfiles`` requests and continue to iterate + through the ``connection_profiles`` field on the + corresponding responses. + + All the usual :class:`google.cloud.datastream_v1alpha1.types.ListConnectionProfilesResponse` + 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[datastream.ListConnectionProfilesResponse]], + request: datastream.ListConnectionProfilesRequest, + response: datastream.ListConnectionProfilesResponse, + *, + 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.datastream_v1alpha1.types.ListConnectionProfilesRequest): + The initial request object. + response (google.cloud.datastream_v1alpha1.types.ListConnectionProfilesResponse): + 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 = datastream.ListConnectionProfilesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[datastream.ListConnectionProfilesResponse]: + 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[datastream_resources.ConnectionProfile]: + async def async_generator(): + async for page in self.pages: + for response in page.connection_profiles: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListStreamsPager: + """A pager for iterating through ``list_streams`` requests. + + This class thinly wraps an initial + :class:`google.cloud.datastream_v1alpha1.types.ListStreamsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``streams`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListStreams`` requests and continue to iterate + through the ``streams`` field on the + corresponding responses. + + All the usual :class:`google.cloud.datastream_v1alpha1.types.ListStreamsResponse` + 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[..., datastream.ListStreamsResponse], + request: datastream.ListStreamsRequest, + response: datastream.ListStreamsResponse, + *, + 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.datastream_v1alpha1.types.ListStreamsRequest): + The initial request object. + response (google.cloud.datastream_v1alpha1.types.ListStreamsResponse): + 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 = datastream.ListStreamsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[datastream.ListStreamsResponse]: + 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[datastream_resources.Stream]: + for page in self.pages: + yield from page.streams + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListStreamsAsyncPager: + """A pager for iterating through ``list_streams`` requests. + + This class thinly wraps an initial + :class:`google.cloud.datastream_v1alpha1.types.ListStreamsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``streams`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListStreams`` requests and continue to iterate + through the ``streams`` field on the + corresponding responses. + + All the usual :class:`google.cloud.datastream_v1alpha1.types.ListStreamsResponse` + 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[datastream.ListStreamsResponse]], + request: datastream.ListStreamsRequest, + response: datastream.ListStreamsResponse, + *, + 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.datastream_v1alpha1.types.ListStreamsRequest): + The initial request object. + response (google.cloud.datastream_v1alpha1.types.ListStreamsResponse): + 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 = datastream.ListStreamsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[datastream.ListStreamsResponse]: + 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[datastream_resources.Stream]: + async def async_generator(): + async for page in self.pages: + for response in page.streams: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class FetchStaticIpsPager: + """A pager for iterating through ``fetch_static_ips`` requests. + + This class thinly wraps an initial + :class:`google.cloud.datastream_v1alpha1.types.FetchStaticIpsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``static_ips`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``FetchStaticIps`` requests and continue to iterate + through the ``static_ips`` field on the + corresponding responses. + + All the usual :class:`google.cloud.datastream_v1alpha1.types.FetchStaticIpsResponse` + 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[..., datastream.FetchStaticIpsResponse], + request: datastream.FetchStaticIpsRequest, + response: datastream.FetchStaticIpsResponse, + *, + 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.datastream_v1alpha1.types.FetchStaticIpsRequest): + The initial request object. + response (google.cloud.datastream_v1alpha1.types.FetchStaticIpsResponse): + 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 = datastream.FetchStaticIpsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[datastream.FetchStaticIpsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[str]: + for page in self.pages: + yield from page.static_ips + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class FetchStaticIpsAsyncPager: + """A pager for iterating through ``fetch_static_ips`` requests. + + This class thinly wraps an initial + :class:`google.cloud.datastream_v1alpha1.types.FetchStaticIpsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``static_ips`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``FetchStaticIps`` requests and continue to iterate + through the ``static_ips`` field on the + corresponding responses. + + All the usual :class:`google.cloud.datastream_v1alpha1.types.FetchStaticIpsResponse` + 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[datastream.FetchStaticIpsResponse]], + request: datastream.FetchStaticIpsRequest, + response: datastream.FetchStaticIpsResponse, + *, + 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.datastream_v1alpha1.types.FetchStaticIpsRequest): + The initial request object. + response (google.cloud.datastream_v1alpha1.types.FetchStaticIpsResponse): + 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 = datastream.FetchStaticIpsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[datastream.FetchStaticIpsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[str]: + async def async_generator(): + async for page in self.pages: + for response in page.static_ips: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListPrivateConnectionsPager: + """A pager for iterating through ``list_private_connections`` requests. + + This class thinly wraps an initial + :class:`google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``private_connections`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListPrivateConnections`` requests and continue to iterate + through the ``private_connections`` field on the + corresponding responses. + + All the usual :class:`google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsResponse` + 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[..., datastream.ListPrivateConnectionsResponse], + request: datastream.ListPrivateConnectionsRequest, + response: datastream.ListPrivateConnectionsResponse, + *, + 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.datastream_v1alpha1.types.ListPrivateConnectionsRequest): + The initial request object. + response (google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsResponse): + 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 = datastream.ListPrivateConnectionsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[datastream.ListPrivateConnectionsResponse]: + 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[datastream_resources.PrivateConnection]: + for page in self.pages: + yield from page.private_connections + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListPrivateConnectionsAsyncPager: + """A pager for iterating through ``list_private_connections`` requests. + + This class thinly wraps an initial + :class:`google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``private_connections`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListPrivateConnections`` requests and continue to iterate + through the ``private_connections`` field on the + corresponding responses. + + All the usual :class:`google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsResponse` + 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[datastream.ListPrivateConnectionsResponse]], + request: datastream.ListPrivateConnectionsRequest, + response: datastream.ListPrivateConnectionsResponse, + *, + 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.datastream_v1alpha1.types.ListPrivateConnectionsRequest): + The initial request object. + response (google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsResponse): + 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 = datastream.ListPrivateConnectionsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[datastream.ListPrivateConnectionsResponse]: + 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[datastream_resources.PrivateConnection]: + async def async_generator(): + async for page in self.pages: + for response in page.private_connections: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListRoutesPager: + """A pager for iterating through ``list_routes`` requests. + + This class thinly wraps an initial + :class:`google.cloud.datastream_v1alpha1.types.ListRoutesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``routes`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListRoutes`` requests and continue to iterate + through the ``routes`` field on the + corresponding responses. + + All the usual :class:`google.cloud.datastream_v1alpha1.types.ListRoutesResponse` + 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[..., datastream.ListRoutesResponse], + request: datastream.ListRoutesRequest, + response: datastream.ListRoutesResponse, + *, + 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.datastream_v1alpha1.types.ListRoutesRequest): + The initial request object. + response (google.cloud.datastream_v1alpha1.types.ListRoutesResponse): + 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 = datastream.ListRoutesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[datastream.ListRoutesResponse]: + 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[datastream_resources.Route]: + for page in self.pages: + yield from page.routes + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListRoutesAsyncPager: + """A pager for iterating through ``list_routes`` requests. + + This class thinly wraps an initial + :class:`google.cloud.datastream_v1alpha1.types.ListRoutesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``routes`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListRoutes`` requests and continue to iterate + through the ``routes`` field on the + corresponding responses. + + All the usual :class:`google.cloud.datastream_v1alpha1.types.ListRoutesResponse` + 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[datastream.ListRoutesResponse]], + request: datastream.ListRoutesRequest, + response: datastream.ListRoutesResponse, + *, + 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.datastream_v1alpha1.types.ListRoutesRequest): + The initial request object. + response (google.cloud.datastream_v1alpha1.types.ListRoutesResponse): + 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 = datastream.ListRoutesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[datastream.ListRoutesResponse]: + 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[datastream_resources.Route]: + async def async_generator(): + async for page in self.pages: + for response in page.routes: + 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/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/__init__.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/__init__.py new file mode 100644 index 0000000..6563729 --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/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 DatastreamTransport +from .grpc import DatastreamGrpcTransport +from .grpc_asyncio import DatastreamGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[DatastreamTransport]] +_transport_registry['grpc'] = DatastreamGrpcTransport +_transport_registry['grpc_asyncio'] = DatastreamGrpcAsyncIOTransport + +__all__ = ( + 'DatastreamTransport', + 'DatastreamGrpcTransport', + 'DatastreamGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py new file mode 100644 index 0000000..336435f --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py @@ -0,0 +1,434 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.datastream_v1alpha1.types import datastream +from google.cloud.datastream_v1alpha1.types import datastream_resources +from google.longrunning import operations_pb2 # type: ignore + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + 'google-cloud-datastream', + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +class DatastreamTransport(abc.ABC): + """Abstract transport class for Datastream.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'datastream.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.list_connection_profiles: gapic_v1.method.wrap_method( + self.list_connection_profiles, + default_timeout=None, + client_info=client_info, + ), + self.get_connection_profile: gapic_v1.method.wrap_method( + self.get_connection_profile, + default_timeout=None, + client_info=client_info, + ), + self.create_connection_profile: gapic_v1.method.wrap_method( + self.create_connection_profile, + default_timeout=60.0, + client_info=client_info, + ), + self.update_connection_profile: gapic_v1.method.wrap_method( + self.update_connection_profile, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_connection_profile: gapic_v1.method.wrap_method( + self.delete_connection_profile, + default_timeout=60.0, + client_info=client_info, + ), + self.discover_connection_profile: gapic_v1.method.wrap_method( + self.discover_connection_profile, + default_timeout=None, + client_info=client_info, + ), + self.list_streams: gapic_v1.method.wrap_method( + self.list_streams, + default_timeout=None, + client_info=client_info, + ), + self.get_stream: gapic_v1.method.wrap_method( + self.get_stream, + default_timeout=None, + client_info=client_info, + ), + self.create_stream: gapic_v1.method.wrap_method( + self.create_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.update_stream: gapic_v1.method.wrap_method( + self.update_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_stream: gapic_v1.method.wrap_method( + self.delete_stream, + default_timeout=60.0, + client_info=client_info, + ), + self.fetch_errors: gapic_v1.method.wrap_method( + self.fetch_errors, + default_timeout=None, + client_info=client_info, + ), + self.fetch_static_ips: gapic_v1.method.wrap_method( + self.fetch_static_ips, + default_timeout=None, + client_info=client_info, + ), + self.create_private_connection: gapic_v1.method.wrap_method( + self.create_private_connection, + default_timeout=60.0, + client_info=client_info, + ), + self.get_private_connection: gapic_v1.method.wrap_method( + self.get_private_connection, + default_timeout=None, + client_info=client_info, + ), + self.list_private_connections: gapic_v1.method.wrap_method( + self.list_private_connections, + default_timeout=None, + client_info=client_info, + ), + self.delete_private_connection: gapic_v1.method.wrap_method( + self.delete_private_connection, + default_timeout=60.0, + client_info=client_info, + ), + self.create_route: gapic_v1.method.wrap_method( + self.create_route, + default_timeout=60.0, + client_info=client_info, + ), + self.get_route: gapic_v1.method.wrap_method( + self.get_route, + default_timeout=None, + client_info=client_info, + ), + self.list_routes: gapic_v1.method.wrap_method( + self.list_routes, + default_timeout=None, + client_info=client_info, + ), + self.delete_route: gapic_v1.method.wrap_method( + self.delete_route, + default_timeout=60.0, + client_info=client_info, + ), + } + + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + + @property + def operations_client(self): + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def list_connection_profiles(self) -> Callable[ + [datastream.ListConnectionProfilesRequest], + Union[ + datastream.ListConnectionProfilesResponse, + Awaitable[datastream.ListConnectionProfilesResponse] + ]]: + raise NotImplementedError() + + @property + def get_connection_profile(self) -> Callable[ + [datastream.GetConnectionProfileRequest], + Union[ + datastream_resources.ConnectionProfile, + Awaitable[datastream_resources.ConnectionProfile] + ]]: + raise NotImplementedError() + + @property + def create_connection_profile(self) -> Callable[ + [datastream.CreateConnectionProfileRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_connection_profile(self) -> Callable[ + [datastream.UpdateConnectionProfileRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_connection_profile(self) -> Callable[ + [datastream.DeleteConnectionProfileRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def discover_connection_profile(self) -> Callable[ + [datastream.DiscoverConnectionProfileRequest], + Union[ + datastream.DiscoverConnectionProfileResponse, + Awaitable[datastream.DiscoverConnectionProfileResponse] + ]]: + raise NotImplementedError() + + @property + def list_streams(self) -> Callable[ + [datastream.ListStreamsRequest], + Union[ + datastream.ListStreamsResponse, + Awaitable[datastream.ListStreamsResponse] + ]]: + raise NotImplementedError() + + @property + def get_stream(self) -> Callable[ + [datastream.GetStreamRequest], + Union[ + datastream_resources.Stream, + Awaitable[datastream_resources.Stream] + ]]: + raise NotImplementedError() + + @property + def create_stream(self) -> Callable[ + [datastream.CreateStreamRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_stream(self) -> Callable[ + [datastream.UpdateStreamRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_stream(self) -> Callable[ + [datastream.DeleteStreamRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def fetch_errors(self) -> Callable[ + [datastream.FetchErrorsRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def fetch_static_ips(self) -> Callable[ + [datastream.FetchStaticIpsRequest], + Union[ + datastream.FetchStaticIpsResponse, + Awaitable[datastream.FetchStaticIpsResponse] + ]]: + raise NotImplementedError() + + @property + def create_private_connection(self) -> Callable[ + [datastream.CreatePrivateConnectionRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_private_connection(self) -> Callable[ + [datastream.GetPrivateConnectionRequest], + Union[ + datastream_resources.PrivateConnection, + Awaitable[datastream_resources.PrivateConnection] + ]]: + raise NotImplementedError() + + @property + def list_private_connections(self) -> Callable[ + [datastream.ListPrivateConnectionsRequest], + Union[ + datastream.ListPrivateConnectionsResponse, + Awaitable[datastream.ListPrivateConnectionsResponse] + ]]: + raise NotImplementedError() + + @property + def delete_private_connection(self) -> Callable[ + [datastream.DeletePrivateConnectionRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_route(self) -> Callable[ + [datastream.CreateRouteRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_route(self) -> Callable[ + [datastream.GetRouteRequest], + Union[ + datastream_resources.Route, + Awaitable[datastream_resources.Route] + ]]: + raise NotImplementedError() + + @property + def list_routes(self) -> Callable[ + [datastream.ListRoutesRequest], + Union[ + datastream.ListRoutesResponse, + Awaitable[datastream.ListRoutesResponse] + ]]: + raise NotImplementedError() + + @property + def delete_route(self) -> Callable[ + [datastream.DeleteRouteRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + +__all__ = ( + 'DatastreamTransport', +) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py new file mode 100644 index 0000000..c23ca1f --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py @@ -0,0 +1,814 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.datastream_v1alpha1.types import datastream +from google.cloud.datastream_v1alpha1.types import datastream_resources +from google.longrunning import operations_pb2 # type: ignore +from .base import DatastreamTransport, DEFAULT_CLIENT_INFO + + +class DatastreamGrpcTransport(DatastreamTransport): + """gRPC backend transport for Datastream. + + Datastream service + + 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 = 'datastream.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 = 'datastream.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_connection_profiles(self) -> Callable[ + [datastream.ListConnectionProfilesRequest], + datastream.ListConnectionProfilesResponse]: + r"""Return a callable for the list connection profiles method over gRPC. + + Use this method to list connection profiles created + in a project and location. + + Returns: + Callable[[~.ListConnectionProfilesRequest], + ~.ListConnectionProfilesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_connection_profiles' not in self._stubs: + self._stubs['list_connection_profiles'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/ListConnectionProfiles', + request_serializer=datastream.ListConnectionProfilesRequest.serialize, + response_deserializer=datastream.ListConnectionProfilesResponse.deserialize, + ) + return self._stubs['list_connection_profiles'] + + @property + def get_connection_profile(self) -> Callable[ + [datastream.GetConnectionProfileRequest], + datastream_resources.ConnectionProfile]: + r"""Return a callable for the get connection profile method over gRPC. + + Use this method to get details about a connection + profile. + + Returns: + Callable[[~.GetConnectionProfileRequest], + ~.ConnectionProfile]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_connection_profile' not in self._stubs: + self._stubs['get_connection_profile'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/GetConnectionProfile', + request_serializer=datastream.GetConnectionProfileRequest.serialize, + response_deserializer=datastream_resources.ConnectionProfile.deserialize, + ) + return self._stubs['get_connection_profile'] + + @property + def create_connection_profile(self) -> Callable[ + [datastream.CreateConnectionProfileRequest], + operations_pb2.Operation]: + r"""Return a callable for the create connection profile method over gRPC. + + Use this method to create a connection profile in a + project and location. + + Returns: + Callable[[~.CreateConnectionProfileRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_connection_profile' not in self._stubs: + self._stubs['create_connection_profile'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/CreateConnectionProfile', + request_serializer=datastream.CreateConnectionProfileRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_connection_profile'] + + @property + def update_connection_profile(self) -> Callable[ + [datastream.UpdateConnectionProfileRequest], + operations_pb2.Operation]: + r"""Return a callable for the update connection profile method over gRPC. + + Use this method to update the parameters of a + connection profile. + + Returns: + Callable[[~.UpdateConnectionProfileRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_connection_profile' not in self._stubs: + self._stubs['update_connection_profile'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/UpdateConnectionProfile', + request_serializer=datastream.UpdateConnectionProfileRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_connection_profile'] + + @property + def delete_connection_profile(self) -> Callable[ + [datastream.DeleteConnectionProfileRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete connection profile method over gRPC. + + Use this method to delete a connection profile.. + + Returns: + Callable[[~.DeleteConnectionProfileRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_connection_profile' not in self._stubs: + self._stubs['delete_connection_profile'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/DeleteConnectionProfile', + request_serializer=datastream.DeleteConnectionProfileRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_connection_profile'] + + @property + def discover_connection_profile(self) -> Callable[ + [datastream.DiscoverConnectionProfileRequest], + datastream.DiscoverConnectionProfileResponse]: + r"""Return a callable for the discover connection profile method over gRPC. + + Use this method to discover a connection profile. + The discover API call exposes the data objects and + metadata belonging to the profile. Typically, a request + returns children data objects under a parent data object + that's optionally supplied in the request. + + Returns: + Callable[[~.DiscoverConnectionProfileRequest], + ~.DiscoverConnectionProfileResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'discover_connection_profile' not in self._stubs: + self._stubs['discover_connection_profile'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/DiscoverConnectionProfile', + request_serializer=datastream.DiscoverConnectionProfileRequest.serialize, + response_deserializer=datastream.DiscoverConnectionProfileResponse.deserialize, + ) + return self._stubs['discover_connection_profile'] + + @property + def list_streams(self) -> Callable[ + [datastream.ListStreamsRequest], + datastream.ListStreamsResponse]: + r"""Return a callable for the list streams method over gRPC. + + Use this method to list streams in a project and + location. + + Returns: + Callable[[~.ListStreamsRequest], + ~.ListStreamsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_streams' not in self._stubs: + self._stubs['list_streams'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/ListStreams', + request_serializer=datastream.ListStreamsRequest.serialize, + response_deserializer=datastream.ListStreamsResponse.deserialize, + ) + return self._stubs['list_streams'] + + @property + def get_stream(self) -> Callable[ + [datastream.GetStreamRequest], + datastream_resources.Stream]: + r"""Return a callable for the get stream method over gRPC. + + Use this method to get details about a stream. + + Returns: + Callable[[~.GetStreamRequest], + ~.Stream]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_stream' not in self._stubs: + self._stubs['get_stream'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/GetStream', + request_serializer=datastream.GetStreamRequest.serialize, + response_deserializer=datastream_resources.Stream.deserialize, + ) + return self._stubs['get_stream'] + + @property + def create_stream(self) -> Callable[ + [datastream.CreateStreamRequest], + operations_pb2.Operation]: + r"""Return a callable for the create stream method over gRPC. + + Use this method to create a stream. + + Returns: + Callable[[~.CreateStreamRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_stream' not in self._stubs: + self._stubs['create_stream'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/CreateStream', + request_serializer=datastream.CreateStreamRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_stream'] + + @property + def update_stream(self) -> Callable[ + [datastream.UpdateStreamRequest], + operations_pb2.Operation]: + r"""Return a callable for the update stream method over gRPC. + + Use this method to update the configuration of a + stream. + + Returns: + Callable[[~.UpdateStreamRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_stream' not in self._stubs: + self._stubs['update_stream'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/UpdateStream', + request_serializer=datastream.UpdateStreamRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_stream'] + + @property + def delete_stream(self) -> Callable[ + [datastream.DeleteStreamRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete stream method over gRPC. + + Use this method to delete a stream. + + Returns: + Callable[[~.DeleteStreamRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_stream' not in self._stubs: + self._stubs['delete_stream'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/DeleteStream', + request_serializer=datastream.DeleteStreamRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_stream'] + + @property + def fetch_errors(self) -> Callable[ + [datastream.FetchErrorsRequest], + operations_pb2.Operation]: + r"""Return a callable for the fetch errors method over gRPC. + + Use this method to fetch any errors associated with a + stream. + + Returns: + Callable[[~.FetchErrorsRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'fetch_errors' not in self._stubs: + self._stubs['fetch_errors'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/FetchErrors', + request_serializer=datastream.FetchErrorsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['fetch_errors'] + + @property + def fetch_static_ips(self) -> Callable[ + [datastream.FetchStaticIpsRequest], + datastream.FetchStaticIpsResponse]: + r"""Return a callable for the fetch static ips method over gRPC. + + The FetchStaticIps API call exposes the static ips + used by Datastream. Typically, a request returns + children data objects under a parent data object that's + optionally supplied in the request. + + Returns: + Callable[[~.FetchStaticIpsRequest], + ~.FetchStaticIpsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'fetch_static_ips' not in self._stubs: + self._stubs['fetch_static_ips'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/FetchStaticIps', + request_serializer=datastream.FetchStaticIpsRequest.serialize, + response_deserializer=datastream.FetchStaticIpsResponse.deserialize, + ) + return self._stubs['fetch_static_ips'] + + @property + def create_private_connection(self) -> Callable[ + [datastream.CreatePrivateConnectionRequest], + operations_pb2.Operation]: + r"""Return a callable for the create private connection method over gRPC. + + Use this method to create a private connectivity + configuration. + + Returns: + Callable[[~.CreatePrivateConnectionRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_private_connection' not in self._stubs: + self._stubs['create_private_connection'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/CreatePrivateConnection', + request_serializer=datastream.CreatePrivateConnectionRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_private_connection'] + + @property + def get_private_connection(self) -> Callable[ + [datastream.GetPrivateConnectionRequest], + datastream_resources.PrivateConnection]: + r"""Return a callable for the get private connection method over gRPC. + + Use this method to get details about a private + connectivity configuration. + + Returns: + Callable[[~.GetPrivateConnectionRequest], + ~.PrivateConnection]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_private_connection' not in self._stubs: + self._stubs['get_private_connection'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/GetPrivateConnection', + request_serializer=datastream.GetPrivateConnectionRequest.serialize, + response_deserializer=datastream_resources.PrivateConnection.deserialize, + ) + return self._stubs['get_private_connection'] + + @property + def list_private_connections(self) -> Callable[ + [datastream.ListPrivateConnectionsRequest], + datastream.ListPrivateConnectionsResponse]: + r"""Return a callable for the list private connections method over gRPC. + + Use this method to list private connectivity + configurations in a project and location. + + Returns: + Callable[[~.ListPrivateConnectionsRequest], + ~.ListPrivateConnectionsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_private_connections' not in self._stubs: + self._stubs['list_private_connections'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/ListPrivateConnections', + request_serializer=datastream.ListPrivateConnectionsRequest.serialize, + response_deserializer=datastream.ListPrivateConnectionsResponse.deserialize, + ) + return self._stubs['list_private_connections'] + + @property + def delete_private_connection(self) -> Callable[ + [datastream.DeletePrivateConnectionRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete private connection method over gRPC. + + Use this method to delete a private connectivity + configuration. + + Returns: + Callable[[~.DeletePrivateConnectionRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_private_connection' not in self._stubs: + self._stubs['delete_private_connection'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/DeletePrivateConnection', + request_serializer=datastream.DeletePrivateConnectionRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_private_connection'] + + @property + def create_route(self) -> Callable[ + [datastream.CreateRouteRequest], + operations_pb2.Operation]: + r"""Return a callable for the create route method over gRPC. + + Use this method to create a route for a private + connectivity in a project and location. + + Returns: + Callable[[~.CreateRouteRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_route' not in self._stubs: + self._stubs['create_route'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/CreateRoute', + request_serializer=datastream.CreateRouteRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_route'] + + @property + def get_route(self) -> Callable[ + [datastream.GetRouteRequest], + datastream_resources.Route]: + r"""Return a callable for the get route method over gRPC. + + Use this method to get details about a route. + + Returns: + Callable[[~.GetRouteRequest], + ~.Route]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_route' not in self._stubs: + self._stubs['get_route'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/GetRoute', + request_serializer=datastream.GetRouteRequest.serialize, + response_deserializer=datastream_resources.Route.deserialize, + ) + return self._stubs['get_route'] + + @property + def list_routes(self) -> Callable[ + [datastream.ListRoutesRequest], + datastream.ListRoutesResponse]: + r"""Return a callable for the list routes method over gRPC. + + Use this method to list routes created for a private + connectivity in a project and location. + + Returns: + Callable[[~.ListRoutesRequest], + ~.ListRoutesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_routes' not in self._stubs: + self._stubs['list_routes'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/ListRoutes', + request_serializer=datastream.ListRoutesRequest.serialize, + response_deserializer=datastream.ListRoutesResponse.deserialize, + ) + return self._stubs['list_routes'] + + @property + def delete_route(self) -> Callable[ + [datastream.DeleteRouteRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete route method over gRPC. + + Use this method to delete a route. + + Returns: + Callable[[~.DeleteRouteRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_route' not in self._stubs: + self._stubs['delete_route'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/DeleteRoute', + request_serializer=datastream.DeleteRouteRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_route'] + + def close(self): + self.grpc_channel.close() + +__all__ = ( + 'DatastreamGrpcTransport', +) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py new file mode 100644 index 0000000..857f17f --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py @@ -0,0 +1,818 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.datastream_v1alpha1.types import datastream +from google.cloud.datastream_v1alpha1.types import datastream_resources +from google.longrunning import operations_pb2 # type: ignore +from .base import DatastreamTransport, DEFAULT_CLIENT_INFO +from .grpc import DatastreamGrpcTransport + + +class DatastreamGrpcAsyncIOTransport(DatastreamTransport): + """gRPC AsyncIO backend transport for Datastream. + + Datastream service + + 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 = 'datastream.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 = 'datastream.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 list_connection_profiles(self) -> Callable[ + [datastream.ListConnectionProfilesRequest], + Awaitable[datastream.ListConnectionProfilesResponse]]: + r"""Return a callable for the list connection profiles method over gRPC. + + Use this method to list connection profiles created + in a project and location. + + Returns: + Callable[[~.ListConnectionProfilesRequest], + Awaitable[~.ListConnectionProfilesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_connection_profiles' not in self._stubs: + self._stubs['list_connection_profiles'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/ListConnectionProfiles', + request_serializer=datastream.ListConnectionProfilesRequest.serialize, + response_deserializer=datastream.ListConnectionProfilesResponse.deserialize, + ) + return self._stubs['list_connection_profiles'] + + @property + def get_connection_profile(self) -> Callable[ + [datastream.GetConnectionProfileRequest], + Awaitable[datastream_resources.ConnectionProfile]]: + r"""Return a callable for the get connection profile method over gRPC. + + Use this method to get details about a connection + profile. + + Returns: + Callable[[~.GetConnectionProfileRequest], + Awaitable[~.ConnectionProfile]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_connection_profile' not in self._stubs: + self._stubs['get_connection_profile'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/GetConnectionProfile', + request_serializer=datastream.GetConnectionProfileRequest.serialize, + response_deserializer=datastream_resources.ConnectionProfile.deserialize, + ) + return self._stubs['get_connection_profile'] + + @property + def create_connection_profile(self) -> Callable[ + [datastream.CreateConnectionProfileRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create connection profile method over gRPC. + + Use this method to create a connection profile in a + project and location. + + Returns: + Callable[[~.CreateConnectionProfileRequest], + 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_connection_profile' not in self._stubs: + self._stubs['create_connection_profile'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/CreateConnectionProfile', + request_serializer=datastream.CreateConnectionProfileRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_connection_profile'] + + @property + def update_connection_profile(self) -> Callable[ + [datastream.UpdateConnectionProfileRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update connection profile method over gRPC. + + Use this method to update the parameters of a + connection profile. + + Returns: + Callable[[~.UpdateConnectionProfileRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_connection_profile' not in self._stubs: + self._stubs['update_connection_profile'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/UpdateConnectionProfile', + request_serializer=datastream.UpdateConnectionProfileRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_connection_profile'] + + @property + def delete_connection_profile(self) -> Callable[ + [datastream.DeleteConnectionProfileRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete connection profile method over gRPC. + + Use this method to delete a connection profile.. + + Returns: + Callable[[~.DeleteConnectionProfileRequest], + 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_connection_profile' not in self._stubs: + self._stubs['delete_connection_profile'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/DeleteConnectionProfile', + request_serializer=datastream.DeleteConnectionProfileRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_connection_profile'] + + @property + def discover_connection_profile(self) -> Callable[ + [datastream.DiscoverConnectionProfileRequest], + Awaitable[datastream.DiscoverConnectionProfileResponse]]: + r"""Return a callable for the discover connection profile method over gRPC. + + Use this method to discover a connection profile. + The discover API call exposes the data objects and + metadata belonging to the profile. Typically, a request + returns children data objects under a parent data object + that's optionally supplied in the request. + + Returns: + Callable[[~.DiscoverConnectionProfileRequest], + Awaitable[~.DiscoverConnectionProfileResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'discover_connection_profile' not in self._stubs: + self._stubs['discover_connection_profile'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/DiscoverConnectionProfile', + request_serializer=datastream.DiscoverConnectionProfileRequest.serialize, + response_deserializer=datastream.DiscoverConnectionProfileResponse.deserialize, + ) + return self._stubs['discover_connection_profile'] + + @property + def list_streams(self) -> Callable[ + [datastream.ListStreamsRequest], + Awaitable[datastream.ListStreamsResponse]]: + r"""Return a callable for the list streams method over gRPC. + + Use this method to list streams in a project and + location. + + Returns: + Callable[[~.ListStreamsRequest], + Awaitable[~.ListStreamsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_streams' not in self._stubs: + self._stubs['list_streams'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/ListStreams', + request_serializer=datastream.ListStreamsRequest.serialize, + response_deserializer=datastream.ListStreamsResponse.deserialize, + ) + return self._stubs['list_streams'] + + @property + def get_stream(self) -> Callable[ + [datastream.GetStreamRequest], + Awaitable[datastream_resources.Stream]]: + r"""Return a callable for the get stream method over gRPC. + + Use this method to get details about a stream. + + Returns: + Callable[[~.GetStreamRequest], + Awaitable[~.Stream]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_stream' not in self._stubs: + self._stubs['get_stream'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/GetStream', + request_serializer=datastream.GetStreamRequest.serialize, + response_deserializer=datastream_resources.Stream.deserialize, + ) + return self._stubs['get_stream'] + + @property + def create_stream(self) -> Callable[ + [datastream.CreateStreamRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create stream method over gRPC. + + Use this method to create a stream. + + Returns: + Callable[[~.CreateStreamRequest], + 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_stream' not in self._stubs: + self._stubs['create_stream'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/CreateStream', + request_serializer=datastream.CreateStreamRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_stream'] + + @property + def update_stream(self) -> Callable[ + [datastream.UpdateStreamRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update stream method over gRPC. + + Use this method to update the configuration of a + stream. + + Returns: + Callable[[~.UpdateStreamRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_stream' not in self._stubs: + self._stubs['update_stream'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/UpdateStream', + request_serializer=datastream.UpdateStreamRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_stream'] + + @property + def delete_stream(self) -> Callable[ + [datastream.DeleteStreamRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete stream method over gRPC. + + Use this method to delete a stream. + + Returns: + Callable[[~.DeleteStreamRequest], + 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_stream' not in self._stubs: + self._stubs['delete_stream'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/DeleteStream', + request_serializer=datastream.DeleteStreamRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_stream'] + + @property + def fetch_errors(self) -> Callable[ + [datastream.FetchErrorsRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the fetch errors method over gRPC. + + Use this method to fetch any errors associated with a + stream. + + Returns: + Callable[[~.FetchErrorsRequest], + 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 'fetch_errors' not in self._stubs: + self._stubs['fetch_errors'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/FetchErrors', + request_serializer=datastream.FetchErrorsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['fetch_errors'] + + @property + def fetch_static_ips(self) -> Callable[ + [datastream.FetchStaticIpsRequest], + Awaitable[datastream.FetchStaticIpsResponse]]: + r"""Return a callable for the fetch static ips method over gRPC. + + The FetchStaticIps API call exposes the static ips + used by Datastream. Typically, a request returns + children data objects under a parent data object that's + optionally supplied in the request. + + Returns: + Callable[[~.FetchStaticIpsRequest], + Awaitable[~.FetchStaticIpsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'fetch_static_ips' not in self._stubs: + self._stubs['fetch_static_ips'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/FetchStaticIps', + request_serializer=datastream.FetchStaticIpsRequest.serialize, + response_deserializer=datastream.FetchStaticIpsResponse.deserialize, + ) + return self._stubs['fetch_static_ips'] + + @property + def create_private_connection(self) -> Callable[ + [datastream.CreatePrivateConnectionRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create private connection method over gRPC. + + Use this method to create a private connectivity + configuration. + + Returns: + Callable[[~.CreatePrivateConnectionRequest], + 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_private_connection' not in self._stubs: + self._stubs['create_private_connection'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/CreatePrivateConnection', + request_serializer=datastream.CreatePrivateConnectionRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_private_connection'] + + @property + def get_private_connection(self) -> Callable[ + [datastream.GetPrivateConnectionRequest], + Awaitable[datastream_resources.PrivateConnection]]: + r"""Return a callable for the get private connection method over gRPC. + + Use this method to get details about a private + connectivity configuration. + + Returns: + Callable[[~.GetPrivateConnectionRequest], + Awaitable[~.PrivateConnection]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_private_connection' not in self._stubs: + self._stubs['get_private_connection'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/GetPrivateConnection', + request_serializer=datastream.GetPrivateConnectionRequest.serialize, + response_deserializer=datastream_resources.PrivateConnection.deserialize, + ) + return self._stubs['get_private_connection'] + + @property + def list_private_connections(self) -> Callable[ + [datastream.ListPrivateConnectionsRequest], + Awaitable[datastream.ListPrivateConnectionsResponse]]: + r"""Return a callable for the list private connections method over gRPC. + + Use this method to list private connectivity + configurations in a project and location. + + Returns: + Callable[[~.ListPrivateConnectionsRequest], + Awaitable[~.ListPrivateConnectionsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_private_connections' not in self._stubs: + self._stubs['list_private_connections'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/ListPrivateConnections', + request_serializer=datastream.ListPrivateConnectionsRequest.serialize, + response_deserializer=datastream.ListPrivateConnectionsResponse.deserialize, + ) + return self._stubs['list_private_connections'] + + @property + def delete_private_connection(self) -> Callable[ + [datastream.DeletePrivateConnectionRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete private connection method over gRPC. + + Use this method to delete a private connectivity + configuration. + + Returns: + Callable[[~.DeletePrivateConnectionRequest], + 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_private_connection' not in self._stubs: + self._stubs['delete_private_connection'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/DeletePrivateConnection', + request_serializer=datastream.DeletePrivateConnectionRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_private_connection'] + + @property + def create_route(self) -> Callable[ + [datastream.CreateRouteRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create route method over gRPC. + + Use this method to create a route for a private + connectivity in a project and location. + + Returns: + Callable[[~.CreateRouteRequest], + 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_route' not in self._stubs: + self._stubs['create_route'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/CreateRoute', + request_serializer=datastream.CreateRouteRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_route'] + + @property + def get_route(self) -> Callable[ + [datastream.GetRouteRequest], + Awaitable[datastream_resources.Route]]: + r"""Return a callable for the get route method over gRPC. + + Use this method to get details about a route. + + Returns: + Callable[[~.GetRouteRequest], + Awaitable[~.Route]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_route' not in self._stubs: + self._stubs['get_route'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/GetRoute', + request_serializer=datastream.GetRouteRequest.serialize, + response_deserializer=datastream_resources.Route.deserialize, + ) + return self._stubs['get_route'] + + @property + def list_routes(self) -> Callable[ + [datastream.ListRoutesRequest], + Awaitable[datastream.ListRoutesResponse]]: + r"""Return a callable for the list routes method over gRPC. + + Use this method to list routes created for a private + connectivity in a project and location. + + Returns: + Callable[[~.ListRoutesRequest], + Awaitable[~.ListRoutesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_routes' not in self._stubs: + self._stubs['list_routes'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/ListRoutes', + request_serializer=datastream.ListRoutesRequest.serialize, + response_deserializer=datastream.ListRoutesResponse.deserialize, + ) + return self._stubs['list_routes'] + + @property + def delete_route(self) -> Callable[ + [datastream.DeleteRouteRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete route method over gRPC. + + Use this method to delete a route. + + Returns: + Callable[[~.DeleteRouteRequest], + 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_route' not in self._stubs: + self._stubs['delete_route'] = self.grpc_channel.unary_unary( + '/google.cloud.datastream.v1alpha1.Datastream/DeleteRoute', + request_serializer=datastream.DeleteRouteRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_route'] + + def close(self): + return self.grpc_channel.close() + + +__all__ = ( + 'DatastreamGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/__init__.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/__init__.py new file mode 100644 index 0000000..0aaa80a --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/__init__.py @@ -0,0 +1,148 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 .datastream import ( + CreateConnectionProfileRequest, + CreatePrivateConnectionRequest, + CreateRouteRequest, + CreateStreamRequest, + DeleteConnectionProfileRequest, + DeletePrivateConnectionRequest, + DeleteRouteRequest, + DeleteStreamRequest, + DiscoverConnectionProfileRequest, + DiscoverConnectionProfileResponse, + FetchErrorsRequest, + FetchErrorsResponse, + FetchStaticIpsRequest, + FetchStaticIpsResponse, + GetConnectionProfileRequest, + GetPrivateConnectionRequest, + GetRouteRequest, + GetStreamRequest, + ListConnectionProfilesRequest, + ListConnectionProfilesResponse, + ListPrivateConnectionsRequest, + ListPrivateConnectionsResponse, + ListRoutesRequest, + ListRoutesResponse, + ListStreamsRequest, + ListStreamsResponse, + OperationMetadata, + UpdateConnectionProfileRequest, + UpdateStreamRequest, +) +from .datastream_resources import ( + AvroFileFormat, + ConnectionProfile, + DestinationConfig, + Error, + ForwardSshTunnelConnectivity, + GcsDestinationConfig, + GcsProfile, + JsonFileFormat, + MysqlColumn, + MysqlDatabase, + MysqlProfile, + MysqlRdbms, + MysqlSourceConfig, + MysqlSslConfig, + MysqlTable, + NoConnectivitySettings, + OracleColumn, + OracleProfile, + OracleRdbms, + OracleSchema, + OracleSourceConfig, + OracleTable, + PrivateConnection, + PrivateConnectivity, + Route, + SourceConfig, + StaticServiceIpConnectivity, + Stream, + Validation, + ValidationMessage, + ValidationResult, + VpcPeeringConfig, + GcsFileFormat, + SchemaFileFormat, +) + +__all__ = ( + 'CreateConnectionProfileRequest', + 'CreatePrivateConnectionRequest', + 'CreateRouteRequest', + 'CreateStreamRequest', + 'DeleteConnectionProfileRequest', + 'DeletePrivateConnectionRequest', + 'DeleteRouteRequest', + 'DeleteStreamRequest', + 'DiscoverConnectionProfileRequest', + 'DiscoverConnectionProfileResponse', + 'FetchErrorsRequest', + 'FetchErrorsResponse', + 'FetchStaticIpsRequest', + 'FetchStaticIpsResponse', + 'GetConnectionProfileRequest', + 'GetPrivateConnectionRequest', + 'GetRouteRequest', + 'GetStreamRequest', + 'ListConnectionProfilesRequest', + 'ListConnectionProfilesResponse', + 'ListPrivateConnectionsRequest', + 'ListPrivateConnectionsResponse', + 'ListRoutesRequest', + 'ListRoutesResponse', + 'ListStreamsRequest', + 'ListStreamsResponse', + 'OperationMetadata', + 'UpdateConnectionProfileRequest', + 'UpdateStreamRequest', + 'AvroFileFormat', + 'ConnectionProfile', + 'DestinationConfig', + 'Error', + 'ForwardSshTunnelConnectivity', + 'GcsDestinationConfig', + 'GcsProfile', + 'JsonFileFormat', + 'MysqlColumn', + 'MysqlDatabase', + 'MysqlProfile', + 'MysqlRdbms', + 'MysqlSourceConfig', + 'MysqlSslConfig', + 'MysqlTable', + 'NoConnectivitySettings', + 'OracleColumn', + 'OracleProfile', + 'OracleRdbms', + 'OracleSchema', + 'OracleSourceConfig', + 'OracleTable', + 'PrivateConnection', + 'PrivateConnectivity', + 'Route', + 'SourceConfig', + 'StaticServiceIpConnectivity', + 'Stream', + 'Validation', + 'ValidationMessage', + 'ValidationResult', + 'VpcPeeringConfig', + 'GcsFileFormat', + 'SchemaFileFormat', +) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream.py new file mode 100644 index 0000000..44f8590 --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream.py @@ -0,0 +1,1195 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.datastream_v1alpha1.types import datastream_resources +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.datastream.v1alpha1', + manifest={ + 'DiscoverConnectionProfileRequest', + 'DiscoverConnectionProfileResponse', + 'FetchStaticIpsRequest', + 'FetchStaticIpsResponse', + 'FetchErrorsRequest', + 'FetchErrorsResponse', + 'ListConnectionProfilesRequest', + 'ListConnectionProfilesResponse', + 'GetConnectionProfileRequest', + 'CreateConnectionProfileRequest', + 'UpdateConnectionProfileRequest', + 'DeleteConnectionProfileRequest', + 'ListStreamsRequest', + 'ListStreamsResponse', + 'GetStreamRequest', + 'CreateStreamRequest', + 'UpdateStreamRequest', + 'DeleteStreamRequest', + 'OperationMetadata', + 'CreatePrivateConnectionRequest', + 'ListPrivateConnectionsRequest', + 'ListPrivateConnectionsResponse', + 'DeletePrivateConnectionRequest', + 'GetPrivateConnectionRequest', + 'CreateRouteRequest', + 'ListRoutesRequest', + 'ListRoutesResponse', + 'DeleteRouteRequest', + 'GetRouteRequest', + }, +) + + +class DiscoverConnectionProfileRequest(proto.Message): + r"""Request message for 'discover' ConnectionProfile request. + + 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: + parent (str): + Required. The parent resource of the ConnectionProfile type. + Must be in the format ``projects/*/locations/*``. + connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile): + An ad-hoc ConnectionProfile configuration. + This field is a member of `oneof`_ ``target``. + connection_profile_name (str): + A reference to an existing ConnectionProfile. + This field is a member of `oneof`_ ``target``. + recursive (bool): + Whether to retrieve the full hierarchy of + data objects (TRUE) or only the current level + (FALSE). + This field is a member of `oneof`_ ``depth``. + recursion_depth (int): + The number of hierarchy levels below the + current level to be retrieved. + This field is a member of `oneof`_ ``depth``. + oracle_rdbms (google.cloud.datastream_v1alpha1.types.OracleRdbms): + Oracle RDBMS to enrich with child data + objects and metadata. + This field is a member of `oneof`_ ``data_object``. + mysql_rdbms (google.cloud.datastream_v1alpha1.types.MysqlRdbms): + MySQL RDBMS to enrich with child data objects + and metadata. + This field is a member of `oneof`_ ``data_object``. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + connection_profile = proto.Field( + proto.MESSAGE, + number=200, + oneof='target', + message=datastream_resources.ConnectionProfile, + ) + connection_profile_name = proto.Field( + proto.STRING, + number=201, + oneof='target', + ) + recursive = proto.Field( + proto.BOOL, + number=3, + oneof='depth', + ) + recursion_depth = proto.Field( + proto.INT32, + number=4, + oneof='depth', + ) + oracle_rdbms = proto.Field( + proto.MESSAGE, + number=100, + oneof='data_object', + message=datastream_resources.OracleRdbms, + ) + mysql_rdbms = proto.Field( + proto.MESSAGE, + number=101, + oneof='data_object', + message=datastream_resources.MysqlRdbms, + ) + + +class DiscoverConnectionProfileResponse(proto.Message): + r""" + + 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: + oracle_rdbms (google.cloud.datastream_v1alpha1.types.OracleRdbms): + Enriched Oracle RDBMS object. + This field is a member of `oneof`_ ``data_object``. + mysql_rdbms (google.cloud.datastream_v1alpha1.types.MysqlRdbms): + Enriched MySQL RDBMS object. + This field is a member of `oneof`_ ``data_object``. + """ + + oracle_rdbms = proto.Field( + proto.MESSAGE, + number=100, + oneof='data_object', + message=datastream_resources.OracleRdbms, + ) + mysql_rdbms = proto.Field( + proto.MESSAGE, + number=101, + oneof='data_object', + message=datastream_resources.MysqlRdbms, + ) + + +class FetchStaticIpsRequest(proto.Message): + r"""Request message for 'FetchStaticIps' request. + + Attributes: + name (str): + Required. The name resource of the Response type. Must be in + the format ``projects/*/locations/*``. + page_size (int): + Maximum number of Ips to return, will likely + not be specified. + page_token (str): + A page token, received from a previous ``ListStaticIps`` + call. will likely not be specified. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + + +class FetchStaticIpsResponse(proto.Message): + r"""Response message for a 'FetchStaticIps' response. + + Attributes: + static_ips (Sequence[str]): + list of static ips by account + next_page_token (str): + A token that can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + static_ips = proto.RepeatedField( + proto.STRING, + number=1, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + + +class FetchErrorsRequest(proto.Message): + r"""Request message for 'FetchErrors' request. + + Attributes: + stream (str): + Name of the Stream resource for which to + fetch any errors. + """ + + stream = proto.Field( + proto.STRING, + number=1, + ) + + +class FetchErrorsResponse(proto.Message): + r"""Response message for a 'FetchErrors' response. + + Attributes: + errors (Sequence[google.cloud.datastream_v1alpha1.types.Error]): + The list of errors on the Stream. + """ + + errors = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=datastream_resources.Error, + ) + + +class ListConnectionProfilesRequest(proto.Message): + r""" + + Attributes: + parent (str): + Required. The parent that owns the collection + of connection profiles. + page_size (int): + Maximum number of connection profiles to + return. If unspecified, at most 50 connection + profiles will be returned. The maximum value is + 1000; values above 1000 will be coerced to 1000. + page_token (str): + Page token received from a previous + ``ListConnectionProfiles`` call. Provide this to retrieve + the subsequent page. + + When paginating, all other parameters provided to + ``ListConnectionProfiles`` must match the call that provided + the page token. + filter (str): + Filter request. + order_by (str): + Order by fields for the result. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListConnectionProfilesResponse(proto.Message): + r""" + + Attributes: + connection_profiles (Sequence[google.cloud.datastream_v1alpha1.types.ConnectionProfile]): + List of connection profiles. + 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. + unreachable (Sequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + connection_profiles = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=datastream_resources.ConnectionProfile, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetConnectionProfileRequest(proto.Message): + r""" + + Attributes: + name (str): + Required. The name of the connection profile + resource to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateConnectionProfileRequest(proto.Message): + r""" + + Attributes: + parent (str): + Required. The parent that owns the collection + of ConnectionProfiles. + connection_profile_id (str): + Required. The connection profile identifier. + connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile): + Required. The connection profile resource to + create. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes since the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + connection_profile_id = proto.Field( + proto.STRING, + number=2, + ) + connection_profile = proto.Field( + proto.MESSAGE, + number=3, + message=datastream_resources.ConnectionProfile, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class UpdateConnectionProfileRequest(proto.Message): + r""" + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the ConnectionProfile resource by the update. + The fields specified in the update_mask are relative to the + resource, not the full request. A field will be overwritten + if it is in the mask. If the user does not provide a mask + then all fields will be overwritten. + connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile): + Required. The ConnectionProfile to update. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes since the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + update_mask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + connection_profile = proto.Field( + proto.MESSAGE, + number=2, + message=datastream_resources.ConnectionProfile, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + + +class DeleteConnectionProfileRequest(proto.Message): + r""" + + Attributes: + name (str): + Required. The name of the connection profile + resource to delete. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class ListStreamsRequest(proto.Message): + r""" + + Attributes: + parent (str): + Required. The parent that owns the collection + of streams. + page_size (int): + Maximum number of streams to return. + If unspecified, at most 50 streams will be + returned. The maximum value is 1000; values + above 1000 will be coerced to 1000. + page_token (str): + Page token received from a previous ``ListStreams`` call. + Provide this to retrieve the subsequent page. + + When paginating, all other parameters provided to + ``ListStreams`` must match the call that provided the page + token. + filter (str): + Filter request. + order_by (str): + Order by fields for the result. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListStreamsResponse(proto.Message): + r""" + + Attributes: + streams (Sequence[google.cloud.datastream_v1alpha1.types.Stream]): + List of streams + 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. + unreachable (Sequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + streams = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=datastream_resources.Stream, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetStreamRequest(proto.Message): + r""" + + Attributes: + name (str): + Required. The name of the stream resource to + get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateStreamRequest(proto.Message): + r""" + + Attributes: + parent (str): + Required. The parent that owns the collection + of streams. + stream_id (str): + Required. The stream identifier. + stream (google.cloud.datastream_v1alpha1.types.Stream): + Required. The stream resource to create. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes since the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + validate_only (bool): + Optional. Only validate the stream, but do + not create any resources. The default is false. + force (bool): + Optional. Create the stream without + validating it. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + stream_id = proto.Field( + proto.STRING, + number=2, + ) + stream = proto.Field( + proto.MESSAGE, + number=3, + message=datastream_resources.Stream, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + validate_only = proto.Field( + proto.BOOL, + number=5, + ) + force = proto.Field( + proto.BOOL, + number=6, + ) + + +class UpdateStreamRequest(proto.Message): + r""" + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the stream resource by the update. The fields + specified in the update_mask are relative to the resource, + not the full request. A field will be overwritten if it is + in the mask. If the user does not provide a mask then all + fields will be overwritten. + stream (google.cloud.datastream_v1alpha1.types.Stream): + Required. The stream resource to update. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes since the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + validate_only (bool): + Optional. Only validate the stream with the + changes, without actually updating it. The + default is false. + force (bool): + Optional. Execute the update without + validating it. + """ + + update_mask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + stream = proto.Field( + proto.MESSAGE, + number=2, + message=datastream_resources.Stream, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + validate_only = proto.Field( + proto.BOOL, + number=4, + ) + force = proto.Field( + proto.BOOL, + number=5, + ) + + +class DeleteStreamRequest(proto.Message): + r""" + + Attributes: + name (str): + Required. The name of the stream resource to + delete. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class OperationMetadata(proto.Message): + r"""Represents the metadata of the long-running operation. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + target (str): + Output only. Server-defined resource path for + the target of the operation. + verb (str): + Output only. Name of the verb executed by the + operation. + status_message (str): + Output only. Human-readable status of the + operation, if any. + requested_cancellation (bool): + Output only. Identifies whether the user has requested + cancellation of the operation. Operations that have + successfully been cancelled have [Operation.error][] value + with a [google.rpc.Status.code][google.rpc.Status.code] of + 1, corresponding to ``Code.CANCELLED``. + api_version (str): + Output only. API version used to start the + operation. + validation_result (google.cloud.datastream_v1alpha1.types.ValidationResult): + Output only. Results of executed validations + if there are any. + """ + + create_time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + target = proto.Field( + proto.STRING, + number=3, + ) + verb = proto.Field( + proto.STRING, + number=4, + ) + status_message = proto.Field( + proto.STRING, + number=5, + ) + requested_cancellation = proto.Field( + proto.BOOL, + number=6, + ) + api_version = proto.Field( + proto.STRING, + number=7, + ) + validation_result = proto.Field( + proto.MESSAGE, + number=8, + message=datastream_resources.ValidationResult, + ) + + +class CreatePrivateConnectionRequest(proto.Message): + r""" + + Attributes: + parent (str): + Required. The parent that owns the collection + of PrivateConnections. + private_connection_id (str): + Required. The private connectivity + identifier. + private_connection (google.cloud.datastream_v1alpha1.types.PrivateConnection): + Required. The Private Connectivity resource + to create. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes since the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + private_connection_id = proto.Field( + proto.STRING, + number=2, + ) + private_connection = proto.Field( + proto.MESSAGE, + number=3, + message=datastream_resources.PrivateConnection, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class ListPrivateConnectionsRequest(proto.Message): + r""" + + Attributes: + parent (str): + Required. The parent that owns the collection + of private connectivity configurations. + page_size (int): + Maximum number of private connectivity + configurations to return. If unspecified, at + most 50 private connectivity configurations that + will be returned. The maximum value is 1000; + values above 1000 will be coerced to 1000. + page_token (str): + Page token received from a previous + ``ListPrivateConnections`` call. Provide this to retrieve + the subsequent page. + + When paginating, all other parameters provided to + ``ListPrivateConnections`` must match the call that provided + the page token. + filter (str): + Filter request. + order_by (str): + Order by fields for the result. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListPrivateConnectionsResponse(proto.Message): + r""" + + Attributes: + private_connections (Sequence[google.cloud.datastream_v1alpha1.types.PrivateConnection]): + List of private connectivity configurations. + 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. + unreachable (Sequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + private_connections = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=datastream_resources.PrivateConnection, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class DeletePrivateConnectionRequest(proto.Message): + r""" + + Attributes: + name (str): + Required. The name of the private + connectivity configuration to delete. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + force (bool): + Optional. If set to true, any child routes + that belong to this PrivateConnection will also + be deleted. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + force = proto.Field( + proto.BOOL, + number=3, + ) + + +class GetPrivateConnectionRequest(proto.Message): + r""" + + Attributes: + name (str): + Required. The name of the private + connectivity configuration to get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateRouteRequest(proto.Message): + r"""route creation request + + Attributes: + parent (str): + Required. The parent that owns the collection + of Routes. + route_id (str): + Required. The Route identifier. + route (google.cloud.datastream_v1alpha1.types.Route): + Required. The Route resource to create. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes since the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + route_id = proto.Field( + proto.STRING, + number=2, + ) + route = proto.Field( + proto.MESSAGE, + number=3, + message=datastream_resources.Route, + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) + + +class ListRoutesRequest(proto.Message): + r"""route list request + + Attributes: + parent (str): + Required. The parent that owns the collection + of Routess. + page_size (int): + Maximum number of Routes to return. The + service may return fewer than this value. If + unspecified, at most 50 Routes will be returned. + The maximum value is 1000; values above 1000 + will be coerced to 1000. + page_token (str): + Page token received from a previous ``ListRoutes`` call. + Provide this to retrieve the subsequent page. + + When paginating, all other parameters provided to + ``ListRoutes`` must match the call that provided the page + token. + filter (str): + Filter request. + order_by (str): + Order by fields for the result. + """ + + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) + order_by = proto.Field( + proto.STRING, + number=5, + ) + + +class ListRoutesResponse(proto.Message): + r"""route list response + + Attributes: + routes (Sequence[google.cloud.datastream_v1alpha1.types.Route]): + List of Routes. + 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. + unreachable (Sequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + routes = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=datastream_resources.Route, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class DeleteRouteRequest(proto.Message): + r"""route deletion request + + Attributes: + name (str): + Required. The name of the Route resource to + delete. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. The server will guarantee that for at + least 60 minutes after the first request. + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + + +class GetRouteRequest(proto.Message): + r"""route get request + + Attributes: + name (str): + Required. The name of the Route resource to + get. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream_resources.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream_resources.py new file mode 100644 index 0000000..1dcda3e --- /dev/null +++ b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream_resources.py @@ -0,0 +1,1311 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.datastream.v1alpha1', + manifest={ + 'GcsFileFormat', + 'SchemaFileFormat', + 'OracleProfile', + 'MysqlProfile', + 'GcsProfile', + 'NoConnectivitySettings', + 'StaticServiceIpConnectivity', + 'ForwardSshTunnelConnectivity', + 'VpcPeeringConfig', + 'PrivateConnection', + 'PrivateConnectivity', + 'Route', + 'MysqlSslConfig', + 'ConnectionProfile', + 'OracleColumn', + 'OracleTable', + 'OracleSchema', + 'OracleRdbms', + 'OracleSourceConfig', + 'MysqlColumn', + 'MysqlTable', + 'MysqlDatabase', + 'MysqlRdbms', + 'MysqlSourceConfig', + 'SourceConfig', + 'AvroFileFormat', + 'JsonFileFormat', + 'GcsDestinationConfig', + 'DestinationConfig', + 'Stream', + 'Error', + 'ValidationResult', + 'Validation', + 'ValidationMessage', + }, +) + + +class GcsFileFormat(proto.Enum): + r"""File format in Cloud Storage.""" + _pb_options = {'deprecated': True} + GCS_FILE_FORMAT_UNSPECIFIED = 0 + AVRO = 1 + + +class SchemaFileFormat(proto.Enum): + r"""Schema file format.""" + SCHEMA_FILE_FORMAT_UNSPECIFIED = 0 + NO_SCHEMA_FILE = 1 + AVRO_SCHEMA_FILE = 2 + + +class OracleProfile(proto.Message): + r"""Oracle database profile. + + Attributes: + hostname (str): + Required. Hostname for the Oracle connection. + port (int): + Port for the Oracle connection, default value + is 1521. + username (str): + Required. Username for the Oracle connection. + password (str): + Required. Password for the Oracle connection. + database_service (str): + Required. Database for the Oracle connection. + connection_attributes (Sequence[google.cloud.datastream_v1alpha1.types.OracleProfile.ConnectionAttributesEntry]): + Connection string attributes + """ + + hostname = proto.Field( + proto.STRING, + number=1, + ) + port = proto.Field( + proto.INT32, + number=2, + ) + username = proto.Field( + proto.STRING, + number=3, + ) + password = proto.Field( + proto.STRING, + number=4, + ) + database_service = proto.Field( + proto.STRING, + number=5, + ) + connection_attributes = proto.MapField( + proto.STRING, + proto.STRING, + number=6, + ) + + +class MysqlProfile(proto.Message): + r"""MySQL database profile. + + Attributes: + hostname (str): + Required. Hostname for the MySQL connection. + port (int): + Port for the MySQL connection, default value + is 3306. + username (str): + Required. Username for the MySQL connection. + password (str): + Required. Input only. Password for the MySQL + connection. + ssl_config (google.cloud.datastream_v1alpha1.types.MysqlSslConfig): + SSL configuration for the MySQL connection. + """ + + hostname = proto.Field( + proto.STRING, + number=1, + ) + port = proto.Field( + proto.INT32, + number=2, + ) + username = proto.Field( + proto.STRING, + number=3, + ) + password = proto.Field( + proto.STRING, + number=4, + ) + ssl_config = proto.Field( + proto.MESSAGE, + number=5, + message='MysqlSslConfig', + ) + + +class GcsProfile(proto.Message): + r"""Cloud Storage bucket profile. + + Attributes: + bucket_name (str): + Required. The full project and resource path + for Cloud Storage bucket including the name. + root_path (str): + The root path inside the Cloud Storage + bucket. + """ + + bucket_name = proto.Field( + proto.STRING, + number=1, + ) + root_path = proto.Field( + proto.STRING, + number=2, + ) + + +class NoConnectivitySettings(proto.Message): + r"""No connectivity settings. + """ + + +class StaticServiceIpConnectivity(proto.Message): + r"""Static IP address connectivity. + """ + + +class ForwardSshTunnelConnectivity(proto.Message): + r"""Forward SSH Tunnel connectivity. + + 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: + hostname (str): + Required. Hostname for the SSH tunnel. + username (str): + Required. Username for the SSH tunnel. + port (int): + Port for the SSH tunnel, default value is 22. + password (str): + Input only. SSH password. + This field is a member of `oneof`_ ``authentication_method``. + private_key (str): + Input only. SSH private key. + This field is a member of `oneof`_ ``authentication_method``. + """ + + hostname = proto.Field( + proto.STRING, + number=1, + ) + username = proto.Field( + proto.STRING, + number=2, + ) + port = proto.Field( + proto.INT32, + number=3, + ) + password = proto.Field( + proto.STRING, + number=100, + oneof='authentication_method', + ) + private_key = proto.Field( + proto.STRING, + number=101, + oneof='authentication_method', + ) + + +class VpcPeeringConfig(proto.Message): + r"""The VPC Peering configuration is used to create VPC peering + between Datastream and the consumer's VPC. + + Attributes: + vpc_name (str): + Required. fully qualified name of the VPC + Datastream will peer to. + subnet (str): + Required. A free subnet for peering. (CIDR of + /29) + """ + + vpc_name = proto.Field( + proto.STRING, + number=1, + ) + subnet = proto.Field( + proto.STRING, + number=2, + ) + + +class PrivateConnection(proto.Message): + r"""The PrivateConnection resource is used to establish private + connectivity between Datastream and a customer's network. + + Attributes: + name (str): + Output only. The resource's name. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The create time of the resource. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The update time of the resource. + labels (Sequence[google.cloud.datastream_v1alpha1.types.PrivateConnection.LabelsEntry]): + Labels. + display_name (str): + Required. Display name. + state (google.cloud.datastream_v1alpha1.types.PrivateConnection.State): + Output only. The state of the Private + Connection. + error (google.cloud.datastream_v1alpha1.types.Error): + Output only. In case of error, the details of + the error in a user-friendly format. + vpc_peering_config (google.cloud.datastream_v1alpha1.types.VpcPeeringConfig): + VPC Peering Config + """ + class State(proto.Enum): + r"""Private Connection state.""" + STATE_UNSPECIFIED = 0 + CREATING = 1 + CREATED = 2 + FAILED = 3 + + 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, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + display_name = proto.Field( + proto.STRING, + number=5, + ) + state = proto.Field( + proto.ENUM, + number=6, + enum=State, + ) + error = proto.Field( + proto.MESSAGE, + number=7, + message='Error', + ) + vpc_peering_config = proto.Field( + proto.MESSAGE, + number=100, + message='VpcPeeringConfig', + ) + + +class PrivateConnectivity(proto.Message): + r"""Private Connectivity + + Attributes: + private_connection_name (str): + + """ + + private_connection_name = proto.Field( + proto.STRING, + number=1, + ) + + +class Route(proto.Message): + r"""The Route resource is the child of the PrivateConnection + resource. It used to define a route for a PrivateConnection + setup. + + Attributes: + name (str): + Output only. The resource's name. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The create time of the resource. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The update time of the resource. + labels (Sequence[google.cloud.datastream_v1alpha1.types.Route.LabelsEntry]): + Labels. + display_name (str): + Required. Display name. + destination_address (str): + Required. Destination address for connection + destination_port (int): + Destination port for connection + """ + + 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, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + display_name = proto.Field( + proto.STRING, + number=5, + ) + destination_address = proto.Field( + proto.STRING, + number=6, + ) + destination_port = proto.Field( + proto.INT32, + number=7, + ) + + +class MysqlSslConfig(proto.Message): + r"""MySQL SSL configuration information. + + Attributes: + client_key (str): + Input only. PEM-encoded private key associated with the + Client Certificate. If this field is used then the + 'client_certificate' and the 'ca_certificate' fields are + mandatory. + client_key_set (bool): + Output only. Indicates whether the client_key field is set. + client_certificate (str): + Input only. PEM-encoded certificate that will be used by the + replica to authenticate against the source database server. + If this field is used then the 'client_key' and the + 'ca_certificate' fields are mandatory. + client_certificate_set (bool): + Output only. Indicates whether the client_certificate field + is set. + ca_certificate (str): + Input only. PEM-encoded certificate of the CA + that signed the source database server's + certificate. + ca_certificate_set (bool): + Output only. Indicates whether the ca_certificate field is + set. + """ + + client_key = proto.Field( + proto.STRING, + number=11, + ) + client_key_set = proto.Field( + proto.BOOL, + number=12, + ) + client_certificate = proto.Field( + proto.STRING, + number=13, + ) + client_certificate_set = proto.Field( + proto.BOOL, + number=14, + ) + ca_certificate = proto.Field( + proto.STRING, + number=15, + ) + ca_certificate_set = proto.Field( + proto.BOOL, + number=16, + ) + + +class ConnectionProfile(proto.Message): + r""" + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + Output only. The resource's name. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The create time of the resource. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The update time of the resource. + labels (Sequence[google.cloud.datastream_v1alpha1.types.ConnectionProfile.LabelsEntry]): + Labels. + display_name (str): + Required. Display name. + oracle_profile (google.cloud.datastream_v1alpha1.types.OracleProfile): + Oracle ConnectionProfile configuration. + This field is a member of `oneof`_ ``profile``. + gcs_profile (google.cloud.datastream_v1alpha1.types.GcsProfile): + Cloud Storage ConnectionProfile + configuration. + This field is a member of `oneof`_ ``profile``. + mysql_profile (google.cloud.datastream_v1alpha1.types.MysqlProfile): + MySQL ConnectionProfile configuration. + This field is a member of `oneof`_ ``profile``. + no_connectivity (google.cloud.datastream_v1alpha1.types.NoConnectivitySettings): + No connectivity option chosen. + This field is a member of `oneof`_ ``connectivity``. + static_service_ip_connectivity (google.cloud.datastream_v1alpha1.types.StaticServiceIpConnectivity): + Static Service IP connectivity. + This field is a member of `oneof`_ ``connectivity``. + forward_ssh_connectivity (google.cloud.datastream_v1alpha1.types.ForwardSshTunnelConnectivity): + Forward SSH tunnel connectivity. + This field is a member of `oneof`_ ``connectivity``. + private_connectivity (google.cloud.datastream_v1alpha1.types.PrivateConnectivity): + Private connectivity. + This field is a member of `oneof`_ ``connectivity``. + """ + + 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, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + display_name = proto.Field( + proto.STRING, + number=5, + ) + oracle_profile = proto.Field( + proto.MESSAGE, + number=100, + oneof='profile', + message='OracleProfile', + ) + gcs_profile = proto.Field( + proto.MESSAGE, + number=101, + oneof='profile', + message='GcsProfile', + ) + mysql_profile = proto.Field( + proto.MESSAGE, + number=102, + oneof='profile', + message='MysqlProfile', + ) + no_connectivity = proto.Field( + proto.MESSAGE, + number=200, + oneof='connectivity', + message='NoConnectivitySettings', + ) + static_service_ip_connectivity = proto.Field( + proto.MESSAGE, + number=201, + oneof='connectivity', + message='StaticServiceIpConnectivity', + ) + forward_ssh_connectivity = proto.Field( + proto.MESSAGE, + number=202, + oneof='connectivity', + message='ForwardSshTunnelConnectivity', + ) + private_connectivity = proto.Field( + proto.MESSAGE, + number=203, + oneof='connectivity', + message='PrivateConnectivity', + ) + + +class OracleColumn(proto.Message): + r"""Oracle Column. + + Attributes: + column_name (str): + Column name. + data_type (str): + The Oracle data type. + length (int): + Column length. + precision (int): + Column precision. + scale (int): + Column scale. + encoding (str): + Column encoding. + primary_key (bool): + Whether or not the column represents a + primary key. + nullable (bool): + Whether or not the column can accept a null + value. + ordinal_position (int): + The ordinal position of the column in the + table. + """ + + column_name = proto.Field( + proto.STRING, + number=1, + ) + data_type = proto.Field( + proto.STRING, + number=2, + ) + length = proto.Field( + proto.INT32, + number=3, + ) + precision = proto.Field( + proto.INT32, + number=4, + ) + scale = proto.Field( + proto.INT32, + number=5, + ) + encoding = proto.Field( + proto.STRING, + number=6, + ) + primary_key = proto.Field( + proto.BOOL, + number=7, + ) + nullable = proto.Field( + proto.BOOL, + number=8, + ) + ordinal_position = proto.Field( + proto.INT32, + number=9, + ) + + +class OracleTable(proto.Message): + r"""Oracle table. + + Attributes: + table_name (str): + Table name. + oracle_columns (Sequence[google.cloud.datastream_v1alpha1.types.OracleColumn]): + Oracle columns in the schema. + When unspecified as part of inclue/exclude + lists, includes/excludes everything. + """ + + table_name = proto.Field( + proto.STRING, + number=1, + ) + oracle_columns = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='OracleColumn', + ) + + +class OracleSchema(proto.Message): + r"""Oracle schema. + + Attributes: + schema_name (str): + Schema name. + oracle_tables (Sequence[google.cloud.datastream_v1alpha1.types.OracleTable]): + Tables in the schema. + """ + + schema_name = proto.Field( + proto.STRING, + number=1, + ) + oracle_tables = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='OracleTable', + ) + + +class OracleRdbms(proto.Message): + r"""Oracle database structure. + + Attributes: + oracle_schemas (Sequence[google.cloud.datastream_v1alpha1.types.OracleSchema]): + Oracle schemas/databases in the database + server. + """ + + oracle_schemas = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='OracleSchema', + ) + + +class OracleSourceConfig(proto.Message): + r"""Oracle data source configuration + + Attributes: + allowlist (google.cloud.datastream_v1alpha1.types.OracleRdbms): + Oracle objects to include in the stream. + rejectlist (google.cloud.datastream_v1alpha1.types.OracleRdbms): + Oracle objects to exclude from the stream. + """ + + allowlist = proto.Field( + proto.MESSAGE, + number=1, + message='OracleRdbms', + ) + rejectlist = proto.Field( + proto.MESSAGE, + number=2, + message='OracleRdbms', + ) + + +class MysqlColumn(proto.Message): + r"""MySQL Column. + + Attributes: + column_name (str): + Column name. + data_type (str): + The MySQL data type. Full data types list can + be found here: + https://dev.mysql.com/doc/refman/8.0/en/data- + types.html + length (int): + Column length. + collation (str): + Column collation. + primary_key (bool): + Whether or not the column represents a + primary key. + nullable (bool): + Whether or not the column can accept a null + value. + ordinal_position (int): + The ordinal position of the column in the + table. + """ + + column_name = proto.Field( + proto.STRING, + number=1, + ) + data_type = proto.Field( + proto.STRING, + number=2, + ) + length = proto.Field( + proto.INT32, + number=3, + ) + collation = proto.Field( + proto.STRING, + number=4, + ) + primary_key = proto.Field( + proto.BOOL, + number=5, + ) + nullable = proto.Field( + proto.BOOL, + number=6, + ) + ordinal_position = proto.Field( + proto.INT32, + number=7, + ) + + +class MysqlTable(proto.Message): + r"""MySQL table. + + Attributes: + table_name (str): + Table name. + mysql_columns (Sequence[google.cloud.datastream_v1alpha1.types.MysqlColumn]): + MySQL columns in the database. + When unspecified as part of include/exclude + lists, includes/excludes everything. + """ + + table_name = proto.Field( + proto.STRING, + number=1, + ) + mysql_columns = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='MysqlColumn', + ) + + +class MysqlDatabase(proto.Message): + r"""MySQL database. + + Attributes: + database_name (str): + Database name. + mysql_tables (Sequence[google.cloud.datastream_v1alpha1.types.MysqlTable]): + Tables in the database. + """ + + database_name = proto.Field( + proto.STRING, + number=1, + ) + mysql_tables = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='MysqlTable', + ) + + +class MysqlRdbms(proto.Message): + r"""MySQL database structure + + Attributes: + mysql_databases (Sequence[google.cloud.datastream_v1alpha1.types.MysqlDatabase]): + Mysql databases on the server + """ + + mysql_databases = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='MysqlDatabase', + ) + + +class MysqlSourceConfig(proto.Message): + r"""MySQL source configuration + + Attributes: + allowlist (google.cloud.datastream_v1alpha1.types.MysqlRdbms): + MySQL objects to retrieve from the source. + rejectlist (google.cloud.datastream_v1alpha1.types.MysqlRdbms): + MySQL objects to exclude from the stream. + """ + + allowlist = proto.Field( + proto.MESSAGE, + number=1, + message='MysqlRdbms', + ) + rejectlist = proto.Field( + proto.MESSAGE, + number=2, + message='MysqlRdbms', + ) + + +class SourceConfig(proto.Message): + r"""The configuration of the stream source. + + 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: + source_connection_profile_name (str): + Required. Source connection profile + identifier. + oracle_source_config (google.cloud.datastream_v1alpha1.types.OracleSourceConfig): + Oracle data source configuration + This field is a member of `oneof`_ ``source_stream_config``. + mysql_source_config (google.cloud.datastream_v1alpha1.types.MysqlSourceConfig): + MySQL data source configuration + This field is a member of `oneof`_ ``source_stream_config``. + """ + + source_connection_profile_name = proto.Field( + proto.STRING, + number=1, + ) + oracle_source_config = proto.Field( + proto.MESSAGE, + number=100, + oneof='source_stream_config', + message='OracleSourceConfig', + ) + mysql_source_config = proto.Field( + proto.MESSAGE, + number=101, + oneof='source_stream_config', + message='MysqlSourceConfig', + ) + + +class AvroFileFormat(proto.Message): + r"""AVRO file format configuration. + """ + + +class JsonFileFormat(proto.Message): + r"""JSON file format configuration. + + Attributes: + schema_file_format (google.cloud.datastream_v1alpha1.types.SchemaFileFormat): + The schema file format along JSON data files. + compression (google.cloud.datastream_v1alpha1.types.JsonFileFormat.JsonCompression): + Compression of the loaded JSON file. + """ + class JsonCompression(proto.Enum): + r"""Json file compression.""" + JSON_COMPRESSION_UNSPECIFIED = 0 + NO_COMPRESSION = 1 + GZIP = 2 + + schema_file_format = proto.Field( + proto.ENUM, + number=1, + enum='SchemaFileFormat', + ) + compression = proto.Field( + proto.ENUM, + number=2, + enum=JsonCompression, + ) + + +class GcsDestinationConfig(proto.Message): + r"""Google Cloud Storage destination configuration + + 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: + path (str): + Path inside the Cloud Storage bucket to write + data to. + gcs_file_format (google.cloud.datastream_v1alpha1.types.GcsFileFormat): + File format that data should be written in. Deprecated field + - use file_format instead. + file_rotation_mb (int): + The maximum file size to be saved in the + bucket. + file_rotation_interval (google.protobuf.duration_pb2.Duration): + The maximum duration for which new events are + added before a file is closed and a new file is + created. + avro_file_format (google.cloud.datastream_v1alpha1.types.AvroFileFormat): + AVRO file format configuration. + This field is a member of `oneof`_ ``file_format``. + json_file_format (google.cloud.datastream_v1alpha1.types.JsonFileFormat): + JSON file format configuration. + This field is a member of `oneof`_ ``file_format``. + """ + + path = proto.Field( + proto.STRING, + number=1, + ) + gcs_file_format = proto.Field( + proto.ENUM, + number=2, + enum='GcsFileFormat', + ) + file_rotation_mb = proto.Field( + proto.INT32, + number=3, + ) + file_rotation_interval = proto.Field( + proto.MESSAGE, + number=4, + message=duration_pb2.Duration, + ) + avro_file_format = proto.Field( + proto.MESSAGE, + number=100, + oneof='file_format', + message='AvroFileFormat', + ) + json_file_format = proto.Field( + proto.MESSAGE, + number=101, + oneof='file_format', + message='JsonFileFormat', + ) + + +class DestinationConfig(proto.Message): + r"""The configuration of the stream destination. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + destination_connection_profile_name (str): + Required. Destination connection profile + identifier. + gcs_destination_config (google.cloud.datastream_v1alpha1.types.GcsDestinationConfig): + + This field is a member of `oneof`_ ``destination_stream_config``. + """ + + destination_connection_profile_name = proto.Field( + proto.STRING, + number=1, + ) + gcs_destination_config = proto.Field( + proto.MESSAGE, + number=100, + oneof='destination_stream_config', + message='GcsDestinationConfig', + ) + + +class Stream(proto.Message): + r""" + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + Output only. The stream's name. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The creation time of the stream. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The last update time of the + stream. + labels (Sequence[google.cloud.datastream_v1alpha1.types.Stream.LabelsEntry]): + Labels. + display_name (str): + Required. Display name. + source_config (google.cloud.datastream_v1alpha1.types.SourceConfig): + Required. Source connection profile + configuration. + destination_config (google.cloud.datastream_v1alpha1.types.DestinationConfig): + Required. Destination connection profile + configuration. + state (google.cloud.datastream_v1alpha1.types.Stream.State): + The state of the stream. + backfill_all (google.cloud.datastream_v1alpha1.types.Stream.BackfillAllStrategy): + Automatically backfill objects included in + the stream source configuration. Specific + objects can be excluded. + This field is a member of `oneof`_ ``backfill_strategy``. + backfill_none (google.cloud.datastream_v1alpha1.types.Stream.BackfillNoneStrategy): + Do not automatically backfill any objects. + This field is a member of `oneof`_ ``backfill_strategy``. + errors (Sequence[google.cloud.datastream_v1alpha1.types.Error]): + Output only. Errors on the Stream. + """ + class State(proto.Enum): + r"""Stream state.""" + STATE_UNSPECIFIED = 0 + CREATED = 1 + RUNNING = 2 + PAUSED = 3 + MAINTENANCE = 4 + FAILED = 5 + FAILED_PERMANENTLY = 6 + STARTING = 7 + DRAINING = 8 + + class BackfillAllStrategy(proto.Message): + r"""Backfill strategy to automatically backfill the Stream's + objects. Specific objects can be excluded. + + 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: + oracle_excluded_objects (google.cloud.datastream_v1alpha1.types.OracleRdbms): + Oracle data source objects to avoid + backfilling. + This field is a member of `oneof`_ ``excluded_objects``. + mysql_excluded_objects (google.cloud.datastream_v1alpha1.types.MysqlRdbms): + MySQL data source objects to avoid + backfilling. + This field is a member of `oneof`_ ``excluded_objects``. + """ + + oracle_excluded_objects = proto.Field( + proto.MESSAGE, + number=1, + oneof='excluded_objects', + message='OracleRdbms', + ) + mysql_excluded_objects = proto.Field( + proto.MESSAGE, + number=2, + oneof='excluded_objects', + message='MysqlRdbms', + ) + + class BackfillNoneStrategy(proto.Message): + r"""Backfill strategy to disable automatic backfill for the + Stream's objects. + + """ + + 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, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + display_name = proto.Field( + proto.STRING, + number=5, + ) + source_config = proto.Field( + proto.MESSAGE, + number=6, + message='SourceConfig', + ) + destination_config = proto.Field( + proto.MESSAGE, + number=7, + message='DestinationConfig', + ) + state = proto.Field( + proto.ENUM, + number=8, + enum=State, + ) + backfill_all = proto.Field( + proto.MESSAGE, + number=101, + oneof='backfill_strategy', + message=BackfillAllStrategy, + ) + backfill_none = proto.Field( + proto.MESSAGE, + number=102, + oneof='backfill_strategy', + message=BackfillNoneStrategy, + ) + errors = proto.RepeatedField( + proto.MESSAGE, + number=9, + message='Error', + ) + + +class Error(proto.Message): + r"""Represent a user-facing Error. + + Attributes: + reason (str): + A title that explains the reason for the + error. + error_uuid (str): + A unique identifier for this specific error, + allowing it to be traced throughout the system + in logs and API responses. + message (str): + A message containing more information about + the error that occurred. + error_time (google.protobuf.timestamp_pb2.Timestamp): + The time when the error occurred. + details (Sequence[google.cloud.datastream_v1alpha1.types.Error.DetailsEntry]): + Additional information about the error. + """ + + reason = proto.Field( + proto.STRING, + number=1, + ) + error_uuid = proto.Field( + proto.STRING, + number=2, + ) + message = proto.Field( + proto.STRING, + number=3, + ) + error_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + details = proto.MapField( + proto.STRING, + proto.STRING, + number=5, + ) + + +class ValidationResult(proto.Message): + r"""Contains the current validation results. + + Attributes: + validations (Sequence[google.cloud.datastream_v1alpha1.types.Validation]): + A list of validations (includes both executed + as well as not executed validations). + """ + + validations = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='Validation', + ) + + +class Validation(proto.Message): + r""" + + Attributes: + description (str): + A short description of the validation. + status (google.cloud.datastream_v1alpha1.types.Validation.Status): + Validation execution status. + message (Sequence[google.cloud.datastream_v1alpha1.types.ValidationMessage]): + Messages reflecting the validation results. + code (str): + A custom code identifying this validation. + """ + class Status(proto.Enum): + r"""Validation execution status.""" + STATUS_UNSPECIFIED = 0 + NOT_EXECUTED = 1 + FAILED = 2 + PASSED = 3 + + description = proto.Field( + proto.STRING, + number=1, + ) + status = proto.Field( + proto.ENUM, + number=2, + enum=Status, + ) + message = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='ValidationMessage', + ) + code = proto.Field( + proto.STRING, + number=4, + ) + + +class ValidationMessage(proto.Message): + r"""Represent user-facing validation result message. + + Attributes: + message (str): + The result of the validation. + level (google.cloud.datastream_v1alpha1.types.ValidationMessage.Level): + Message severity level (warning or error). + metadata (Sequence[google.cloud.datastream_v1alpha1.types.ValidationMessage.MetadataEntry]): + Additional metadata related to the result. + code (str): + A custom code identifying this specific + message. + """ + class Level(proto.Enum): + r"""Validation message level.""" + LEVEL_UNSPECIFIED = 0 + WARNING = 1 + ERROR = 2 + + message = proto.Field( + proto.STRING, + number=1, + ) + level = proto.Field( + proto.ENUM, + number=2, + enum=Level, + ) + metadata = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) + code = proto.Field( + proto.STRING, + number=4, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha1/mypy.ini b/owl-bot-staging/v1alpha1/mypy.ini new file mode 100644 index 0000000..4505b48 --- /dev/null +++ b/owl-bot-staging/v1alpha1/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.6 +namespace_packages = True diff --git a/owl-bot-staging/v1alpha1/noxfile.py b/owl-bot-staging/v1alpha1/noxfile.py new file mode 100644 index 0000000..e5cac4e --- /dev/null +++ b/owl-bot-staging/v1alpha1/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/datastream_v1alpha1/', + '--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/v1alpha1/scripts/fixup_datastream_v1alpha1_keywords.py b/owl-bot-staging/v1alpha1/scripts/fixup_datastream_v1alpha1_keywords.py new file mode 100644 index 0000000..636ec17 --- /dev/null +++ b/owl-bot-staging/v1alpha1/scripts/fixup_datastream_v1alpha1_keywords.py @@ -0,0 +1,196 @@ +#! /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 datastreamCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_connection_profile': ('parent', 'connection_profile_id', 'connection_profile', 'request_id', ), + 'create_private_connection': ('parent', 'private_connection_id', 'private_connection', 'request_id', ), + 'create_route': ('parent', 'route_id', 'route', 'request_id', ), + 'create_stream': ('parent', 'stream_id', 'stream', 'request_id', 'validate_only', 'force', ), + 'delete_connection_profile': ('name', 'request_id', ), + 'delete_private_connection': ('name', 'request_id', 'force', ), + 'delete_route': ('name', 'request_id', ), + 'delete_stream': ('name', 'request_id', ), + 'discover_connection_profile': ('parent', 'connection_profile', 'connection_profile_name', 'recursive', 'recursion_depth', 'oracle_rdbms', 'mysql_rdbms', ), + 'fetch_errors': ('stream', ), + 'fetch_static_ips': ('name', 'page_size', 'page_token', ), + 'get_connection_profile': ('name', ), + 'get_private_connection': ('name', ), + 'get_route': ('name', ), + 'get_stream': ('name', ), + 'list_connection_profiles': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_private_connections': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_routes': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_streams': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'update_connection_profile': ('connection_profile', 'update_mask', 'request_id', ), + 'update_stream': ('stream', 'update_mask', 'request_id', 'validate_only', 'force', ), + } + + 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=datastreamCallTransformer(), +): + """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 datastream 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/v1alpha1/setup.py b/owl-bot-staging/v1alpha1/setup.py new file mode 100644 index 0000000..e819da1 --- /dev/null +++ b/owl-bot-staging/v1alpha1/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-datastream', + 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.4', + ), + 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/v1alpha1/tests/__init__.py b/owl-bot-staging/v1alpha1/tests/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha1/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/v1alpha1/tests/unit/__init__.py b/owl-bot-staging/v1alpha1/tests/unit/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha1/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/v1alpha1/tests/unit/gapic/__init__.py b/owl-bot-staging/v1alpha1/tests/unit/gapic/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha1/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/v1alpha1/tests/unit/gapic/datastream_v1alpha1/__init__.py b/owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/__init__.py new file mode 100644 index 0000000..b54a5fc --- /dev/null +++ b/owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/__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/v1alpha1/tests/unit/gapic/datastream_v1alpha1/test_datastream.py b/owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/test_datastream.py new file mode 100644 index 0000000..1c82416 --- /dev/null +++ b/owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/test_datastream.py @@ -0,0 +1,6756 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.datastream_v1alpha1.services.datastream import DatastreamAsyncClient +from google.cloud.datastream_v1alpha1.services.datastream import DatastreamClient +from google.cloud.datastream_v1alpha1.services.datastream import pagers +from google.cloud.datastream_v1alpha1.services.datastream import transports +from google.cloud.datastream_v1alpha1.types import datastream +from google.cloud.datastream_v1alpha1.types import datastream_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 DatastreamClient._get_default_mtls_endpoint(None) is None + assert DatastreamClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert DatastreamClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert DatastreamClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert DatastreamClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert DatastreamClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class", [ + DatastreamClient, + DatastreamAsyncClient, +]) +def test_datastream_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 == 'datastream.googleapis.com:443' + + +@pytest.mark.parametrize("transport_class,transport_name", [ + (transports.DatastreamGrpcTransport, "grpc"), + (transports.DatastreamGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_datastream_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", [ + DatastreamClient, + DatastreamAsyncClient, +]) +def test_datastream_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 == 'datastream.googleapis.com:443' + + +def test_datastream_client_get_transport_class(): + transport = DatastreamClient.get_transport_class() + available_transports = [ + transports.DatastreamGrpcTransport, + ] + assert transport in available_transports + + transport = DatastreamClient.get_transport_class("grpc") + assert transport == transports.DatastreamGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (DatastreamClient, transports.DatastreamGrpcTransport, "grpc"), + (DatastreamAsyncClient, transports.DatastreamGrpcAsyncIOTransport, "grpc_asyncio"), +]) +@mock.patch.object(DatastreamClient, "DEFAULT_ENDPOINT", modify_default_endpoint(DatastreamClient)) +@mock.patch.object(DatastreamAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(DatastreamAsyncClient)) +def test_datastream_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(DatastreamClient, '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(DatastreamClient, '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() + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name, client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (DatastreamClient, transports.DatastreamGrpcTransport, "grpc", "true"), + (DatastreamAsyncClient, transports.DatastreamGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (DatastreamClient, transports.DatastreamGrpcTransport, "grpc", "false"), + (DatastreamAsyncClient, transports.DatastreamGrpcAsyncIOTransport, "grpc_asyncio", "false"), +]) +@mock.patch.object(DatastreamClient, "DEFAULT_ENDPOINT", modify_default_endpoint(DatastreamClient)) +@mock.patch.object(DatastreamAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(DatastreamAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_datastream_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(transport=transport_name, client_options=options) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class(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", [ + (DatastreamClient, transports.DatastreamGrpcTransport, "grpc"), + (DatastreamAsyncClient, transports.DatastreamGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_datastream_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(transport=transport_name, client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (DatastreamClient, transports.DatastreamGrpcTransport, "grpc"), + (DatastreamAsyncClient, transports.DatastreamGrpcAsyncIOTransport, "grpc_asyncio"), +]) +def test_datastream_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(transport=transport_name, client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + +def test_datastream_client_client_options_from_dict(): + with mock.patch('google.cloud.datastream_v1alpha1.services.datastream.transports.DatastreamGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = DatastreamClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + +def test_list_connection_profiles(transport: str = 'grpc', request_type=datastream.ListConnectionProfilesRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_connection_profiles), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.ListConnectionProfilesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_connection_profiles(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.ListConnectionProfilesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListConnectionProfilesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_connection_profiles_from_dict(): + test_list_connection_profiles(request_type=dict) + + +def test_list_connection_profiles_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_connection_profiles), + '__call__') as call: + client.list_connection_profiles() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.ListConnectionProfilesRequest() + + +@pytest.mark.asyncio +async def test_list_connection_profiles_async(transport: str = 'grpc_asyncio', request_type=datastream.ListConnectionProfilesRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_connection_profiles), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListConnectionProfilesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_connection_profiles(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.ListConnectionProfilesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListConnectionProfilesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_connection_profiles_async_from_dict(): + await test_list_connection_profiles_async(request_type=dict) + + +def test_list_connection_profiles_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.ListConnectionProfilesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_connection_profiles), + '__call__') as call: + call.return_value = datastream.ListConnectionProfilesResponse() + client.list_connection_profiles(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_connection_profiles_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.ListConnectionProfilesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_connection_profiles), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListConnectionProfilesResponse()) + await client.list_connection_profiles(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_connection_profiles_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_connection_profiles), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.ListConnectionProfilesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_connection_profiles( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +def test_list_connection_profiles_flattened_error(): + client = DatastreamClient( + credentials=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_connection_profiles( + datastream.ListConnectionProfilesRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_connection_profiles_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_connection_profiles), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.ListConnectionProfilesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListConnectionProfilesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_connection_profiles( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_connection_profiles_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_connection_profiles( + datastream.ListConnectionProfilesRequest(), + parent='parent_value', + ) + + +def test_list_connection_profiles_pager(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_connection_profiles), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListConnectionProfilesResponse( + connection_profiles=[ + datastream_resources.ConnectionProfile(), + datastream_resources.ConnectionProfile(), + datastream_resources.ConnectionProfile(), + ], + next_page_token='abc', + ), + datastream.ListConnectionProfilesResponse( + connection_profiles=[], + next_page_token='def', + ), + datastream.ListConnectionProfilesResponse( + connection_profiles=[ + datastream_resources.ConnectionProfile(), + ], + next_page_token='ghi', + ), + datastream.ListConnectionProfilesResponse( + connection_profiles=[ + datastream_resources.ConnectionProfile(), + datastream_resources.ConnectionProfile(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_connection_profiles(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, datastream_resources.ConnectionProfile) + for i in results) + +def test_list_connection_profiles_pages(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_connection_profiles), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListConnectionProfilesResponse( + connection_profiles=[ + datastream_resources.ConnectionProfile(), + datastream_resources.ConnectionProfile(), + datastream_resources.ConnectionProfile(), + ], + next_page_token='abc', + ), + datastream.ListConnectionProfilesResponse( + connection_profiles=[], + next_page_token='def', + ), + datastream.ListConnectionProfilesResponse( + connection_profiles=[ + datastream_resources.ConnectionProfile(), + ], + next_page_token='ghi', + ), + datastream.ListConnectionProfilesResponse( + connection_profiles=[ + datastream_resources.ConnectionProfile(), + datastream_resources.ConnectionProfile(), + ], + ), + RuntimeError, + ) + pages = list(client.list_connection_profiles(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_connection_profiles_async_pager(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_connection_profiles), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListConnectionProfilesResponse( + connection_profiles=[ + datastream_resources.ConnectionProfile(), + datastream_resources.ConnectionProfile(), + datastream_resources.ConnectionProfile(), + ], + next_page_token='abc', + ), + datastream.ListConnectionProfilesResponse( + connection_profiles=[], + next_page_token='def', + ), + datastream.ListConnectionProfilesResponse( + connection_profiles=[ + datastream_resources.ConnectionProfile(), + ], + next_page_token='ghi', + ), + datastream.ListConnectionProfilesResponse( + connection_profiles=[ + datastream_resources.ConnectionProfile(), + datastream_resources.ConnectionProfile(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_connection_profiles(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, datastream_resources.ConnectionProfile) + for i in responses) + +@pytest.mark.asyncio +async def test_list_connection_profiles_async_pages(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_connection_profiles), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListConnectionProfilesResponse( + connection_profiles=[ + datastream_resources.ConnectionProfile(), + datastream_resources.ConnectionProfile(), + datastream_resources.ConnectionProfile(), + ], + next_page_token='abc', + ), + datastream.ListConnectionProfilesResponse( + connection_profiles=[], + next_page_token='def', + ), + datastream.ListConnectionProfilesResponse( + connection_profiles=[ + datastream_resources.ConnectionProfile(), + ], + next_page_token='ghi', + ), + datastream.ListConnectionProfilesResponse( + connection_profiles=[ + datastream_resources.ConnectionProfile(), + datastream_resources.ConnectionProfile(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_connection_profiles(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_get_connection_profile(transport: str = 'grpc', request_type=datastream.GetConnectionProfileRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_connection_profile), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream_resources.ConnectionProfile( + name='name_value', + display_name='display_name_value', + oracle_profile=datastream_resources.OracleProfile(hostname='hostname_value'), + no_connectivity=None, + ) + response = client.get_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.GetConnectionProfileRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, datastream_resources.ConnectionProfile) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + + +def test_get_connection_profile_from_dict(): + test_get_connection_profile(request_type=dict) + + +def test_get_connection_profile_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_connection_profile), + '__call__') as call: + client.get_connection_profile() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.GetConnectionProfileRequest() + + +@pytest.mark.asyncio +async def test_get_connection_profile_async(transport: str = 'grpc_asyncio', request_type=datastream.GetConnectionProfileRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_connection_profile), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.ConnectionProfile( + name='name_value', + display_name='display_name_value', + )) + response = await client.get_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.GetConnectionProfileRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, datastream_resources.ConnectionProfile) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_get_connection_profile_async_from_dict(): + await test_get_connection_profile_async(request_type=dict) + + +def test_get_connection_profile_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.GetConnectionProfileRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_connection_profile), + '__call__') as call: + call.return_value = datastream_resources.ConnectionProfile() + client.get_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_connection_profile_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.GetConnectionProfileRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_connection_profile), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.ConnectionProfile()) + await client.get_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_connection_profile_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_connection_profile), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream_resources.ConnectionProfile() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_connection_profile( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_connection_profile_flattened_error(): + client = DatastreamClient( + credentials=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_connection_profile( + datastream.GetConnectionProfileRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_connection_profile_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_connection_profile), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream_resources.ConnectionProfile() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.ConnectionProfile()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_connection_profile( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_connection_profile_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_connection_profile( + datastream.GetConnectionProfileRequest(), + name='name_value', + ) + + +def test_create_connection_profile(transport: str = 'grpc', request_type=datastream.CreateConnectionProfileRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_connection_profile), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.CreateConnectionProfileRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_connection_profile_from_dict(): + test_create_connection_profile(request_type=dict) + + +def test_create_connection_profile_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_connection_profile), + '__call__') as call: + client.create_connection_profile() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.CreateConnectionProfileRequest() + + +@pytest.mark.asyncio +async def test_create_connection_profile_async(transport: str = 'grpc_asyncio', request_type=datastream.CreateConnectionProfileRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_connection_profile), + '__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_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.CreateConnectionProfileRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_connection_profile_async_from_dict(): + await test_create_connection_profile_async(request_type=dict) + + +def test_create_connection_profile_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.CreateConnectionProfileRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_connection_profile), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_connection_profile_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.CreateConnectionProfileRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_connection_profile), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_connection_profile_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_connection_profile), + '__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_connection_profile( + parent='parent_value', + connection_profile=datastream_resources.ConnectionProfile(name='name_value'), + connection_profile_id='connection_profile_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].connection_profile == datastream_resources.ConnectionProfile(name='name_value') + assert args[0].connection_profile_id == 'connection_profile_id_value' + + +def test_create_connection_profile_flattened_error(): + client = DatastreamClient( + credentials=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_connection_profile( + datastream.CreateConnectionProfileRequest(), + parent='parent_value', + connection_profile=datastream_resources.ConnectionProfile(name='name_value'), + connection_profile_id='connection_profile_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_connection_profile_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_connection_profile), + '__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_connection_profile( + parent='parent_value', + connection_profile=datastream_resources.ConnectionProfile(name='name_value'), + connection_profile_id='connection_profile_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].connection_profile == datastream_resources.ConnectionProfile(name='name_value') + assert args[0].connection_profile_id == 'connection_profile_id_value' + + +@pytest.mark.asyncio +async def test_create_connection_profile_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_connection_profile( + datastream.CreateConnectionProfileRequest(), + parent='parent_value', + connection_profile=datastream_resources.ConnectionProfile(name='name_value'), + connection_profile_id='connection_profile_id_value', + ) + + +def test_update_connection_profile(transport: str = 'grpc', request_type=datastream.UpdateConnectionProfileRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_connection_profile), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.UpdateConnectionProfileRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_connection_profile_from_dict(): + test_update_connection_profile(request_type=dict) + + +def test_update_connection_profile_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_connection_profile), + '__call__') as call: + client.update_connection_profile() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.UpdateConnectionProfileRequest() + + +@pytest.mark.asyncio +async def test_update_connection_profile_async(transport: str = 'grpc_asyncio', request_type=datastream.UpdateConnectionProfileRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_connection_profile), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.update_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.UpdateConnectionProfileRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_connection_profile_async_from_dict(): + await test_update_connection_profile_async(request_type=dict) + + +def test_update_connection_profile_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.UpdateConnectionProfileRequest() + + request.connection_profile.name = 'connection_profile.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_connection_profile), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'connection_profile.name=connection_profile.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_connection_profile_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.UpdateConnectionProfileRequest() + + request.connection_profile.name = 'connection_profile.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_connection_profile), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'connection_profile.name=connection_profile.name/value', + ) in kw['metadata'] + + +def test_update_connection_profile_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_connection_profile), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_connection_profile( + connection_profile=datastream_resources.ConnectionProfile(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].connection_profile == datastream_resources.ConnectionProfile(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_connection_profile_flattened_error(): + client = DatastreamClient( + credentials=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_connection_profile( + datastream.UpdateConnectionProfileRequest(), + connection_profile=datastream_resources.ConnectionProfile(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_connection_profile_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_connection_profile), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_connection_profile( + connection_profile=datastream_resources.ConnectionProfile(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].connection_profile == datastream_resources.ConnectionProfile(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_connection_profile_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_connection_profile( + datastream.UpdateConnectionProfileRequest(), + connection_profile=datastream_resources.ConnectionProfile(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_delete_connection_profile(transport: str = 'grpc', request_type=datastream.DeleteConnectionProfileRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_connection_profile), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DeleteConnectionProfileRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_connection_profile_from_dict(): + test_delete_connection_profile(request_type=dict) + + +def test_delete_connection_profile_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_connection_profile), + '__call__') as call: + client.delete_connection_profile() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DeleteConnectionProfileRequest() + + +@pytest.mark.asyncio +async def test_delete_connection_profile_async(transport: str = 'grpc_asyncio', request_type=datastream.DeleteConnectionProfileRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_connection_profile), + '__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_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DeleteConnectionProfileRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_connection_profile_async_from_dict(): + await test_delete_connection_profile_async(request_type=dict) + + +def test_delete_connection_profile_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.DeleteConnectionProfileRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_connection_profile), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_connection_profile_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.DeleteConnectionProfileRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_connection_profile), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_connection_profile_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_connection_profile), + '__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_connection_profile( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_connection_profile_flattened_error(): + client = DatastreamClient( + credentials=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_connection_profile( + datastream.DeleteConnectionProfileRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_connection_profile_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_connection_profile), + '__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_connection_profile( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_connection_profile_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_connection_profile( + datastream.DeleteConnectionProfileRequest(), + name='name_value', + ) + + +def test_discover_connection_profile(transport: str = 'grpc', request_type=datastream.DiscoverConnectionProfileRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.discover_connection_profile), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.DiscoverConnectionProfileResponse( + oracle_rdbms=datastream_resources.OracleRdbms(oracle_schemas=[datastream_resources.OracleSchema(schema_name='schema_name_value')]), + ) + response = client.discover_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DiscoverConnectionProfileRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, datastream.DiscoverConnectionProfileResponse) + + +def test_discover_connection_profile_from_dict(): + test_discover_connection_profile(request_type=dict) + + +def test_discover_connection_profile_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.discover_connection_profile), + '__call__') as call: + client.discover_connection_profile() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DiscoverConnectionProfileRequest() + + +@pytest.mark.asyncio +async def test_discover_connection_profile_async(transport: str = 'grpc_asyncio', request_type=datastream.DiscoverConnectionProfileRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.discover_connection_profile), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream.DiscoverConnectionProfileResponse( + )) + response = await client.discover_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DiscoverConnectionProfileRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, datastream.DiscoverConnectionProfileResponse) + + +@pytest.mark.asyncio +async def test_discover_connection_profile_async_from_dict(): + await test_discover_connection_profile_async(request_type=dict) + + +def test_discover_connection_profile_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.DiscoverConnectionProfileRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.discover_connection_profile), + '__call__') as call: + call.return_value = datastream.DiscoverConnectionProfileResponse() + client.discover_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_discover_connection_profile_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.DiscoverConnectionProfileRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.discover_connection_profile), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.DiscoverConnectionProfileResponse()) + await client.discover_connection_profile(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_streams(transport: str = 'grpc', request_type=datastream.ListStreamsRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.ListStreamsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_streams(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.ListStreamsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListStreamsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_streams_from_dict(): + test_list_streams(request_type=dict) + + +def test_list_streams_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_streams), + '__call__') as call: + client.list_streams() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.ListStreamsRequest() + + +@pytest.mark.asyncio +async def test_list_streams_async(transport: str = 'grpc_asyncio', request_type=datastream.ListStreamsRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListStreamsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_streams(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.ListStreamsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListStreamsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_streams_async_from_dict(): + await test_list_streams_async(request_type=dict) + + +def test_list_streams_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.ListStreamsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_streams), + '__call__') as call: + call.return_value = datastream.ListStreamsResponse() + client.list_streams(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_streams_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.ListStreamsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_streams), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListStreamsResponse()) + await client.list_streams(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_streams_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.ListStreamsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_streams( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +def test_list_streams_flattened_error(): + client = DatastreamClient( + credentials=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_streams( + datastream.ListStreamsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_streams_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_streams), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.ListStreamsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListStreamsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_streams( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_streams_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_streams( + datastream.ListStreamsRequest(), + parent='parent_value', + ) + + +def test_list_streams_pager(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_streams), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListStreamsResponse( + streams=[ + datastream_resources.Stream(), + datastream_resources.Stream(), + datastream_resources.Stream(), + ], + next_page_token='abc', + ), + datastream.ListStreamsResponse( + streams=[], + next_page_token='def', + ), + datastream.ListStreamsResponse( + streams=[ + datastream_resources.Stream(), + ], + next_page_token='ghi', + ), + datastream.ListStreamsResponse( + streams=[ + datastream_resources.Stream(), + datastream_resources.Stream(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_streams(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, datastream_resources.Stream) + for i in results) + +def test_list_streams_pages(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_streams), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListStreamsResponse( + streams=[ + datastream_resources.Stream(), + datastream_resources.Stream(), + datastream_resources.Stream(), + ], + next_page_token='abc', + ), + datastream.ListStreamsResponse( + streams=[], + next_page_token='def', + ), + datastream.ListStreamsResponse( + streams=[ + datastream_resources.Stream(), + ], + next_page_token='ghi', + ), + datastream.ListStreamsResponse( + streams=[ + datastream_resources.Stream(), + datastream_resources.Stream(), + ], + ), + RuntimeError, + ) + pages = list(client.list_streams(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_streams_async_pager(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_streams), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListStreamsResponse( + streams=[ + datastream_resources.Stream(), + datastream_resources.Stream(), + datastream_resources.Stream(), + ], + next_page_token='abc', + ), + datastream.ListStreamsResponse( + streams=[], + next_page_token='def', + ), + datastream.ListStreamsResponse( + streams=[ + datastream_resources.Stream(), + ], + next_page_token='ghi', + ), + datastream.ListStreamsResponse( + streams=[ + datastream_resources.Stream(), + datastream_resources.Stream(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_streams(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, datastream_resources.Stream) + for i in responses) + +@pytest.mark.asyncio +async def test_list_streams_async_pages(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_streams), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListStreamsResponse( + streams=[ + datastream_resources.Stream(), + datastream_resources.Stream(), + datastream_resources.Stream(), + ], + next_page_token='abc', + ), + datastream.ListStreamsResponse( + streams=[], + next_page_token='def', + ), + datastream.ListStreamsResponse( + streams=[ + datastream_resources.Stream(), + ], + next_page_token='ghi', + ), + datastream.ListStreamsResponse( + streams=[ + datastream_resources.Stream(), + datastream_resources.Stream(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_streams(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_get_stream(transport: str = 'grpc', request_type=datastream.GetStreamRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream_resources.Stream( + name='name_value', + display_name='display_name_value', + state=datastream_resources.Stream.State.CREATED, + backfill_all=datastream_resources.Stream.BackfillAllStrategy(oracle_excluded_objects=datastream_resources.OracleRdbms(oracle_schemas=[datastream_resources.OracleSchema(schema_name='schema_name_value')])), + ) + response = client.get_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.GetStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, datastream_resources.Stream) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.state == datastream_resources.Stream.State.CREATED + + +def test_get_stream_from_dict(): + test_get_stream(request_type=dict) + + +def test_get_stream_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_stream), + '__call__') as call: + client.get_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.GetStreamRequest() + + +@pytest.mark.asyncio +async def test_get_stream_async(transport: str = 'grpc_asyncio', request_type=datastream.GetStreamRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.Stream( + name='name_value', + display_name='display_name_value', + state=datastream_resources.Stream.State.CREATED, + )) + response = await client.get_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.GetStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, datastream_resources.Stream) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.state == datastream_resources.Stream.State.CREATED + + +@pytest.mark.asyncio +async def test_get_stream_async_from_dict(): + await test_get_stream_async(request_type=dict) + + +def test_get_stream_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.GetStreamRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_stream), + '__call__') as call: + call.return_value = datastream_resources.Stream() + client.get_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_stream_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.GetStreamRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.Stream()) + await client.get_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_stream_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream_resources.Stream() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_stream( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_stream_flattened_error(): + client = DatastreamClient( + credentials=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_stream( + datastream.GetStreamRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_stream_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream_resources.Stream() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.Stream()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_stream( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_stream_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_stream( + datastream.GetStreamRequest(), + name='name_value', + ) + + +def test_create_stream(transport: str = 'grpc', request_type=datastream.CreateStreamRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.CreateStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_stream_from_dict(): + test_create_stream(request_type=dict) + + +def test_create_stream_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_stream), + '__call__') as call: + client.create_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.CreateStreamRequest() + + +@pytest.mark.asyncio +async def test_create_stream_async(transport: str = 'grpc_asyncio', request_type=datastream.CreateStreamRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_stream), + '__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_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.CreateStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_stream_async_from_dict(): + await test_create_stream_async(request_type=dict) + + +def test_create_stream_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.CreateStreamRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_stream), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_stream_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.CreateStreamRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_stream_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_stream), + '__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_stream( + parent='parent_value', + stream=datastream_resources.Stream(name='name_value'), + stream_id='stream_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].stream == datastream_resources.Stream(name='name_value') + assert args[0].stream_id == 'stream_id_value' + + +def test_create_stream_flattened_error(): + client = DatastreamClient( + credentials=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_stream( + datastream.CreateStreamRequest(), + parent='parent_value', + stream=datastream_resources.Stream(name='name_value'), + stream_id='stream_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_stream_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_stream), + '__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_stream( + parent='parent_value', + stream=datastream_resources.Stream(name='name_value'), + stream_id='stream_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].stream == datastream_resources.Stream(name='name_value') + assert args[0].stream_id == 'stream_id_value' + + +@pytest.mark.asyncio +async def test_create_stream_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_stream( + datastream.CreateStreamRequest(), + parent='parent_value', + stream=datastream_resources.Stream(name='name_value'), + stream_id='stream_id_value', + ) + + +def test_update_stream(transport: str = 'grpc', request_type=datastream.UpdateStreamRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.UpdateStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_stream_from_dict(): + test_update_stream(request_type=dict) + + +def test_update_stream_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_stream), + '__call__') as call: + client.update_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.UpdateStreamRequest() + + +@pytest.mark.asyncio +async def test_update_stream_async(transport: str = 'grpc_asyncio', request_type=datastream.UpdateStreamRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.update_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.UpdateStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_stream_async_from_dict(): + await test_update_stream_async(request_type=dict) + + +def test_update_stream_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.UpdateStreamRequest() + + request.stream.name = 'stream.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_stream), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'stream.name=stream.name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_stream_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.UpdateStreamRequest() + + request.stream.name = 'stream.name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'stream.name=stream.name/value', + ) in kw['metadata'] + + +def test_update_stream_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_stream( + stream=datastream_resources.Stream(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].stream == datastream_resources.Stream(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +def test_update_stream_flattened_error(): + client = DatastreamClient( + credentials=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_stream( + datastream.UpdateStreamRequest(), + stream=datastream_resources.Stream(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.asyncio +async def test_update_stream_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_stream( + stream=datastream_resources.Stream(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].stream == datastream_resources.Stream(name='name_value') + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) + + +@pytest.mark.asyncio +async def test_update_stream_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_stream( + datastream.UpdateStreamRequest(), + stream=datastream_resources.Stream(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_delete_stream(transport: str = 'grpc', request_type=datastream.DeleteStreamRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_stream), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DeleteStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_stream_from_dict(): + test_delete_stream(request_type=dict) + + +def test_delete_stream_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_stream), + '__call__') as call: + client.delete_stream() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DeleteStreamRequest() + + +@pytest.mark.asyncio +async def test_delete_stream_async(transport: str = 'grpc_asyncio', request_type=datastream.DeleteStreamRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_stream), + '__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_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DeleteStreamRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_stream_async_from_dict(): + await test_delete_stream_async(request_type=dict) + + +def test_delete_stream_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.DeleteStreamRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_stream), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_stream_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.DeleteStreamRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_stream), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_stream(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_stream_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_stream), + '__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_stream( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_stream_flattened_error(): + client = DatastreamClient( + credentials=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_stream( + datastream.DeleteStreamRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_stream_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_stream), + '__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_stream( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_stream_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_stream( + datastream.DeleteStreamRequest(), + name='name_value', + ) + + +def test_fetch_errors(transport: str = 'grpc', request_type=datastream.FetchErrorsRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_errors), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.fetch_errors(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.FetchErrorsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_fetch_errors_from_dict(): + test_fetch_errors(request_type=dict) + + +def test_fetch_errors_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_errors), + '__call__') as call: + client.fetch_errors() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.FetchErrorsRequest() + + +@pytest.mark.asyncio +async def test_fetch_errors_async(transport: str = 'grpc_asyncio', request_type=datastream.FetchErrorsRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_errors), + '__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.fetch_errors(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.FetchErrorsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_fetch_errors_async_from_dict(): + await test_fetch_errors_async(request_type=dict) + + +def test_fetch_errors_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.FetchErrorsRequest() + + request.stream = 'stream/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_errors), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.fetch_errors(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'stream=stream/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_fetch_errors_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.FetchErrorsRequest() + + request.stream = 'stream/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_errors), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.fetch_errors(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'stream=stream/value', + ) in kw['metadata'] + + +def test_fetch_static_ips(transport: str = 'grpc', request_type=datastream.FetchStaticIpsRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_static_ips), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.FetchStaticIpsResponse( + static_ips=['static_ips_value'], + next_page_token='next_page_token_value', + ) + response = client.fetch_static_ips(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.FetchStaticIpsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.FetchStaticIpsPager) + assert response.static_ips == ['static_ips_value'] + assert response.next_page_token == 'next_page_token_value' + + +def test_fetch_static_ips_from_dict(): + test_fetch_static_ips(request_type=dict) + + +def test_fetch_static_ips_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_static_ips), + '__call__') as call: + client.fetch_static_ips() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.FetchStaticIpsRequest() + + +@pytest.mark.asyncio +async def test_fetch_static_ips_async(transport: str = 'grpc_asyncio', request_type=datastream.FetchStaticIpsRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_static_ips), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream.FetchStaticIpsResponse( + static_ips=['static_ips_value'], + next_page_token='next_page_token_value', + )) + response = await client.fetch_static_ips(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.FetchStaticIpsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.FetchStaticIpsAsyncPager) + assert response.static_ips == ['static_ips_value'] + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_fetch_static_ips_async_from_dict(): + await test_fetch_static_ips_async(request_type=dict) + + +def test_fetch_static_ips_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.FetchStaticIpsRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_static_ips), + '__call__') as call: + call.return_value = datastream.FetchStaticIpsResponse() + client.fetch_static_ips(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_fetch_static_ips_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.FetchStaticIpsRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_static_ips), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.FetchStaticIpsResponse()) + await client.fetch_static_ips(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name/value', + ) in kw['metadata'] + + +def test_fetch_static_ips_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_static_ips), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.FetchStaticIpsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.fetch_static_ips( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_fetch_static_ips_flattened_error(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.fetch_static_ips( + datastream.FetchStaticIpsRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_fetch_static_ips_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_static_ips), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.FetchStaticIpsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.FetchStaticIpsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.fetch_static_ips( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_fetch_static_ips_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.fetch_static_ips( + datastream.FetchStaticIpsRequest(), + name='name_value', + ) + + +def test_fetch_static_ips_pager(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_static_ips), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.FetchStaticIpsResponse( + static_ips=[ + str(), + str(), + str(), + ], + next_page_token='abc', + ), + datastream.FetchStaticIpsResponse( + static_ips=[], + next_page_token='def', + ), + datastream.FetchStaticIpsResponse( + static_ips=[ + str(), + ], + next_page_token='ghi', + ), + datastream.FetchStaticIpsResponse( + static_ips=[ + str(), + str(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('name', ''), + )), + ) + pager = client.fetch_static_ips(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, str) + for i in results) + +def test_fetch_static_ips_pages(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_static_ips), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.FetchStaticIpsResponse( + static_ips=[ + str(), + str(), + str(), + ], + next_page_token='abc', + ), + datastream.FetchStaticIpsResponse( + static_ips=[], + next_page_token='def', + ), + datastream.FetchStaticIpsResponse( + static_ips=[ + str(), + ], + next_page_token='ghi', + ), + datastream.FetchStaticIpsResponse( + static_ips=[ + str(), + str(), + ], + ), + RuntimeError, + ) + pages = list(client.fetch_static_ips(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_fetch_static_ips_async_pager(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_static_ips), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.FetchStaticIpsResponse( + static_ips=[ + str(), + str(), + str(), + ], + next_page_token='abc', + ), + datastream.FetchStaticIpsResponse( + static_ips=[], + next_page_token='def', + ), + datastream.FetchStaticIpsResponse( + static_ips=[ + str(), + ], + next_page_token='ghi', + ), + datastream.FetchStaticIpsResponse( + static_ips=[ + str(), + str(), + ], + ), + RuntimeError, + ) + async_pager = await client.fetch_static_ips(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, str) + for i in responses) + +@pytest.mark.asyncio +async def test_fetch_static_ips_async_pages(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_static_ips), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.FetchStaticIpsResponse( + static_ips=[ + str(), + str(), + str(), + ], + next_page_token='abc', + ), + datastream.FetchStaticIpsResponse( + static_ips=[], + next_page_token='def', + ), + datastream.FetchStaticIpsResponse( + static_ips=[ + str(), + ], + next_page_token='ghi', + ), + datastream.FetchStaticIpsResponse( + static_ips=[ + str(), + str(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.fetch_static_ips(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_create_private_connection(transport: str = 'grpc', request_type=datastream.CreatePrivateConnectionRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_private_connection), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_private_connection(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.CreatePrivateConnectionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_private_connection_from_dict(): + test_create_private_connection(request_type=dict) + + +def test_create_private_connection_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_private_connection), + '__call__') as call: + client.create_private_connection() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.CreatePrivateConnectionRequest() + + +@pytest.mark.asyncio +async def test_create_private_connection_async(transport: str = 'grpc_asyncio', request_type=datastream.CreatePrivateConnectionRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_private_connection), + '__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_private_connection(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.CreatePrivateConnectionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_private_connection_async_from_dict(): + await test_create_private_connection_async(request_type=dict) + + +def test_create_private_connection_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.CreatePrivateConnectionRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_private_connection), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_private_connection(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_private_connection_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.CreatePrivateConnectionRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_private_connection), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_private_connection(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_private_connection_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_private_connection), + '__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_private_connection( + parent='parent_value', + private_connection=datastream_resources.PrivateConnection(name='name_value'), + private_connection_id='private_connection_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].private_connection == datastream_resources.PrivateConnection(name='name_value') + assert args[0].private_connection_id == 'private_connection_id_value' + + +def test_create_private_connection_flattened_error(): + client = DatastreamClient( + credentials=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_private_connection( + datastream.CreatePrivateConnectionRequest(), + parent='parent_value', + private_connection=datastream_resources.PrivateConnection(name='name_value'), + private_connection_id='private_connection_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_private_connection_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_private_connection), + '__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_private_connection( + parent='parent_value', + private_connection=datastream_resources.PrivateConnection(name='name_value'), + private_connection_id='private_connection_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].private_connection == datastream_resources.PrivateConnection(name='name_value') + assert args[0].private_connection_id == 'private_connection_id_value' + + +@pytest.mark.asyncio +async def test_create_private_connection_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_private_connection( + datastream.CreatePrivateConnectionRequest(), + parent='parent_value', + private_connection=datastream_resources.PrivateConnection(name='name_value'), + private_connection_id='private_connection_id_value', + ) + + +def test_get_private_connection(transport: str = 'grpc', request_type=datastream.GetPrivateConnectionRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_private_connection), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream_resources.PrivateConnection( + name='name_value', + display_name='display_name_value', + state=datastream_resources.PrivateConnection.State.CREATING, + ) + response = client.get_private_connection(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.GetPrivateConnectionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, datastream_resources.PrivateConnection) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.state == datastream_resources.PrivateConnection.State.CREATING + + +def test_get_private_connection_from_dict(): + test_get_private_connection(request_type=dict) + + +def test_get_private_connection_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_private_connection), + '__call__') as call: + client.get_private_connection() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.GetPrivateConnectionRequest() + + +@pytest.mark.asyncio +async def test_get_private_connection_async(transport: str = 'grpc_asyncio', request_type=datastream.GetPrivateConnectionRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_private_connection), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.PrivateConnection( + name='name_value', + display_name='display_name_value', + state=datastream_resources.PrivateConnection.State.CREATING, + )) + response = await client.get_private_connection(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.GetPrivateConnectionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, datastream_resources.PrivateConnection) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.state == datastream_resources.PrivateConnection.State.CREATING + + +@pytest.mark.asyncio +async def test_get_private_connection_async_from_dict(): + await test_get_private_connection_async(request_type=dict) + + +def test_get_private_connection_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.GetPrivateConnectionRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_private_connection), + '__call__') as call: + call.return_value = datastream_resources.PrivateConnection() + client.get_private_connection(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_private_connection_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.GetPrivateConnectionRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_private_connection), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.PrivateConnection()) + await client.get_private_connection(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_private_connection_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_private_connection), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream_resources.PrivateConnection() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_private_connection( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_private_connection_flattened_error(): + client = DatastreamClient( + credentials=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_private_connection( + datastream.GetPrivateConnectionRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_private_connection_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_private_connection), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream_resources.PrivateConnection() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.PrivateConnection()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_private_connection( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_private_connection_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_private_connection( + datastream.GetPrivateConnectionRequest(), + name='name_value', + ) + + +def test_list_private_connections(transport: str = 'grpc', request_type=datastream.ListPrivateConnectionsRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_private_connections), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.ListPrivateConnectionsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_private_connections(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.ListPrivateConnectionsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPrivateConnectionsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_private_connections_from_dict(): + test_list_private_connections(request_type=dict) + + +def test_list_private_connections_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_private_connections), + '__call__') as call: + client.list_private_connections() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.ListPrivateConnectionsRequest() + + +@pytest.mark.asyncio +async def test_list_private_connections_async(transport: str = 'grpc_asyncio', request_type=datastream.ListPrivateConnectionsRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_private_connections), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListPrivateConnectionsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_private_connections(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.ListPrivateConnectionsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPrivateConnectionsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_private_connections_async_from_dict(): + await test_list_private_connections_async(request_type=dict) + + +def test_list_private_connections_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.ListPrivateConnectionsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_private_connections), + '__call__') as call: + call.return_value = datastream.ListPrivateConnectionsResponse() + client.list_private_connections(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_private_connections_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.ListPrivateConnectionsRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_private_connections), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListPrivateConnectionsResponse()) + await client.list_private_connections(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_private_connections_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_private_connections), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.ListPrivateConnectionsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_private_connections( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +def test_list_private_connections_flattened_error(): + client = DatastreamClient( + credentials=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_private_connections( + datastream.ListPrivateConnectionsRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_private_connections_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_private_connections), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.ListPrivateConnectionsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListPrivateConnectionsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_private_connections( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_private_connections_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_private_connections( + datastream.ListPrivateConnectionsRequest(), + parent='parent_value', + ) + + +def test_list_private_connections_pager(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_private_connections), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListPrivateConnectionsResponse( + private_connections=[ + datastream_resources.PrivateConnection(), + datastream_resources.PrivateConnection(), + datastream_resources.PrivateConnection(), + ], + next_page_token='abc', + ), + datastream.ListPrivateConnectionsResponse( + private_connections=[], + next_page_token='def', + ), + datastream.ListPrivateConnectionsResponse( + private_connections=[ + datastream_resources.PrivateConnection(), + ], + next_page_token='ghi', + ), + datastream.ListPrivateConnectionsResponse( + private_connections=[ + datastream_resources.PrivateConnection(), + datastream_resources.PrivateConnection(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_private_connections(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, datastream_resources.PrivateConnection) + for i in results) + +def test_list_private_connections_pages(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_private_connections), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListPrivateConnectionsResponse( + private_connections=[ + datastream_resources.PrivateConnection(), + datastream_resources.PrivateConnection(), + datastream_resources.PrivateConnection(), + ], + next_page_token='abc', + ), + datastream.ListPrivateConnectionsResponse( + private_connections=[], + next_page_token='def', + ), + datastream.ListPrivateConnectionsResponse( + private_connections=[ + datastream_resources.PrivateConnection(), + ], + next_page_token='ghi', + ), + datastream.ListPrivateConnectionsResponse( + private_connections=[ + datastream_resources.PrivateConnection(), + datastream_resources.PrivateConnection(), + ], + ), + RuntimeError, + ) + pages = list(client.list_private_connections(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_private_connections_async_pager(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_private_connections), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListPrivateConnectionsResponse( + private_connections=[ + datastream_resources.PrivateConnection(), + datastream_resources.PrivateConnection(), + datastream_resources.PrivateConnection(), + ], + next_page_token='abc', + ), + datastream.ListPrivateConnectionsResponse( + private_connections=[], + next_page_token='def', + ), + datastream.ListPrivateConnectionsResponse( + private_connections=[ + datastream_resources.PrivateConnection(), + ], + next_page_token='ghi', + ), + datastream.ListPrivateConnectionsResponse( + private_connections=[ + datastream_resources.PrivateConnection(), + datastream_resources.PrivateConnection(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_private_connections(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, datastream_resources.PrivateConnection) + for i in responses) + +@pytest.mark.asyncio +async def test_list_private_connections_async_pages(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_private_connections), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListPrivateConnectionsResponse( + private_connections=[ + datastream_resources.PrivateConnection(), + datastream_resources.PrivateConnection(), + datastream_resources.PrivateConnection(), + ], + next_page_token='abc', + ), + datastream.ListPrivateConnectionsResponse( + private_connections=[], + next_page_token='def', + ), + datastream.ListPrivateConnectionsResponse( + private_connections=[ + datastream_resources.PrivateConnection(), + ], + next_page_token='ghi', + ), + datastream.ListPrivateConnectionsResponse( + private_connections=[ + datastream_resources.PrivateConnection(), + datastream_resources.PrivateConnection(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_private_connections(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_delete_private_connection(transport: str = 'grpc', request_type=datastream.DeletePrivateConnectionRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_private_connection), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_private_connection(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DeletePrivateConnectionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_private_connection_from_dict(): + test_delete_private_connection(request_type=dict) + + +def test_delete_private_connection_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_private_connection), + '__call__') as call: + client.delete_private_connection() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DeletePrivateConnectionRequest() + + +@pytest.mark.asyncio +async def test_delete_private_connection_async(transport: str = 'grpc_asyncio', request_type=datastream.DeletePrivateConnectionRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_private_connection), + '__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_private_connection(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DeletePrivateConnectionRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_private_connection_async_from_dict(): + await test_delete_private_connection_async(request_type=dict) + + +def test_delete_private_connection_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.DeletePrivateConnectionRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_private_connection), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_private_connection(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_private_connection_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.DeletePrivateConnectionRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_private_connection), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_private_connection(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_private_connection_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_private_connection), + '__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_private_connection( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_private_connection_flattened_error(): + client = DatastreamClient( + credentials=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_private_connection( + datastream.DeletePrivateConnectionRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_private_connection_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_private_connection), + '__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_private_connection( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_private_connection_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_private_connection( + datastream.DeletePrivateConnectionRequest(), + name='name_value', + ) + + +def test_create_route(transport: str = 'grpc', request_type=datastream.CreateRouteRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_route), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_route(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.CreateRouteRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_route_from_dict(): + test_create_route(request_type=dict) + + +def test_create_route_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_route), + '__call__') as call: + client.create_route() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.CreateRouteRequest() + + +@pytest.mark.asyncio +async def test_create_route_async(transport: str = 'grpc_asyncio', request_type=datastream.CreateRouteRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_route), + '__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_route(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.CreateRouteRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_route_async_from_dict(): + await test_create_route_async(request_type=dict) + + +def test_create_route_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.CreateRouteRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_route), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_route(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_route_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.CreateRouteRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_route), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_route(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_route_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_route), + '__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_route( + parent='parent_value', + route=datastream_resources.Route(name='name_value'), + route_id='route_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].route == datastream_resources.Route(name='name_value') + assert args[0].route_id == 'route_id_value' + + +def test_create_route_flattened_error(): + client = DatastreamClient( + credentials=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_route( + datastream.CreateRouteRequest(), + parent='parent_value', + route=datastream_resources.Route(name='name_value'), + route_id='route_id_value', + ) + + +@pytest.mark.asyncio +async def test_create_route_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_route), + '__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_route( + parent='parent_value', + route=datastream_resources.Route(name='name_value'), + route_id='route_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + assert args[0].route == datastream_resources.Route(name='name_value') + assert args[0].route_id == 'route_id_value' + + +@pytest.mark.asyncio +async def test_create_route_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_route( + datastream.CreateRouteRequest(), + parent='parent_value', + route=datastream_resources.Route(name='name_value'), + route_id='route_id_value', + ) + + +def test_get_route(transport: str = 'grpc', request_type=datastream.GetRouteRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_route), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream_resources.Route( + name='name_value', + display_name='display_name_value', + destination_address='destination_address_value', + destination_port=1734, + ) + response = client.get_route(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.GetRouteRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, datastream_resources.Route) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.destination_address == 'destination_address_value' + assert response.destination_port == 1734 + + +def test_get_route_from_dict(): + test_get_route(request_type=dict) + + +def test_get_route_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_route), + '__call__') as call: + client.get_route() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.GetRouteRequest() + + +@pytest.mark.asyncio +async def test_get_route_async(transport: str = 'grpc_asyncio', request_type=datastream.GetRouteRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_route), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.Route( + name='name_value', + display_name='display_name_value', + destination_address='destination_address_value', + destination_port=1734, + )) + response = await client.get_route(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.GetRouteRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, datastream_resources.Route) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.destination_address == 'destination_address_value' + assert response.destination_port == 1734 + + +@pytest.mark.asyncio +async def test_get_route_async_from_dict(): + await test_get_route_async(request_type=dict) + + +def test_get_route_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.GetRouteRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_route), + '__call__') as call: + call.return_value = datastream_resources.Route() + client.get_route(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_route_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.GetRouteRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_route), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.Route()) + await client.get_route(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_route_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_route), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream_resources.Route() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_route( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_get_route_flattened_error(): + client = DatastreamClient( + credentials=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_route( + datastream.GetRouteRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_get_route_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_route), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream_resources.Route() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.Route()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_route( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_route_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_route( + datastream.GetRouteRequest(), + name='name_value', + ) + + +def test_list_routes(transport: str = 'grpc', request_type=datastream.ListRoutesRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_routes), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.ListRoutesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_routes(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.ListRoutesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListRoutesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_routes_from_dict(): + test_list_routes(request_type=dict) + + +def test_list_routes_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_routes), + '__call__') as call: + client.list_routes() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.ListRoutesRequest() + + +@pytest.mark.asyncio +async def test_list_routes_async(transport: str = 'grpc_asyncio', request_type=datastream.ListRoutesRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_routes), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListRoutesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_routes(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.ListRoutesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListRoutesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_routes_async_from_dict(): + await test_list_routes_async(request_type=dict) + + +def test_list_routes_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.ListRoutesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_routes), + '__call__') as call: + call.return_value = datastream.ListRoutesResponse() + client.list_routes(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.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_routes_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.ListRoutesRequest() + + request.parent = 'parent/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_routes), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListRoutesResponse()) + await client.list_routes(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.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_routes_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_routes), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.ListRoutesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_routes( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +def test_list_routes_flattened_error(): + client = DatastreamClient( + credentials=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_routes( + datastream.ListRoutesRequest(), + parent='parent_value', + ) + + +@pytest.mark.asyncio +async def test_list_routes_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_routes), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = datastream.ListRoutesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListRoutesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_routes( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == 'parent_value' + + +@pytest.mark.asyncio +async def test_list_routes_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_routes( + datastream.ListRoutesRequest(), + parent='parent_value', + ) + + +def test_list_routes_pager(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_routes), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListRoutesResponse( + routes=[ + datastream_resources.Route(), + datastream_resources.Route(), + datastream_resources.Route(), + ], + next_page_token='abc', + ), + datastream.ListRoutesResponse( + routes=[], + next_page_token='def', + ), + datastream.ListRoutesResponse( + routes=[ + datastream_resources.Route(), + ], + next_page_token='ghi', + ), + datastream.ListRoutesResponse( + routes=[ + datastream_resources.Route(), + datastream_resources.Route(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_routes(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, datastream_resources.Route) + for i in results) + +def test_list_routes_pages(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_routes), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListRoutesResponse( + routes=[ + datastream_resources.Route(), + datastream_resources.Route(), + datastream_resources.Route(), + ], + next_page_token='abc', + ), + datastream.ListRoutesResponse( + routes=[], + next_page_token='def', + ), + datastream.ListRoutesResponse( + routes=[ + datastream_resources.Route(), + ], + next_page_token='ghi', + ), + datastream.ListRoutesResponse( + routes=[ + datastream_resources.Route(), + datastream_resources.Route(), + ], + ), + RuntimeError, + ) + pages = list(client.list_routes(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_routes_async_pager(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_routes), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListRoutesResponse( + routes=[ + datastream_resources.Route(), + datastream_resources.Route(), + datastream_resources.Route(), + ], + next_page_token='abc', + ), + datastream.ListRoutesResponse( + routes=[], + next_page_token='def', + ), + datastream.ListRoutesResponse( + routes=[ + datastream_resources.Route(), + ], + next_page_token='ghi', + ), + datastream.ListRoutesResponse( + routes=[ + datastream_resources.Route(), + datastream_resources.Route(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_routes(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, datastream_resources.Route) + for i in responses) + +@pytest.mark.asyncio +async def test_list_routes_async_pages(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_routes), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + datastream.ListRoutesResponse( + routes=[ + datastream_resources.Route(), + datastream_resources.Route(), + datastream_resources.Route(), + ], + next_page_token='abc', + ), + datastream.ListRoutesResponse( + routes=[], + next_page_token='def', + ), + datastream.ListRoutesResponse( + routes=[ + datastream_resources.Route(), + ], + next_page_token='ghi', + ), + datastream.ListRoutesResponse( + routes=[ + datastream_resources.Route(), + datastream_resources.Route(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_routes(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +def test_delete_route(transport: str = 'grpc', request_type=datastream.DeleteRouteRequest): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_route), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_route(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DeleteRouteRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_route_from_dict(): + test_delete_route(request_type=dict) + + +def test_delete_route_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatastreamClient( + credentials=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_route), + '__call__') as call: + client.delete_route() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DeleteRouteRequest() + + +@pytest.mark.asyncio +async def test_delete_route_async(transport: str = 'grpc_asyncio', request_type=datastream.DeleteRouteRequest): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an 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_route), + '__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_route(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == datastream.DeleteRouteRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_route_async_from_dict(): + await test_delete_route_async(request_type=dict) + + +def test_delete_route_field_headers(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.DeleteRouteRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_route), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_route(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == 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_route_field_headers_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = datastream.DeleteRouteRequest() + + request.name = 'name/value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_route), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_route(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == 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_route_flattened(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_route), + '__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_route( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +def test_delete_route_flattened_error(): + client = DatastreamClient( + credentials=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_route( + datastream.DeleteRouteRequest(), + name='name_value', + ) + + +@pytest.mark.asyncio +async def test_delete_route_flattened_async(): + client = DatastreamAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_route), + '__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_route( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == 'name_value' + + +@pytest.mark.asyncio +async def test_delete_route_flattened_error_async(): + client = DatastreamAsyncClient( + credentials=ga_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_route( + datastream.DeleteRouteRequest(), + name='name_value', + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.DatastreamGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.DatastreamGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = DatastreamClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.DatastreamGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = DatastreamClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.DatastreamGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = DatastreamClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.DatastreamGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.DatastreamGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.DatastreamGrpcTransport, + transports.DatastreamGrpcAsyncIOTransport, +]) +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 = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.DatastreamGrpcTransport, + ) + +def test_datastream_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.DatastreamTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_datastream_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.datastream_v1alpha1.services.datastream.transports.DatastreamTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.DatastreamTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'list_connection_profiles', + 'get_connection_profile', + 'create_connection_profile', + 'update_connection_profile', + 'delete_connection_profile', + 'discover_connection_profile', + 'list_streams', + 'get_stream', + 'create_stream', + 'update_stream', + 'delete_stream', + 'fetch_errors', + 'fetch_static_ips', + 'create_private_connection', + 'get_private_connection', + 'list_private_connections', + 'delete_private_connection', + 'create_route', + 'get_route', + 'list_routes', + 'delete_route', + ) + 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_datastream_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.datastream_v1alpha1.services.datastream.transports.DatastreamTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.DatastreamTransport( + 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_datastream_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.datastream_v1alpha1.services.datastream.transports.DatastreamTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.DatastreamTransport() + adc.assert_called_once() + + +def test_datastream_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) + DatastreamClient() + 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.DatastreamGrpcTransport, + transports.DatastreamGrpcAsyncIOTransport, + ], +) +def test_datastream_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.DatastreamGrpcTransport, grpc_helpers), + (transports.DatastreamGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_datastream_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( + "datastream.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="datastream.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.DatastreamGrpcTransport, transports.DatastreamGrpcAsyncIOTransport]) +def test_datastream_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_datastream_host_no_port(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='datastream.googleapis.com'), + ) + assert client.transport._host == 'datastream.googleapis.com:443' + + +def test_datastream_host_with_port(): + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='datastream.googleapis.com:8000'), + ) + assert client.transport._host == 'datastream.googleapis.com:8000' + +def test_datastream_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.DatastreamGrpcTransport( + 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_datastream_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.DatastreamGrpcAsyncIOTransport( + 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.DatastreamGrpcTransport, transports.DatastreamGrpcAsyncIOTransport]) +def test_datastream_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.DatastreamGrpcTransport, transports.DatastreamGrpcAsyncIOTransport]) +def test_datastream_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_datastream_grpc_lro_client(): + client = DatastreamClient( + 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_datastream_grpc_lro_async_client(): + client = DatastreamAsyncClient( + 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_connection_profile_path(): + project = "squid" + location = "clam" + connection_profile = "whelk" + expected = "projects/{project}/locations/{location}/connectionProfiles/{connection_profile}".format(project=project, location=location, connection_profile=connection_profile, ) + actual = DatastreamClient.connection_profile_path(project, location, connection_profile) + assert expected == actual + + +def test_parse_connection_profile_path(): + expected = { + "project": "octopus", + "location": "oyster", + "connection_profile": "nudibranch", + } + path = DatastreamClient.connection_profile_path(**expected) + + # Check that the path construction is reversible. + actual = DatastreamClient.parse_connection_profile_path(path) + assert expected == actual + +def test_private_connection_path(): + project = "cuttlefish" + location = "mussel" + private_connection = "winkle" + expected = "projects/{project}/locations/{location}/privateConnections/{private_connection}".format(project=project, location=location, private_connection=private_connection, ) + actual = DatastreamClient.private_connection_path(project, location, private_connection) + assert expected == actual + + +def test_parse_private_connection_path(): + expected = { + "project": "nautilus", + "location": "scallop", + "private_connection": "abalone", + } + path = DatastreamClient.private_connection_path(**expected) + + # Check that the path construction is reversible. + actual = DatastreamClient.parse_private_connection_path(path) + assert expected == actual + +def test_route_path(): + project = "squid" + location = "clam" + private_connection = "whelk" + route = "octopus" + expected = "projects/{project}/locations/{location}/privateConnections/{private_connection}/routes/{route}".format(project=project, location=location, private_connection=private_connection, route=route, ) + actual = DatastreamClient.route_path(project, location, private_connection, route) + assert expected == actual + + +def test_parse_route_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "private_connection": "cuttlefish", + "route": "mussel", + } + path = DatastreamClient.route_path(**expected) + + # Check that the path construction is reversible. + actual = DatastreamClient.parse_route_path(path) + assert expected == actual + +def test_stream_path(): + project = "winkle" + location = "nautilus" + stream = "scallop" + expected = "projects/{project}/locations/{location}/streams/{stream}".format(project=project, location=location, stream=stream, ) + actual = DatastreamClient.stream_path(project, location, stream) + assert expected == actual + + +def test_parse_stream_path(): + expected = { + "project": "abalone", + "location": "squid", + "stream": "clam", + } + path = DatastreamClient.stream_path(**expected) + + # Check that the path construction is reversible. + actual = DatastreamClient.parse_stream_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "whelk" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = DatastreamClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "octopus", + } + path = DatastreamClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = DatastreamClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "oyster" + expected = "folders/{folder}".format(folder=folder, ) + actual = DatastreamClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nudibranch", + } + path = DatastreamClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = DatastreamClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "cuttlefish" + expected = "organizations/{organization}".format(organization=organization, ) + actual = DatastreamClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "mussel", + } + path = DatastreamClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = DatastreamClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "winkle" + expected = "projects/{project}".format(project=project, ) + actual = DatastreamClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nautilus", + } + path = DatastreamClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = DatastreamClient.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 = DatastreamClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "squid", + "location": "clam", + } + path = DatastreamClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = DatastreamClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_withDEFAULT_CLIENT_INFO(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.DatastreamTransport, '_prep_wrapped_messages') as prep: + client = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.DatastreamTransport, '_prep_wrapped_messages') as prep: + transport_class = DatastreamClient.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 = DatastreamAsyncClient( + 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 = DatastreamClient( + 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 = DatastreamClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() From dbbcbd66e91b41b3057a98f47cf5963894dc64f3 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Sat, 30 Oct 2021 02:21:29 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../services/datastream/async_client.py | 130 +- .../services/datastream/client.py | 44 +- .../services/datastream/transports/base.py | 37 +- .../services/datastream/transports/grpc.py | 2 +- .../datastream/transports/grpc_asyncio.py | 3 +- .../datastream_v1alpha1/types/datastream.py | 22 + .../types/datastream_resources.py | 62 + owl-bot-staging/v1alpha1/.coveragerc | 17 - owl-bot-staging/v1alpha1/MANIFEST.in | 2 - owl-bot-staging/v1alpha1/README.rst | 49 - owl-bot-staging/v1alpha1/docs/conf.py | 376 - .../docs/datastream_v1alpha1/datastream.rst | 10 - .../docs/datastream_v1alpha1/services.rst | 6 - .../docs/datastream_v1alpha1/types.rst | 7 - owl-bot-staging/v1alpha1/docs/index.rst | 7 - .../google/cloud/datastream/__init__.py | 149 - .../v1alpha1/google/cloud/datastream/py.typed | 2 - .../cloud/datastream_v1alpha1/__init__.py | 150 - .../datastream_v1alpha1/gapic_metadata.json | 233 - .../google/cloud/datastream_v1alpha1/py.typed | 2 - .../datastream_v1alpha1/services/__init__.py | 15 - .../services/datastream/__init__.py | 22 - .../services/datastream/async_client.py | 2029 ----- .../services/datastream/client.py | 2255 ------ .../services/datastream/pagers.py | 629 -- .../datastream/transports/__init__.py | 33 - .../services/datastream/transports/base.py | 434 -- .../services/datastream/transports/grpc.py | 814 -- .../datastream/transports/grpc_asyncio.py | 818 -- .../datastream_v1alpha1/types/__init__.py | 148 - .../datastream_v1alpha1/types/datastream.py | 1195 --- .../types/datastream_resources.py | 1311 ---- owl-bot-staging/v1alpha1/mypy.ini | 3 - owl-bot-staging/v1alpha1/noxfile.py | 132 - .../fixup_datastream_v1alpha1_keywords.py | 196 - owl-bot-staging/v1alpha1/setup.py | 54 - owl-bot-staging/v1alpha1/tests/__init__.py | 16 - .../v1alpha1/tests/unit/__init__.py | 16 - .../v1alpha1/tests/unit/gapic/__init__.py | 16 - .../gapic/datastream_v1alpha1/__init__.py | 16 - .../datastream_v1alpha1/test_datastream.py | 6756 ----------------- .../datastream_v1alpha1/test_datastream.py | 88 +- 42 files changed, 186 insertions(+), 18120 deletions(-) delete mode 100644 owl-bot-staging/v1alpha1/.coveragerc delete mode 100644 owl-bot-staging/v1alpha1/MANIFEST.in delete mode 100644 owl-bot-staging/v1alpha1/README.rst delete mode 100644 owl-bot-staging/v1alpha1/docs/conf.py delete mode 100644 owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/datastream.rst delete mode 100644 owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/services.rst delete mode 100644 owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/types.rst delete mode 100644 owl-bot-staging/v1alpha1/docs/index.rst delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream/__init__.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream/py.typed delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/__init__.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/py.typed delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/__init__.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/__init__.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/async_client.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/client.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/pagers.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/__init__.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/__init__.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream.py delete mode 100644 owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream_resources.py delete mode 100644 owl-bot-staging/v1alpha1/mypy.ini delete mode 100644 owl-bot-staging/v1alpha1/noxfile.py delete mode 100644 owl-bot-staging/v1alpha1/scripts/fixup_datastream_v1alpha1_keywords.py delete mode 100644 owl-bot-staging/v1alpha1/setup.py delete mode 100644 owl-bot-staging/v1alpha1/tests/__init__.py delete mode 100644 owl-bot-staging/v1alpha1/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v1alpha1/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/__init__.py delete mode 100644 owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/test_datastream.py diff --git a/google/cloud/datastream_v1alpha1/services/datastream/async_client.py b/google/cloud/datastream_v1alpha1/services/datastream/async_client.py index 5c8f568..7615a82 100644 --- a/google/cloud/datastream_v1alpha1/services/datastream/async_client.py +++ b/google/cloud/datastream_v1alpha1/services/datastream/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.datastream_v1alpha1.services.datastream import pagers @@ -173,10 +175,10 @@ def __init__( async def list_connection_profiles( self, - request: datastream.ListConnectionProfilesRequest = None, + request: Union[datastream.ListConnectionProfilesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListConnectionProfilesAsyncPager: @@ -184,7 +186,7 @@ async def list_connection_profiles( in a project and location. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.ListConnectionProfilesRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.ListConnectionProfilesRequest, dict]): The request object. parent (:class:`str`): Required. The parent that owns the @@ -251,10 +253,10 @@ async def list_connection_profiles( async def get_connection_profile( self, - request: datastream.GetConnectionProfileRequest = None, + request: Union[datastream.GetConnectionProfileRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> datastream_resources.ConnectionProfile: @@ -262,7 +264,7 @@ async def get_connection_profile( profile. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.GetConnectionProfileRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.GetConnectionProfileRequest, dict]): The request object. name (:class:`str`): Required. The name of the connection @@ -320,12 +322,12 @@ async def get_connection_profile( async def create_connection_profile( self, - request: datastream.CreateConnectionProfileRequest = None, + request: Union[datastream.CreateConnectionProfileRequest, dict] = None, *, parent: str = None, connection_profile: datastream_resources.ConnectionProfile = None, connection_profile_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -333,7 +335,7 @@ async def create_connection_profile( project and location. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.CreateConnectionProfileRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.CreateConnectionProfileRequest, dict]): The request object. parent (:class:`str`): Required. The parent that owns the @@ -421,11 +423,11 @@ async def create_connection_profile( async def update_connection_profile( self, - request: datastream.UpdateConnectionProfileRequest = None, + request: Union[datastream.UpdateConnectionProfileRequest, dict] = None, *, connection_profile: datastream_resources.ConnectionProfile = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -433,7 +435,7 @@ async def update_connection_profile( connection profile. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.UpdateConnectionProfileRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.UpdateConnectionProfileRequest, dict]): The request object. connection_profile (:class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile`): Required. The ConnectionProfile to @@ -519,17 +521,17 @@ async def update_connection_profile( async def delete_connection_profile( self, - request: datastream.DeleteConnectionProfileRequest = None, + request: Union[datastream.DeleteConnectionProfileRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Use this method to delete a connection profile.. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.DeleteConnectionProfileRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.DeleteConnectionProfileRequest, dict]): The request object. name (:class:`str`): Required. The name of the connection @@ -610,9 +612,9 @@ async def delete_connection_profile( async def discover_connection_profile( self, - request: datastream.DiscoverConnectionProfileRequest = None, + request: Union[datastream.DiscoverConnectionProfileRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> datastream.DiscoverConnectionProfileResponse: @@ -623,7 +625,7 @@ async def discover_connection_profile( that's optionally supplied in the request. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.DiscoverConnectionProfileRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.DiscoverConnectionProfileRequest, dict]): The request object. Request message for 'discover' ConnectionProfile request. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -661,10 +663,10 @@ async def discover_connection_profile( async def list_streams( self, - request: datastream.ListStreamsRequest = None, + request: Union[datastream.ListStreamsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListStreamsAsyncPager: @@ -672,7 +674,7 @@ async def list_streams( location. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.ListStreamsRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.ListStreamsRequest, dict]): The request object. parent (:class:`str`): Required. The parent that owns the @@ -739,17 +741,17 @@ async def list_streams( async def get_stream( self, - request: datastream.GetStreamRequest = None, + request: Union[datastream.GetStreamRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> datastream_resources.Stream: r"""Use this method to get details about a stream. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.GetStreamRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.GetStreamRequest, dict]): The request object. name (:class:`str`): Required. The name of the stream @@ -807,19 +809,19 @@ async def get_stream( async def create_stream( self, - request: datastream.CreateStreamRequest = None, + request: Union[datastream.CreateStreamRequest, dict] = None, *, parent: str = None, stream: datastream_resources.Stream = None, stream_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Use this method to create a stream. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.CreateStreamRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.CreateStreamRequest, dict]): The request object. parent (:class:`str`): Required. The parent that owns the @@ -905,11 +907,11 @@ async def create_stream( async def update_stream( self, - request: datastream.UpdateStreamRequest = None, + request: Union[datastream.UpdateStreamRequest, dict] = None, *, stream: datastream_resources.Stream = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -917,7 +919,7 @@ async def update_stream( stream. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.UpdateStreamRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.UpdateStreamRequest, dict]): The request object. stream (:class:`google.cloud.datastream_v1alpha1.types.Stream`): Required. The stream resource to @@ -1002,17 +1004,17 @@ async def update_stream( async def delete_stream( self, - request: datastream.DeleteStreamRequest = None, + request: Union[datastream.DeleteStreamRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Use this method to delete a stream. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.DeleteStreamRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.DeleteStreamRequest, dict]): The request object. name (:class:`str`): Required. The name of the stream @@ -1093,9 +1095,9 @@ async def delete_stream( async def fetch_errors( self, - request: datastream.FetchErrorsRequest = None, + request: Union[datastream.FetchErrorsRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -1103,7 +1105,7 @@ async def fetch_errors( stream. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.FetchErrorsRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.FetchErrorsRequest, dict]): The request object. Request message for 'FetchErrors' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1154,10 +1156,10 @@ async def fetch_errors( async def fetch_static_ips( self, - request: datastream.FetchStaticIpsRequest = None, + request: Union[datastream.FetchStaticIpsRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.FetchStaticIpsAsyncPager: @@ -1167,7 +1169,7 @@ async def fetch_static_ips( optionally supplied in the request. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.FetchStaticIpsRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.FetchStaticIpsRequest, dict]): The request object. Request message for 'FetchStaticIps' request. name (:class:`str`): @@ -1237,12 +1239,12 @@ async def fetch_static_ips( async def create_private_connection( self, - request: datastream.CreatePrivateConnectionRequest = None, + request: Union[datastream.CreatePrivateConnectionRequest, dict] = None, *, parent: str = None, private_connection: datastream_resources.PrivateConnection = None, private_connection_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -1250,7 +1252,7 @@ async def create_private_connection( configuration. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.CreatePrivateConnectionRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.CreatePrivateConnectionRequest, dict]): The request object. parent (:class:`str`): Required. The parent that owns the @@ -1338,10 +1340,10 @@ async def create_private_connection( async def get_private_connection( self, - request: datastream.GetPrivateConnectionRequest = None, + request: Union[datastream.GetPrivateConnectionRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> datastream_resources.PrivateConnection: @@ -1349,7 +1351,7 @@ async def get_private_connection( connectivity configuration. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.GetPrivateConnectionRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.GetPrivateConnectionRequest, dict]): The request object. name (:class:`str`): Required. The name of the private @@ -1411,10 +1413,10 @@ async def get_private_connection( async def list_private_connections( self, - request: datastream.ListPrivateConnectionsRequest = None, + request: Union[datastream.ListPrivateConnectionsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListPrivateConnectionsAsyncPager: @@ -1422,7 +1424,7 @@ async def list_private_connections( configurations in a project and location. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsRequest, dict]): The request object. parent (:class:`str`): Required. The parent that owns the @@ -1490,10 +1492,10 @@ async def list_private_connections( async def delete_private_connection( self, - request: datastream.DeletePrivateConnectionRequest = None, + request: Union[datastream.DeletePrivateConnectionRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -1501,7 +1503,7 @@ async def delete_private_connection( configuration. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.DeletePrivateConnectionRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.DeletePrivateConnectionRequest, dict]): The request object. name (:class:`str`): Required. The name of the private @@ -1582,12 +1584,12 @@ async def delete_private_connection( async def create_route( self, - request: datastream.CreateRouteRequest = None, + request: Union[datastream.CreateRouteRequest, dict] = None, *, parent: str = None, route: datastream_resources.Route = None, route_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -1595,7 +1597,7 @@ async def create_route( connectivity in a project and location. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.CreateRouteRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.CreateRouteRequest, dict]): The request object. route creation request parent (:class:`str`): Required. The parent that owns the @@ -1682,17 +1684,17 @@ async def create_route( async def get_route( self, - request: datastream.GetRouteRequest = None, + request: Union[datastream.GetRouteRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> datastream_resources.Route: r"""Use this method to get details about a route. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.GetRouteRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.GetRouteRequest, dict]): The request object. route get request name (:class:`str`): Required. The name of the Route @@ -1754,10 +1756,10 @@ async def get_route( async def list_routes( self, - request: datastream.ListRoutesRequest = None, + request: Union[datastream.ListRoutesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListRoutesAsyncPager: @@ -1765,7 +1767,7 @@ async def list_routes( connectivity in a project and location. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.ListRoutesRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.ListRoutesRequest, dict]): The request object. route list request parent (:class:`str`): Required. The parent that owns the @@ -1833,17 +1835,17 @@ async def list_routes( async def delete_route( self, - request: datastream.DeleteRouteRequest = None, + request: Union[datastream.DeleteRouteRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Use this method to delete a route. Args: - request (:class:`google.cloud.datastream_v1alpha1.types.DeleteRouteRequest`): + request (Union[google.cloud.datastream_v1alpha1.types.DeleteRouteRequest, dict]): The request object. route deletion request name (:class:`str`): Required. The name of the Route diff --git a/google/cloud/datastream_v1alpha1/services/datastream/client.py b/google/cloud/datastream_v1alpha1/services/datastream/client.py index 07af2d3..310b934 100644 --- a/google/cloud/datastream_v1alpha1/services/datastream/client.py +++ b/google/cloud/datastream_v1alpha1/services/datastream/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.datastream_v1alpha1.services.datastream import pagers @@ -413,7 +415,7 @@ def list_connection_profiles( request: Union[datastream.ListConnectionProfilesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListConnectionProfilesPager: @@ -491,7 +493,7 @@ def get_connection_profile( request: Union[datastream.GetConnectionProfileRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> datastream_resources.ConnectionProfile: @@ -562,7 +564,7 @@ def create_connection_profile( parent: str = None, connection_profile: datastream_resources.ConnectionProfile = None, connection_profile_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -664,7 +666,7 @@ def update_connection_profile( *, connection_profile: datastream_resources.ConnectionProfile = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -763,7 +765,7 @@ def delete_connection_profile( request: Union[datastream.DeleteConnectionProfileRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -855,7 +857,7 @@ def discover_connection_profile( self, request: Union[datastream.DiscoverConnectionProfileRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> datastream.DiscoverConnectionProfileResponse: @@ -910,7 +912,7 @@ def list_streams( request: Union[datastream.ListStreamsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListStreamsPager: @@ -988,7 +990,7 @@ def get_stream( request: Union[datastream.GetStreamRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> datastream_resources.Stream: @@ -1058,7 +1060,7 @@ def create_stream( parent: str = None, stream: datastream_resources.Stream = None, stream_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1155,7 +1157,7 @@ def update_stream( *, stream: datastream_resources.Stream = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1251,7 +1253,7 @@ def delete_stream( request: Union[datastream.DeleteStreamRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1341,7 +1343,7 @@ def fetch_errors( self, request: Union[datastream.FetchErrorsRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1404,7 +1406,7 @@ def fetch_static_ips( request: Union[datastream.FetchStaticIpsRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.FetchStaticIpsPager: @@ -1489,7 +1491,7 @@ def create_private_connection( parent: str = None, private_connection: datastream_resources.PrivateConnection = None, private_connection_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1590,7 +1592,7 @@ def get_private_connection( request: Union[datastream.GetPrivateConnectionRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> datastream_resources.PrivateConnection: @@ -1663,7 +1665,7 @@ def list_private_connections( request: Union[datastream.ListPrivateConnectionsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListPrivateConnectionsPager: @@ -1742,7 +1744,7 @@ def delete_private_connection( request: Union[datastream.DeletePrivateConnectionRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1838,7 +1840,7 @@ def create_route( parent: str = None, route: datastream_resources.Route = None, route_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1936,7 +1938,7 @@ def get_route( request: Union[datastream.GetRouteRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> datastream_resources.Route: @@ -2008,7 +2010,7 @@ def list_routes( request: Union[datastream.ListRoutesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListRoutesPager: @@ -2087,7 +2089,7 @@ def delete_route( request: Union[datastream.DeleteRouteRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: diff --git a/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py b/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py index e034088..10f7f7d 100644 --- a/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py +++ b/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -40,15 +39,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class DatastreamTransport(abc.ABC): """Abstract transport class for Datastream.""" @@ -98,7 +88,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -131,29 +121,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -252,7 +219,7 @@ def close(self): raise NotImplementedError() @property - def operations_client(self) -> operations_v1.OperationsClient: + def operations_client(self): """Return the client designed to process long-running operations.""" raise NotImplementedError() diff --git a/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py b/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py index dd7c92c..a3b97d4 100644 --- a/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py +++ b/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py @@ -113,7 +113,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py b/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py index b2ee457..97a6d19 100644 --- a/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py +++ b/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py @@ -21,7 +21,6 @@ from google.api_core import operations_v1 # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -160,7 +159,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/datastream_v1alpha1/types/datastream.py b/google/cloud/datastream_v1alpha1/types/datastream.py index 9992189..4fc46ba 100644 --- a/google/cloud/datastream_v1alpha1/types/datastream.py +++ b/google/cloud/datastream_v1alpha1/types/datastream.py @@ -59,27 +59,40 @@ class DiscoverConnectionProfileRequest(proto.Message): r"""Request message for 'discover' ConnectionProfile request. + 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: parent (str): Required. The parent resource of the ConnectionProfile type. Must be in the format ``projects/*/locations/*``. connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile): An ad-hoc ConnectionProfile configuration. + This field is a member of `oneof`_ ``target``. connection_profile_name (str): A reference to an existing ConnectionProfile. + This field is a member of `oneof`_ ``target``. recursive (bool): Whether to retrieve the full hierarchy of data objects (TRUE) or only the current level (FALSE). + This field is a member of `oneof`_ ``depth``. recursion_depth (int): The number of hierarchy levels below the current level to be retrieved. + This field is a member of `oneof`_ ``depth``. oracle_rdbms (google.cloud.datastream_v1alpha1.types.OracleRdbms): Oracle RDBMS to enrich with child data objects and metadata. + This field is a member of `oneof`_ ``data_object``. mysql_rdbms (google.cloud.datastream_v1alpha1.types.MysqlRdbms): MySQL RDBMS to enrich with child data objects and metadata. + This field is a member of `oneof`_ ``data_object``. """ parent = proto.Field(proto.STRING, number=1,) @@ -109,11 +122,20 @@ class DiscoverConnectionProfileRequest(proto.Message): class DiscoverConnectionProfileResponse(proto.Message): r""" + 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: oracle_rdbms (google.cloud.datastream_v1alpha1.types.OracleRdbms): Enriched Oracle RDBMS object. + This field is a member of `oneof`_ ``data_object``. mysql_rdbms (google.cloud.datastream_v1alpha1.types.MysqlRdbms): Enriched MySQL RDBMS object. + This field is a member of `oneof`_ ``data_object``. """ oracle_rdbms = proto.Field( diff --git a/google/cloud/datastream_v1alpha1/types/datastream_resources.py b/google/cloud/datastream_v1alpha1/types/datastream_resources.py index 670d704..d5a0f25 100644 --- a/google/cloud/datastream_v1alpha1/types/datastream_resources.py +++ b/google/cloud/datastream_v1alpha1/types/datastream_resources.py @@ -155,6 +155,13 @@ class StaticServiceIpConnectivity(proto.Message): class ForwardSshTunnelConnectivity(proto.Message): r"""Forward SSH Tunnel connectivity. + 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: hostname (str): Required. Hostname for the SSH tunnel. @@ -164,8 +171,10 @@ class ForwardSshTunnelConnectivity(proto.Message): Port for the SSH tunnel, default value is 22. password (str): Input only. SSH password. + This field is a member of `oneof`_ ``authentication_method``. private_key (str): Input only. SSH private key. + This field is a member of `oneof`_ ``authentication_method``. """ hostname = proto.Field(proto.STRING, number=1,) @@ -317,6 +326,13 @@ class MysqlSslConfig(proto.Message): class ConnectionProfile(proto.Message): r""" + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Output only. The resource's name. @@ -330,19 +346,26 @@ class ConnectionProfile(proto.Message): Required. Display name. oracle_profile (google.cloud.datastream_v1alpha1.types.OracleProfile): Oracle ConnectionProfile configuration. + This field is a member of `oneof`_ ``profile``. gcs_profile (google.cloud.datastream_v1alpha1.types.GcsProfile): Cloud Storage ConnectionProfile configuration. + This field is a member of `oneof`_ ``profile``. mysql_profile (google.cloud.datastream_v1alpha1.types.MysqlProfile): MySQL ConnectionProfile configuration. + This field is a member of `oneof`_ ``profile``. no_connectivity (google.cloud.datastream_v1alpha1.types.NoConnectivitySettings): No connectivity option chosen. + This field is a member of `oneof`_ ``connectivity``. static_service_ip_connectivity (google.cloud.datastream_v1alpha1.types.StaticServiceIpConnectivity): Static Service IP connectivity. + This field is a member of `oneof`_ ``connectivity``. forward_ssh_connectivity (google.cloud.datastream_v1alpha1.types.ForwardSshTunnelConnectivity): Forward SSH tunnel connectivity. + This field is a member of `oneof`_ ``connectivity``. private_connectivity (google.cloud.datastream_v1alpha1.types.PrivateConnectivity): Private connectivity. + This field is a member of `oneof`_ ``connectivity``. """ name = proto.Field(proto.STRING, number=1,) @@ -575,14 +598,23 @@ class MysqlSourceConfig(proto.Message): class SourceConfig(proto.Message): r"""The configuration of the stream source. + 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: source_connection_profile_name (str): Required. Source connection profile identifier. oracle_source_config (google.cloud.datastream_v1alpha1.types.OracleSourceConfig): Oracle data source configuration + This field is a member of `oneof`_ ``source_stream_config``. mysql_source_config (google.cloud.datastream_v1alpha1.types.MysqlSourceConfig): MySQL data source configuration + This field is a member of `oneof`_ ``source_stream_config``. """ source_connection_profile_name = proto.Field(proto.STRING, number=1,) @@ -628,6 +660,13 @@ class JsonCompression(proto.Enum): class GcsDestinationConfig(proto.Message): r"""Google Cloud Storage destination configuration + 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: path (str): Path inside the Cloud Storage bucket to write @@ -644,8 +683,10 @@ class GcsDestinationConfig(proto.Message): created. avro_file_format (google.cloud.datastream_v1alpha1.types.AvroFileFormat): AVRO file format configuration. + This field is a member of `oneof`_ ``file_format``. json_file_format (google.cloud.datastream_v1alpha1.types.JsonFileFormat): JSON file format configuration. + This field is a member of `oneof`_ ``file_format``. """ path = proto.Field(proto.STRING, number=1,) @@ -665,12 +706,15 @@ class GcsDestinationConfig(proto.Message): class DestinationConfig(proto.Message): r"""The configuration of the stream destination. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: destination_connection_profile_name (str): Required. Destination connection profile identifier. gcs_destination_config (google.cloud.datastream_v1alpha1.types.GcsDestinationConfig): + This field is a member of `oneof`_ ``destination_stream_config``. """ destination_connection_profile_name = proto.Field(proto.STRING, number=1,) @@ -685,6 +729,13 @@ class DestinationConfig(proto.Message): class Stream(proto.Message): r""" + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Output only. The stream's name. @@ -709,8 +760,10 @@ class Stream(proto.Message): Automatically backfill objects included in the stream source configuration. Specific objects can be excluded. + This field is a member of `oneof`_ ``backfill_strategy``. backfill_none (google.cloud.datastream_v1alpha1.types.Stream.BackfillNoneStrategy): Do not automatically backfill any objects. + This field is a member of `oneof`_ ``backfill_strategy``. errors (Sequence[google.cloud.datastream_v1alpha1.types.Error]): Output only. Errors on the Stream. """ @@ -731,13 +784,22 @@ class BackfillAllStrategy(proto.Message): r"""Backfill strategy to automatically backfill the Stream's objects. Specific objects can be excluded. + 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: oracle_excluded_objects (google.cloud.datastream_v1alpha1.types.OracleRdbms): Oracle data source objects to avoid backfilling. + This field is a member of `oneof`_ ``excluded_objects``. mysql_excluded_objects (google.cloud.datastream_v1alpha1.types.MysqlRdbms): MySQL data source objects to avoid backfilling. + This field is a member of `oneof`_ ``excluded_objects``. """ oracle_excluded_objects = proto.Field( diff --git a/owl-bot-staging/v1alpha1/.coveragerc b/owl-bot-staging/v1alpha1/.coveragerc deleted file mode 100644 index 5f7f329..0000000 --- a/owl-bot-staging/v1alpha1/.coveragerc +++ /dev/null @@ -1,17 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/datastream/__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/v1alpha1/MANIFEST.in b/owl-bot-staging/v1alpha1/MANIFEST.in deleted file mode 100644 index 9b55389..0000000 --- a/owl-bot-staging/v1alpha1/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/datastream *.py -recursive-include google/cloud/datastream_v1alpha1 *.py diff --git a/owl-bot-staging/v1alpha1/README.rst b/owl-bot-staging/v1alpha1/README.rst deleted file mode 100644 index 9a1922d..0000000 --- a/owl-bot-staging/v1alpha1/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Datastream 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 Datastream 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/v1alpha1/docs/conf.py b/owl-bot-staging/v1alpha1/docs/conf.py deleted file mode 100644 index d2e8d45..0000000 --- a/owl-bot-staging/v1alpha1/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# google-cloud-datastream 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-datastream" -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-datastream-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-datastream.tex", - u"google-cloud-datastream 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-datastream", - u"Google Cloud Datastream 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-datastream", - u"google-cloud-datastream Documentation", - author, - "google-cloud-datastream", - "GAPIC library for Google Cloud Datastream 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/v1alpha1/docs/datastream_v1alpha1/datastream.rst b/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/datastream.rst deleted file mode 100644 index 507205d..0000000 --- a/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/datastream.rst +++ /dev/null @@ -1,10 +0,0 @@ -Datastream ----------------------------- - -.. automodule:: google.cloud.datastream_v1alpha1.services.datastream - :members: - :inherited-members: - -.. automodule:: google.cloud.datastream_v1alpha1.services.datastream.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/services.rst b/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/services.rst deleted file mode 100644 index 1711424..0000000 --- a/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/services.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Datastream v1alpha1 API -================================================= -.. toctree:: - :maxdepth: 2 - - datastream diff --git a/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/types.rst b/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/types.rst deleted file mode 100644 index 2c4d392..0000000 --- a/owl-bot-staging/v1alpha1/docs/datastream_v1alpha1/types.rst +++ /dev/null @@ -1,7 +0,0 @@ -Types for Google Cloud Datastream v1alpha1 API -============================================== - -.. automodule:: google.cloud.datastream_v1alpha1.types - :members: - :undoc-members: - :show-inheritance: diff --git a/owl-bot-staging/v1alpha1/docs/index.rst b/owl-bot-staging/v1alpha1/docs/index.rst deleted file mode 100644 index e0c9ba0..0000000 --- a/owl-bot-staging/v1alpha1/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - datastream_v1alpha1/services - datastream_v1alpha1/types diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream/__init__.py b/owl-bot-staging/v1alpha1/google/cloud/datastream/__init__.py deleted file mode 100644 index 7b68728..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream/__init__.py +++ /dev/null @@ -1,149 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from google.cloud.datastream_v1alpha1.services.datastream.client import DatastreamClient -from google.cloud.datastream_v1alpha1.services.datastream.async_client import DatastreamAsyncClient - -from google.cloud.datastream_v1alpha1.types.datastream import CreateConnectionProfileRequest -from google.cloud.datastream_v1alpha1.types.datastream import CreatePrivateConnectionRequest -from google.cloud.datastream_v1alpha1.types.datastream import CreateRouteRequest -from google.cloud.datastream_v1alpha1.types.datastream import CreateStreamRequest -from google.cloud.datastream_v1alpha1.types.datastream import DeleteConnectionProfileRequest -from google.cloud.datastream_v1alpha1.types.datastream import DeletePrivateConnectionRequest -from google.cloud.datastream_v1alpha1.types.datastream import DeleteRouteRequest -from google.cloud.datastream_v1alpha1.types.datastream import DeleteStreamRequest -from google.cloud.datastream_v1alpha1.types.datastream import DiscoverConnectionProfileRequest -from google.cloud.datastream_v1alpha1.types.datastream import DiscoverConnectionProfileResponse -from google.cloud.datastream_v1alpha1.types.datastream import FetchErrorsRequest -from google.cloud.datastream_v1alpha1.types.datastream import FetchErrorsResponse -from google.cloud.datastream_v1alpha1.types.datastream import FetchStaticIpsRequest -from google.cloud.datastream_v1alpha1.types.datastream import FetchStaticIpsResponse -from google.cloud.datastream_v1alpha1.types.datastream import GetConnectionProfileRequest -from google.cloud.datastream_v1alpha1.types.datastream import GetPrivateConnectionRequest -from google.cloud.datastream_v1alpha1.types.datastream import GetRouteRequest -from google.cloud.datastream_v1alpha1.types.datastream import GetStreamRequest -from google.cloud.datastream_v1alpha1.types.datastream import ListConnectionProfilesRequest -from google.cloud.datastream_v1alpha1.types.datastream import ListConnectionProfilesResponse -from google.cloud.datastream_v1alpha1.types.datastream import ListPrivateConnectionsRequest -from google.cloud.datastream_v1alpha1.types.datastream import ListPrivateConnectionsResponse -from google.cloud.datastream_v1alpha1.types.datastream import ListRoutesRequest -from google.cloud.datastream_v1alpha1.types.datastream import ListRoutesResponse -from google.cloud.datastream_v1alpha1.types.datastream import ListStreamsRequest -from google.cloud.datastream_v1alpha1.types.datastream import ListStreamsResponse -from google.cloud.datastream_v1alpha1.types.datastream import OperationMetadata -from google.cloud.datastream_v1alpha1.types.datastream import UpdateConnectionProfileRequest -from google.cloud.datastream_v1alpha1.types.datastream import UpdateStreamRequest -from google.cloud.datastream_v1alpha1.types.datastream_resources import AvroFileFormat -from google.cloud.datastream_v1alpha1.types.datastream_resources import ConnectionProfile -from google.cloud.datastream_v1alpha1.types.datastream_resources import DestinationConfig -from google.cloud.datastream_v1alpha1.types.datastream_resources import Error -from google.cloud.datastream_v1alpha1.types.datastream_resources import ForwardSshTunnelConnectivity -from google.cloud.datastream_v1alpha1.types.datastream_resources import GcsDestinationConfig -from google.cloud.datastream_v1alpha1.types.datastream_resources import GcsProfile -from google.cloud.datastream_v1alpha1.types.datastream_resources import JsonFileFormat -from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlColumn -from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlDatabase -from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlProfile -from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlRdbms -from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlSourceConfig -from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlSslConfig -from google.cloud.datastream_v1alpha1.types.datastream_resources import MysqlTable -from google.cloud.datastream_v1alpha1.types.datastream_resources import NoConnectivitySettings -from google.cloud.datastream_v1alpha1.types.datastream_resources import OracleColumn -from google.cloud.datastream_v1alpha1.types.datastream_resources import OracleProfile -from google.cloud.datastream_v1alpha1.types.datastream_resources import OracleRdbms -from google.cloud.datastream_v1alpha1.types.datastream_resources import OracleSchema -from google.cloud.datastream_v1alpha1.types.datastream_resources import OracleSourceConfig -from google.cloud.datastream_v1alpha1.types.datastream_resources import OracleTable -from google.cloud.datastream_v1alpha1.types.datastream_resources import PrivateConnection -from google.cloud.datastream_v1alpha1.types.datastream_resources import PrivateConnectivity -from google.cloud.datastream_v1alpha1.types.datastream_resources import Route -from google.cloud.datastream_v1alpha1.types.datastream_resources import SourceConfig -from google.cloud.datastream_v1alpha1.types.datastream_resources import StaticServiceIpConnectivity -from google.cloud.datastream_v1alpha1.types.datastream_resources import Stream -from google.cloud.datastream_v1alpha1.types.datastream_resources import Validation -from google.cloud.datastream_v1alpha1.types.datastream_resources import ValidationMessage -from google.cloud.datastream_v1alpha1.types.datastream_resources import ValidationResult -from google.cloud.datastream_v1alpha1.types.datastream_resources import VpcPeeringConfig -from google.cloud.datastream_v1alpha1.types.datastream_resources import GcsFileFormat -from google.cloud.datastream_v1alpha1.types.datastream_resources import SchemaFileFormat - -__all__ = ('DatastreamClient', - 'DatastreamAsyncClient', - 'CreateConnectionProfileRequest', - 'CreatePrivateConnectionRequest', - 'CreateRouteRequest', - 'CreateStreamRequest', - 'DeleteConnectionProfileRequest', - 'DeletePrivateConnectionRequest', - 'DeleteRouteRequest', - 'DeleteStreamRequest', - 'DiscoverConnectionProfileRequest', - 'DiscoverConnectionProfileResponse', - 'FetchErrorsRequest', - 'FetchErrorsResponse', - 'FetchStaticIpsRequest', - 'FetchStaticIpsResponse', - 'GetConnectionProfileRequest', - 'GetPrivateConnectionRequest', - 'GetRouteRequest', - 'GetStreamRequest', - 'ListConnectionProfilesRequest', - 'ListConnectionProfilesResponse', - 'ListPrivateConnectionsRequest', - 'ListPrivateConnectionsResponse', - 'ListRoutesRequest', - 'ListRoutesResponse', - 'ListStreamsRequest', - 'ListStreamsResponse', - 'OperationMetadata', - 'UpdateConnectionProfileRequest', - 'UpdateStreamRequest', - 'AvroFileFormat', - 'ConnectionProfile', - 'DestinationConfig', - 'Error', - 'ForwardSshTunnelConnectivity', - 'GcsDestinationConfig', - 'GcsProfile', - 'JsonFileFormat', - 'MysqlColumn', - 'MysqlDatabase', - 'MysqlProfile', - 'MysqlRdbms', - 'MysqlSourceConfig', - 'MysqlSslConfig', - 'MysqlTable', - 'NoConnectivitySettings', - 'OracleColumn', - 'OracleProfile', - 'OracleRdbms', - 'OracleSchema', - 'OracleSourceConfig', - 'OracleTable', - 'PrivateConnection', - 'PrivateConnectivity', - 'Route', - 'SourceConfig', - 'StaticServiceIpConnectivity', - 'Stream', - 'Validation', - 'ValidationMessage', - 'ValidationResult', - 'VpcPeeringConfig', - 'GcsFileFormat', - 'SchemaFileFormat', -) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream/py.typed b/owl-bot-staging/v1alpha1/google/cloud/datastream/py.typed deleted file mode 100644 index 38ae0fa..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-datastream package uses inline types. diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/__init__.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/__init__.py deleted file mode 100644 index 671eb8b..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/__init__.py +++ /dev/null @@ -1,150 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from .services.datastream import DatastreamClient -from .services.datastream import DatastreamAsyncClient - -from .types.datastream import CreateConnectionProfileRequest -from .types.datastream import CreatePrivateConnectionRequest -from .types.datastream import CreateRouteRequest -from .types.datastream import CreateStreamRequest -from .types.datastream import DeleteConnectionProfileRequest -from .types.datastream import DeletePrivateConnectionRequest -from .types.datastream import DeleteRouteRequest -from .types.datastream import DeleteStreamRequest -from .types.datastream import DiscoverConnectionProfileRequest -from .types.datastream import DiscoverConnectionProfileResponse -from .types.datastream import FetchErrorsRequest -from .types.datastream import FetchErrorsResponse -from .types.datastream import FetchStaticIpsRequest -from .types.datastream import FetchStaticIpsResponse -from .types.datastream import GetConnectionProfileRequest -from .types.datastream import GetPrivateConnectionRequest -from .types.datastream import GetRouteRequest -from .types.datastream import GetStreamRequest -from .types.datastream import ListConnectionProfilesRequest -from .types.datastream import ListConnectionProfilesResponse -from .types.datastream import ListPrivateConnectionsRequest -from .types.datastream import ListPrivateConnectionsResponse -from .types.datastream import ListRoutesRequest -from .types.datastream import ListRoutesResponse -from .types.datastream import ListStreamsRequest -from .types.datastream import ListStreamsResponse -from .types.datastream import OperationMetadata -from .types.datastream import UpdateConnectionProfileRequest -from .types.datastream import UpdateStreamRequest -from .types.datastream_resources import AvroFileFormat -from .types.datastream_resources import ConnectionProfile -from .types.datastream_resources import DestinationConfig -from .types.datastream_resources import Error -from .types.datastream_resources import ForwardSshTunnelConnectivity -from .types.datastream_resources import GcsDestinationConfig -from .types.datastream_resources import GcsProfile -from .types.datastream_resources import JsonFileFormat -from .types.datastream_resources import MysqlColumn -from .types.datastream_resources import MysqlDatabase -from .types.datastream_resources import MysqlProfile -from .types.datastream_resources import MysqlRdbms -from .types.datastream_resources import MysqlSourceConfig -from .types.datastream_resources import MysqlSslConfig -from .types.datastream_resources import MysqlTable -from .types.datastream_resources import NoConnectivitySettings -from .types.datastream_resources import OracleColumn -from .types.datastream_resources import OracleProfile -from .types.datastream_resources import OracleRdbms -from .types.datastream_resources import OracleSchema -from .types.datastream_resources import OracleSourceConfig -from .types.datastream_resources import OracleTable -from .types.datastream_resources import PrivateConnection -from .types.datastream_resources import PrivateConnectivity -from .types.datastream_resources import Route -from .types.datastream_resources import SourceConfig -from .types.datastream_resources import StaticServiceIpConnectivity -from .types.datastream_resources import Stream -from .types.datastream_resources import Validation -from .types.datastream_resources import ValidationMessage -from .types.datastream_resources import ValidationResult -from .types.datastream_resources import VpcPeeringConfig -from .types.datastream_resources import GcsFileFormat -from .types.datastream_resources import SchemaFileFormat - -__all__ = ( - 'DatastreamAsyncClient', -'AvroFileFormat', -'ConnectionProfile', -'CreateConnectionProfileRequest', -'CreatePrivateConnectionRequest', -'CreateRouteRequest', -'CreateStreamRequest', -'DatastreamClient', -'DeleteConnectionProfileRequest', -'DeletePrivateConnectionRequest', -'DeleteRouteRequest', -'DeleteStreamRequest', -'DestinationConfig', -'DiscoverConnectionProfileRequest', -'DiscoverConnectionProfileResponse', -'Error', -'FetchErrorsRequest', -'FetchErrorsResponse', -'FetchStaticIpsRequest', -'FetchStaticIpsResponse', -'ForwardSshTunnelConnectivity', -'GcsDestinationConfig', -'GcsFileFormat', -'GcsProfile', -'GetConnectionProfileRequest', -'GetPrivateConnectionRequest', -'GetRouteRequest', -'GetStreamRequest', -'JsonFileFormat', -'ListConnectionProfilesRequest', -'ListConnectionProfilesResponse', -'ListPrivateConnectionsRequest', -'ListPrivateConnectionsResponse', -'ListRoutesRequest', -'ListRoutesResponse', -'ListStreamsRequest', -'ListStreamsResponse', -'MysqlColumn', -'MysqlDatabase', -'MysqlProfile', -'MysqlRdbms', -'MysqlSourceConfig', -'MysqlSslConfig', -'MysqlTable', -'NoConnectivitySettings', -'OperationMetadata', -'OracleColumn', -'OracleProfile', -'OracleRdbms', -'OracleSchema', -'OracleSourceConfig', -'OracleTable', -'PrivateConnection', -'PrivateConnectivity', -'Route', -'SchemaFileFormat', -'SourceConfig', -'StaticServiceIpConnectivity', -'Stream', -'UpdateConnectionProfileRequest', -'UpdateStreamRequest', -'Validation', -'ValidationMessage', -'ValidationResult', -'VpcPeeringConfig', -) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/gapic_metadata.json b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/gapic_metadata.json deleted file mode 100644 index a82501e..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/gapic_metadata.json +++ /dev/null @@ -1,233 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.datastream_v1alpha1", - "protoPackage": "google.cloud.datastream.v1alpha1", - "schema": "1.0", - "services": { - "Datastream": { - "clients": { - "grpc": { - "libraryClient": "DatastreamClient", - "rpcs": { - "CreateConnectionProfile": { - "methods": [ - "create_connection_profile" - ] - }, - "CreatePrivateConnection": { - "methods": [ - "create_private_connection" - ] - }, - "CreateRoute": { - "methods": [ - "create_route" - ] - }, - "CreateStream": { - "methods": [ - "create_stream" - ] - }, - "DeleteConnectionProfile": { - "methods": [ - "delete_connection_profile" - ] - }, - "DeletePrivateConnection": { - "methods": [ - "delete_private_connection" - ] - }, - "DeleteRoute": { - "methods": [ - "delete_route" - ] - }, - "DeleteStream": { - "methods": [ - "delete_stream" - ] - }, - "DiscoverConnectionProfile": { - "methods": [ - "discover_connection_profile" - ] - }, - "FetchErrors": { - "methods": [ - "fetch_errors" - ] - }, - "FetchStaticIps": { - "methods": [ - "fetch_static_ips" - ] - }, - "GetConnectionProfile": { - "methods": [ - "get_connection_profile" - ] - }, - "GetPrivateConnection": { - "methods": [ - "get_private_connection" - ] - }, - "GetRoute": { - "methods": [ - "get_route" - ] - }, - "GetStream": { - "methods": [ - "get_stream" - ] - }, - "ListConnectionProfiles": { - "methods": [ - "list_connection_profiles" - ] - }, - "ListPrivateConnections": { - "methods": [ - "list_private_connections" - ] - }, - "ListRoutes": { - "methods": [ - "list_routes" - ] - }, - "ListStreams": { - "methods": [ - "list_streams" - ] - }, - "UpdateConnectionProfile": { - "methods": [ - "update_connection_profile" - ] - }, - "UpdateStream": { - "methods": [ - "update_stream" - ] - } - } - }, - "grpc-async": { - "libraryClient": "DatastreamAsyncClient", - "rpcs": { - "CreateConnectionProfile": { - "methods": [ - "create_connection_profile" - ] - }, - "CreatePrivateConnection": { - "methods": [ - "create_private_connection" - ] - }, - "CreateRoute": { - "methods": [ - "create_route" - ] - }, - "CreateStream": { - "methods": [ - "create_stream" - ] - }, - "DeleteConnectionProfile": { - "methods": [ - "delete_connection_profile" - ] - }, - "DeletePrivateConnection": { - "methods": [ - "delete_private_connection" - ] - }, - "DeleteRoute": { - "methods": [ - "delete_route" - ] - }, - "DeleteStream": { - "methods": [ - "delete_stream" - ] - }, - "DiscoverConnectionProfile": { - "methods": [ - "discover_connection_profile" - ] - }, - "FetchErrors": { - "methods": [ - "fetch_errors" - ] - }, - "FetchStaticIps": { - "methods": [ - "fetch_static_ips" - ] - }, - "GetConnectionProfile": { - "methods": [ - "get_connection_profile" - ] - }, - "GetPrivateConnection": { - "methods": [ - "get_private_connection" - ] - }, - "GetRoute": { - "methods": [ - "get_route" - ] - }, - "GetStream": { - "methods": [ - "get_stream" - ] - }, - "ListConnectionProfiles": { - "methods": [ - "list_connection_profiles" - ] - }, - "ListPrivateConnections": { - "methods": [ - "list_private_connections" - ] - }, - "ListRoutes": { - "methods": [ - "list_routes" - ] - }, - "ListStreams": { - "methods": [ - "list_streams" - ] - }, - "UpdateConnectionProfile": { - "methods": [ - "update_connection_profile" - ] - }, - "UpdateStream": { - "methods": [ - "update_stream" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/py.typed b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/py.typed deleted file mode 100644 index 38ae0fa..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-datastream package uses inline types. diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/__init__.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/__init__.py deleted file mode 100644 index 4de6597..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/__init__.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/__init__.py deleted file mode 100644 index f9ff72b..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from .client import DatastreamClient -from .async_client import DatastreamAsyncClient - -__all__ = ( - 'DatastreamClient', - 'DatastreamAsyncClient', -) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/async_client.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/async_client.py deleted file mode 100644 index 47ade10..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/async_client.py +++ /dev/null @@ -1,2029 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -import functools -import re -from typing import Dict, Sequence, Tuple, Type, Union -import pkg_resources - -from google.api_core.client_options import ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -OptionalRetry = Union[retries.Retry, object] - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.datastream_v1alpha1.services.datastream import pagers -from google.cloud.datastream_v1alpha1.types import datastream -from google.cloud.datastream_v1alpha1.types import datastream_resources -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 DatastreamTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import DatastreamGrpcAsyncIOTransport -from .client import DatastreamClient - - -class DatastreamAsyncClient: - """Datastream service""" - - _client: DatastreamClient - - DEFAULT_ENDPOINT = DatastreamClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = DatastreamClient.DEFAULT_MTLS_ENDPOINT - - connection_profile_path = staticmethod(DatastreamClient.connection_profile_path) - parse_connection_profile_path = staticmethod(DatastreamClient.parse_connection_profile_path) - private_connection_path = staticmethod(DatastreamClient.private_connection_path) - parse_private_connection_path = staticmethod(DatastreamClient.parse_private_connection_path) - route_path = staticmethod(DatastreamClient.route_path) - parse_route_path = staticmethod(DatastreamClient.parse_route_path) - stream_path = staticmethod(DatastreamClient.stream_path) - parse_stream_path = staticmethod(DatastreamClient.parse_stream_path) - common_billing_account_path = staticmethod(DatastreamClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(DatastreamClient.parse_common_billing_account_path) - common_folder_path = staticmethod(DatastreamClient.common_folder_path) - parse_common_folder_path = staticmethod(DatastreamClient.parse_common_folder_path) - common_organization_path = staticmethod(DatastreamClient.common_organization_path) - parse_common_organization_path = staticmethod(DatastreamClient.parse_common_organization_path) - common_project_path = staticmethod(DatastreamClient.common_project_path) - parse_common_project_path = staticmethod(DatastreamClient.parse_common_project_path) - common_location_path = staticmethod(DatastreamClient.common_location_path) - parse_common_location_path = staticmethod(DatastreamClient.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: - DatastreamAsyncClient: The constructed client. - """ - return DatastreamClient.from_service_account_info.__func__(DatastreamAsyncClient, 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: - DatastreamAsyncClient: The constructed client. - """ - return DatastreamClient.from_service_account_file.__func__(DatastreamAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> DatastreamTransport: - """Returns the transport used by the client instance. - - Returns: - DatastreamTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(DatastreamClient).get_transport_class, type(DatastreamClient)) - - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, DatastreamTransport] = "grpc_asyncio", - client_options: ClientOptions = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the datastream 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, ~.DatastreamTransport]): 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 = DatastreamClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_connection_profiles(self, - request: Union[datastream.ListConnectionProfilesRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListConnectionProfilesAsyncPager: - r"""Use this method to list connection profiles created - in a project and location. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.ListConnectionProfilesRequest, dict]): - The request object. - parent (:class:`str`): - Required. The parent that owns the - collection of connection profiles. - - 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.datastream_v1alpha1.services.datastream.pagers.ListConnectionProfilesAsyncPager: - 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 = datastream.ListConnectionProfilesRequest(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_connection_profiles, - default_timeout=None, - client_info=DEFAULT_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.ListConnectionProfilesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_connection_profile(self, - request: Union[datastream.GetConnectionProfileRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> datastream_resources.ConnectionProfile: - r"""Use this method to get details about a connection - profile. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.GetConnectionProfileRequest, dict]): - The request object. - name (:class:`str`): - Required. The name of the connection - profile 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.datastream_v1alpha1.types.ConnectionProfile: - - """ - # Create or coerce a protobuf request object. - # Sanity 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 = datastream.GetConnectionProfileRequest(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_connection_profile, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_connection_profile(self, - request: Union[datastream.CreateConnectionProfileRequest, dict] = None, - *, - parent: str = None, - connection_profile: datastream_resources.ConnectionProfile = None, - connection_profile_id: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Use this method to create a connection profile in a - project and location. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.CreateConnectionProfileRequest, dict]): - The request object. - parent (:class:`str`): - Required. The parent that owns the - collection of ConnectionProfiles. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - connection_profile (:class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile`): - Required. The connection profile - resource to create. - - This corresponds to the ``connection_profile`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - connection_profile_id (:class:`str`): - Required. The connection profile - identifier. - - This corresponds to the ``connection_profile_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile` - - """ - # Create or coerce a protobuf request object. - # Sanity 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, connection_profile, connection_profile_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 = datastream.CreateConnectionProfileRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if connection_profile is not None: - request.connection_profile = connection_profile - if connection_profile_id is not None: - request.connection_profile_id = connection_profile_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_connection_profile, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - datastream_resources.ConnectionProfile, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_connection_profile(self, - request: Union[datastream.UpdateConnectionProfileRequest, dict] = None, - *, - connection_profile: datastream_resources.ConnectionProfile = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Use this method to update the parameters of a - connection profile. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.UpdateConnectionProfileRequest, dict]): - The request object. - connection_profile (:class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile`): - Required. The ConnectionProfile to - update. - - This corresponds to the ``connection_profile`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Optional. Field mask is used to specify the fields to be - overwritten in the ConnectionProfile resource by the - update. The fields specified in the update_mask are - relative to the resource, not the full request. A field - will be overwritten if it is in the mask. If the user - does not provide a mask then all fields will be - overwritten. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile` - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([connection_profile, 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 = datastream.UpdateConnectionProfileRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if connection_profile is not None: - request.connection_profile = connection_profile - 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_connection_profile, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("connection_profile.name", request.connection_profile.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, - datastream_resources.ConnectionProfile, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_connection_profile(self, - request: Union[datastream.DeleteConnectionProfileRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Use this method to delete a connection profile.. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.DeleteConnectionProfileRequest, dict]): - The request object. - name (:class:`str`): - Required. The name of the connection - profile resource 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 = datastream.DeleteConnectionProfileRequest(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_connection_profile, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - async def discover_connection_profile(self, - request: Union[datastream.DiscoverConnectionProfileRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> datastream.DiscoverConnectionProfileResponse: - r"""Use this method to discover a connection profile. - The discover API call exposes the data objects and - metadata belonging to the profile. Typically, a request - returns children data objects under a parent data object - that's optionally supplied in the request. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.DiscoverConnectionProfileRequest, dict]): - The request object. Request message for 'discover' - ConnectionProfile request. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.datastream_v1alpha1.types.DiscoverConnectionProfileResponse: - - """ - # Create or coerce a protobuf request object. - request = datastream.DiscoverConnectionProfileRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.discover_connection_profile, - default_timeout=None, - client_info=DEFAULT_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 list_streams(self, - request: Union[datastream.ListStreamsRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListStreamsAsyncPager: - r"""Use this method to list streams in a project and - location. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.ListStreamsRequest, dict]): - The request object. - parent (:class:`str`): - Required. The parent that owns the - collection of streams. - - 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.datastream_v1alpha1.services.datastream.pagers.ListStreamsAsyncPager: - 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 = datastream.ListStreamsRequest(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_streams, - default_timeout=None, - client_info=DEFAULT_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.ListStreamsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_stream(self, - request: Union[datastream.GetStreamRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> datastream_resources.Stream: - r"""Use this method to get details about a stream. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.GetStreamRequest, dict]): - The request object. - name (:class:`str`): - Required. The name of the stream - 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.datastream_v1alpha1.types.Stream: - - """ - # Create or coerce a protobuf request object. - # Sanity 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 = datastream.GetStreamRequest(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_stream, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_stream(self, - request: Union[datastream.CreateStreamRequest, dict] = None, - *, - parent: str = None, - stream: datastream_resources.Stream = None, - stream_id: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Use this method to create a stream. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.CreateStreamRequest, dict]): - The request object. - parent (:class:`str`): - Required. The parent that owns the - collection of streams. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - stream (:class:`google.cloud.datastream_v1alpha1.types.Stream`): - Required. The stream resource to - create. - - This corresponds to the ``stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - stream_id (:class:`str`): - Required. The stream identifier. - This corresponds to the ``stream_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.datastream_v1alpha1.types.Stream` - - """ - # Create or coerce a protobuf request object. - # Sanity 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, stream, stream_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 = datastream.CreateStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if stream is not None: - request.stream = stream - if stream_id is not None: - request.stream_id = stream_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_stream, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - datastream_resources.Stream, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_stream(self, - request: Union[datastream.UpdateStreamRequest, dict] = None, - *, - stream: datastream_resources.Stream = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Use this method to update the configuration of a - stream. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.UpdateStreamRequest, dict]): - The request object. - stream (:class:`google.cloud.datastream_v1alpha1.types.Stream`): - Required. The stream resource to - update. - - This corresponds to the ``stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Optional. Field mask is used to specify the fields to be - overwritten in the stream resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.datastream_v1alpha1.types.Stream` - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([stream, 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 = datastream.UpdateStreamRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if stream is not None: - request.stream = stream - 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_stream, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("stream.name", request.stream.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, - datastream_resources.Stream, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_stream(self, - request: Union[datastream.DeleteStreamRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Use this method to delete a stream. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.DeleteStreamRequest, dict]): - The request object. - name (:class:`str`): - Required. The name of the stream - resource 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 = datastream.DeleteStreamRequest(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_stream, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - async def fetch_errors(self, - request: Union[datastream.FetchErrorsRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Use this method to fetch any errors associated with a - stream. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.FetchErrorsRequest, dict]): - The request object. Request message for 'FetchErrors' - request. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout 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.datastream_v1alpha1.types.FetchErrorsResponse` - Response message for a 'FetchErrors' response. - - """ - # Create or coerce a protobuf request object. - request = datastream.FetchErrorsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.fetch_errors, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("stream", request.stream), - )), - ) - - # 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, - datastream.FetchErrorsResponse, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - async def fetch_static_ips(self, - request: Union[datastream.FetchStaticIpsRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.FetchStaticIpsAsyncPager: - r"""The FetchStaticIps API call exposes the static ips - used by Datastream. Typically, a request returns - children data objects under a parent data object that's - optionally supplied in the request. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.FetchStaticIpsRequest, dict]): - The request object. Request message for 'FetchStaticIps' - request. - name (:class:`str`): - Required. The name resource of the Response type. Must - be in the format ``projects/*/locations/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.datastream_v1alpha1.services.datastream.pagers.FetchStaticIpsAsyncPager: - Response message for a - 'FetchStaticIps' response. - 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([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 = datastream.FetchStaticIpsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.fetch_static_ips, - default_timeout=None, - client_info=DEFAULT_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, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.FetchStaticIpsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_private_connection(self, - request: Union[datastream.CreatePrivateConnectionRequest, dict] = None, - *, - parent: str = None, - private_connection: datastream_resources.PrivateConnection = None, - private_connection_id: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Use this method to create a private connectivity - configuration. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.CreatePrivateConnectionRequest, dict]): - The request object. - parent (:class:`str`): - Required. The parent that owns the - collection of PrivateConnections. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - private_connection (:class:`google.cloud.datastream_v1alpha1.types.PrivateConnection`): - Required. The Private Connectivity - resource to create. - - This corresponds to the ``private_connection`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - private_connection_id (:class:`str`): - Required. The private connectivity - identifier. - - This corresponds to the ``private_connection_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.datastream_v1alpha1.types.PrivateConnection` The PrivateConnection resource is used to establish private connectivity - between Datastream and a customer's network. - - """ - # Create or coerce a protobuf request object. - # Sanity 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, private_connection, private_connection_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 = datastream.CreatePrivateConnectionRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if private_connection is not None: - request.private_connection = private_connection - if private_connection_id is not None: - request.private_connection_id = private_connection_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_private_connection, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - datastream_resources.PrivateConnection, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - async def get_private_connection(self, - request: Union[datastream.GetPrivateConnectionRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> datastream_resources.PrivateConnection: - r"""Use this method to get details about a private - connectivity configuration. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.GetPrivateConnectionRequest, dict]): - The request object. - name (:class:`str`): - Required. The name of the private - connectivity configuration 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.datastream_v1alpha1.types.PrivateConnection: - The PrivateConnection resource is - used to establish private connectivity - between Datastream and a customer's - network. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 = datastream.GetPrivateConnectionRequest(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_private_connection, - default_timeout=None, - client_info=DEFAULT_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_private_connections(self, - request: Union[datastream.ListPrivateConnectionsRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListPrivateConnectionsAsyncPager: - r"""Use this method to list private connectivity - configurations in a project and location. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsRequest, dict]): - The request object. - parent (:class:`str`): - Required. The parent that owns the - collection of private connectivity - configurations. - - 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.datastream_v1alpha1.services.datastream.pagers.ListPrivateConnectionsAsyncPager: - 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 = datastream.ListPrivateConnectionsRequest(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_private_connections, - default_timeout=None, - client_info=DEFAULT_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.ListPrivateConnectionsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_private_connection(self, - request: Union[datastream.DeletePrivateConnectionRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Use this method to delete a private connectivity - configuration. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.DeletePrivateConnectionRequest, dict]): - The request object. - name (:class:`str`): - Required. The name of the private - connectivity configuration 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 = datastream.DeletePrivateConnectionRequest(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_private_connection, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - async def create_route(self, - request: Union[datastream.CreateRouteRequest, dict] = None, - *, - parent: str = None, - route: datastream_resources.Route = None, - route_id: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Use this method to create a route for a private - connectivity in a project and location. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.CreateRouteRequest, dict]): - The request object. route creation request - parent (:class:`str`): - Required. The parent that owns the - collection of Routes. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - route (:class:`google.cloud.datastream_v1alpha1.types.Route`): - Required. The Route resource to - create. - - This corresponds to the ``route`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - route_id (:class:`str`): - Required. The Route identifier. - This corresponds to the ``route_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.datastream_v1alpha1.types.Route` The Route resource is the child of the PrivateConnection resource. - It used to define a route for a PrivateConnection - setup. - - """ - # Create or coerce a protobuf request object. - # Sanity 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, route, route_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 = datastream.CreateRouteRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if route is not None: - request.route = route - if route_id is not None: - request.route_id = route_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_route, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - datastream_resources.Route, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - async def get_route(self, - request: Union[datastream.GetRouteRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> datastream_resources.Route: - r"""Use this method to get details about a route. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.GetRouteRequest, dict]): - The request object. route get request - name (:class:`str`): - Required. The name of the Route - 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.datastream_v1alpha1.types.Route: - The Route resource is the child of - the PrivateConnection resource. It used - to define a route for a - PrivateConnection setup. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 = datastream.GetRouteRequest(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_route, - default_timeout=None, - client_info=DEFAULT_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_routes(self, - request: Union[datastream.ListRoutesRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListRoutesAsyncPager: - r"""Use this method to list routes created for a private - connectivity in a project and location. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.ListRoutesRequest, dict]): - The request object. route list request - parent (:class:`str`): - Required. The parent that owns the - collection of Routess. - - 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.datastream_v1alpha1.services.datastream.pagers.ListRoutesAsyncPager: - route list response - 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 = datastream.ListRoutesRequest(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_routes, - default_timeout=None, - client_info=DEFAULT_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.ListRoutesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_route(self, - request: Union[datastream.DeleteRouteRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Use this method to delete a route. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.DeleteRouteRequest, dict]): - The request object. route deletion request - name (:class:`str`): - Required. The name of the Route - resource 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 = datastream.DeleteRouteRequest(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_route, - default_timeout=60.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - async def __aenter__(self): - return self - - async def __aexit__(self, exc_type, exc, tb): - await self.transport.close() - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-datastream", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "DatastreamAsyncClient", -) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/client.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/client.py deleted file mode 100644 index e97b5cf..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/client.py +++ /dev/null @@ -1,2255 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -from distutils import util -import os -import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources - -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -OptionalRetry = Union[retries.Retry, object] - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.datastream_v1alpha1.services.datastream import pagers -from google.cloud.datastream_v1alpha1.types import datastream -from google.cloud.datastream_v1alpha1.types import datastream_resources -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 DatastreamTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import DatastreamGrpcTransport -from .transports.grpc_asyncio import DatastreamGrpcAsyncIOTransport - - -class DatastreamClientMeta(type): - """Metaclass for the Datastream 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[DatastreamTransport]] - _transport_registry["grpc"] = DatastreamGrpcTransport - _transport_registry["grpc_asyncio"] = DatastreamGrpcAsyncIOTransport - - def get_transport_class(cls, - label: str = None, - ) -> Type[DatastreamTransport]: - """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 DatastreamClient(metaclass=DatastreamClientMeta): - """Datastream service""" - - @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 = "datastream.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: - DatastreamClient: 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: - DatastreamClient: 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) -> DatastreamTransport: - """Returns the transport used by the client instance. - - Returns: - DatastreamTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def connection_profile_path(project: str,location: str,connection_profile: str,) -> str: - """Returns a fully-qualified connection_profile string.""" - return "projects/{project}/locations/{location}/connectionProfiles/{connection_profile}".format(project=project, location=location, connection_profile=connection_profile, ) - - @staticmethod - def parse_connection_profile_path(path: str) -> Dict[str,str]: - """Parses a connection_profile path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/connectionProfiles/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def private_connection_path(project: str,location: str,private_connection: str,) -> str: - """Returns a fully-qualified private_connection string.""" - return "projects/{project}/locations/{location}/privateConnections/{private_connection}".format(project=project, location=location, private_connection=private_connection, ) - - @staticmethod - def parse_private_connection_path(path: str) -> Dict[str,str]: - """Parses a private_connection path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/privateConnections/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def route_path(project: str,location: str,private_connection: str,route: str,) -> str: - """Returns a fully-qualified route string.""" - return "projects/{project}/locations/{location}/privateConnections/{private_connection}/routes/{route}".format(project=project, location=location, private_connection=private_connection, route=route, ) - - @staticmethod - def parse_route_path(path: str) -> Dict[str,str]: - """Parses a route path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/privateConnections/(?P.+?)/routes/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def stream_path(project: str,location: str,stream: str,) -> str: - """Returns a fully-qualified stream string.""" - return "projects/{project}/locations/{location}/streams/{stream}".format(project=project, location=location, stream=stream, ) - - @staticmethod - def parse_stream_path(path: str) -> Dict[str,str]: - """Parses a stream path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/streams/(?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, DatastreamTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the datastream 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, DatastreamTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) - if client_options is None: - client_options = client_options_lib.ClientOptions() - - # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))) - - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - if isinstance(transport, DatastreamTransport): - # transport is a DatastreamTransport instance. - if credentials or client_options.credentials_file: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") - if client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = transport - else: - Transport = type(self).get_transport_class(transport) - self._transport = Transport( - credentials=credentials, - credentials_file=client_options.credentials_file, - host=api_endpoint, - scopes=client_options.scopes, - client_cert_source_for_mtls=client_cert_source_func, - quota_project_id=client_options.quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - ) - - def list_connection_profiles(self, - request: Union[datastream.ListConnectionProfilesRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListConnectionProfilesPager: - r"""Use this method to list connection profiles created - in a project and location. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.ListConnectionProfilesRequest, dict]): - The request object. - parent (str): - Required. The parent that owns the - collection of connection profiles. - - 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.datastream_v1alpha1.services.datastream.pagers.ListConnectionProfilesPager: - 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 datastream.ListConnectionProfilesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.ListConnectionProfilesRequest): - request = datastream.ListConnectionProfilesRequest(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_connection_profiles] - - # 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.ListConnectionProfilesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_connection_profile(self, - request: Union[datastream.GetConnectionProfileRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> datastream_resources.ConnectionProfile: - r"""Use this method to get details about a connection - profile. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.GetConnectionProfileRequest, dict]): - The request object. - name (str): - Required. The name of the connection - profile 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.datastream_v1alpha1.types.ConnectionProfile: - - """ - # Create or coerce a protobuf request object. - # Sanity 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 datastream.GetConnectionProfileRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.GetConnectionProfileRequest): - request = datastream.GetConnectionProfileRequest(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_connection_profile] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_connection_profile(self, - request: Union[datastream.CreateConnectionProfileRequest, dict] = None, - *, - parent: str = None, - connection_profile: datastream_resources.ConnectionProfile = None, - connection_profile_id: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Use this method to create a connection profile in a - project and location. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.CreateConnectionProfileRequest, dict]): - The request object. - parent (str): - Required. The parent that owns the - collection of ConnectionProfiles. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile): - Required. The connection profile - resource to create. - - This corresponds to the ``connection_profile`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - connection_profile_id (str): - Required. The connection profile - identifier. - - This corresponds to the ``connection_profile_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile` - - """ - # Create or coerce a protobuf request object. - # Sanity 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, connection_profile, connection_profile_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 datastream.CreateConnectionProfileRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.CreateConnectionProfileRequest): - request = datastream.CreateConnectionProfileRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if connection_profile is not None: - request.connection_profile = connection_profile - if connection_profile_id is not None: - request.connection_profile_id = connection_profile_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_connection_profile] - - # 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, - datastream_resources.ConnectionProfile, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_connection_profile(self, - request: Union[datastream.UpdateConnectionProfileRequest, dict] = None, - *, - connection_profile: datastream_resources.ConnectionProfile = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Use this method to update the parameters of a - connection profile. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.UpdateConnectionProfileRequest, dict]): - The request object. - connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile): - Required. The ConnectionProfile to - update. - - This corresponds to the ``connection_profile`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Optional. Field mask is used to specify the fields to be - overwritten in the ConnectionProfile resource by the - update. The fields specified in the update_mask are - relative to the resource, not the full request. A field - will be overwritten if it is in the mask. If the user - does not provide a mask then all fields will be - overwritten. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile` - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([connection_profile, 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 datastream.UpdateConnectionProfileRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.UpdateConnectionProfileRequest): - request = datastream.UpdateConnectionProfileRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if connection_profile is not None: - request.connection_profile = connection_profile - 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_connection_profile] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("connection_profile.name", request.connection_profile.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, - datastream_resources.ConnectionProfile, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_connection_profile(self, - request: Union[datastream.DeleteConnectionProfileRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Use this method to delete a connection profile.. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.DeleteConnectionProfileRequest, dict]): - The request object. - name (str): - Required. The name of the connection - profile resource 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 datastream.DeleteConnectionProfileRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.DeleteConnectionProfileRequest): - request = datastream.DeleteConnectionProfileRequest(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_connection_profile] - - # Certain fields should be provided 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=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - def discover_connection_profile(self, - request: Union[datastream.DiscoverConnectionProfileRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> datastream.DiscoverConnectionProfileResponse: - r"""Use this method to discover a connection profile. - The discover API call exposes the data objects and - metadata belonging to the profile. Typically, a request - returns children data objects under a parent data object - that's optionally supplied in the request. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.DiscoverConnectionProfileRequest, dict]): - The request object. Request message for 'discover' - ConnectionProfile request. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.datastream_v1alpha1.types.DiscoverConnectionProfileResponse: - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a datastream.DiscoverConnectionProfileRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.DiscoverConnectionProfileRequest): - request = datastream.DiscoverConnectionProfileRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.discover_connection_profile] - - # 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 list_streams(self, - request: Union[datastream.ListStreamsRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListStreamsPager: - r"""Use this method to list streams in a project and - location. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.ListStreamsRequest, dict]): - The request object. - parent (str): - Required. The parent that owns the - collection of streams. - - 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.datastream_v1alpha1.services.datastream.pagers.ListStreamsPager: - 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 datastream.ListStreamsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.ListStreamsRequest): - request = datastream.ListStreamsRequest(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_streams] - - # 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.ListStreamsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_stream(self, - request: Union[datastream.GetStreamRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> datastream_resources.Stream: - r"""Use this method to get details about a stream. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.GetStreamRequest, dict]): - The request object. - name (str): - Required. The name of the stream - 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.datastream_v1alpha1.types.Stream: - - """ - # Create or coerce a protobuf request object. - # Sanity 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 datastream.GetStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.GetStreamRequest): - request = datastream.GetStreamRequest(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_stream] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_stream(self, - request: Union[datastream.CreateStreamRequest, dict] = None, - *, - parent: str = None, - stream: datastream_resources.Stream = None, - stream_id: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Use this method to create a stream. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.CreateStreamRequest, dict]): - The request object. - parent (str): - Required. The parent that owns the - collection of streams. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - stream (google.cloud.datastream_v1alpha1.types.Stream): - Required. The stream resource to - create. - - This corresponds to the ``stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - stream_id (str): - Required. The stream identifier. - This corresponds to the ``stream_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.datastream_v1alpha1.types.Stream` - - """ - # Create or coerce a protobuf request object. - # Sanity 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, stream, stream_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 datastream.CreateStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.CreateStreamRequest): - request = datastream.CreateStreamRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if stream is not None: - request.stream = stream - if stream_id is not None: - request.stream_id = stream_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_stream] - - # 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, - datastream_resources.Stream, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_stream(self, - request: Union[datastream.UpdateStreamRequest, dict] = None, - *, - stream: datastream_resources.Stream = None, - update_mask: field_mask_pb2.FieldMask = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Use this method to update the configuration of a - stream. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.UpdateStreamRequest, dict]): - The request object. - stream (google.cloud.datastream_v1alpha1.types.Stream): - Required. The stream resource to - update. - - This corresponds to the ``stream`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Optional. Field mask is used to specify the fields to be - overwritten in the stream resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.datastream_v1alpha1.types.Stream` - - """ - # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([stream, 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 datastream.UpdateStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.UpdateStreamRequest): - request = datastream.UpdateStreamRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if stream is not None: - request.stream = stream - 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_stream] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("stream.name", request.stream.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, - datastream_resources.Stream, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_stream(self, - request: Union[datastream.DeleteStreamRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Use this method to delete a stream. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.DeleteStreamRequest, dict]): - The request object. - name (str): - Required. The name of the stream - resource 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 datastream.DeleteStreamRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.DeleteStreamRequest): - request = datastream.DeleteStreamRequest(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_stream] - - # Certain fields should be provided 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=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - def fetch_errors(self, - request: Union[datastream.FetchErrorsRequest, dict] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Use this method to fetch any errors associated with a - stream. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.FetchErrorsRequest, dict]): - The request object. Request message for 'FetchErrors' - request. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout 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.datastream_v1alpha1.types.FetchErrorsResponse` - Response message for a 'FetchErrors' response. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a datastream.FetchErrorsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.FetchErrorsRequest): - request = datastream.FetchErrorsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.fetch_errors] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("stream", request.stream), - )), - ) - - # 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, - datastream.FetchErrorsResponse, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - def fetch_static_ips(self, - request: Union[datastream.FetchStaticIpsRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.FetchStaticIpsPager: - r"""The FetchStaticIps API call exposes the static ips - used by Datastream. Typically, a request returns - children data objects under a parent data object that's - optionally supplied in the request. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.FetchStaticIpsRequest, dict]): - The request object. Request message for 'FetchStaticIps' - request. - name (str): - Required. The name resource of the Response type. Must - be in the format ``projects/*/locations/*``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.datastream_v1alpha1.services.datastream.pagers.FetchStaticIpsPager: - Response message for a - 'FetchStaticIps' response. - 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([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 datastream.FetchStaticIpsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.FetchStaticIpsRequest): - request = datastream.FetchStaticIpsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.fetch_static_ips] - - # Certain fields should be provided 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, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.FetchStaticIpsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_private_connection(self, - request: Union[datastream.CreatePrivateConnectionRequest, dict] = None, - *, - parent: str = None, - private_connection: datastream_resources.PrivateConnection = None, - private_connection_id: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Use this method to create a private connectivity - configuration. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.CreatePrivateConnectionRequest, dict]): - The request object. - parent (str): - Required. The parent that owns the - collection of PrivateConnections. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - private_connection (google.cloud.datastream_v1alpha1.types.PrivateConnection): - Required. The Private Connectivity - resource to create. - - This corresponds to the ``private_connection`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - private_connection_id (str): - Required. The private connectivity - identifier. - - This corresponds to the ``private_connection_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.datastream_v1alpha1.types.PrivateConnection` The PrivateConnection resource is used to establish private connectivity - between Datastream and a customer's network. - - """ - # Create or coerce a protobuf request object. - # Sanity 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, private_connection, private_connection_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 datastream.CreatePrivateConnectionRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.CreatePrivateConnectionRequest): - request = datastream.CreatePrivateConnectionRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if private_connection is not None: - request.private_connection = private_connection - if private_connection_id is not None: - request.private_connection_id = private_connection_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_private_connection] - - # 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, - datastream_resources.PrivateConnection, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - def get_private_connection(self, - request: Union[datastream.GetPrivateConnectionRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> datastream_resources.PrivateConnection: - r"""Use this method to get details about a private - connectivity configuration. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.GetPrivateConnectionRequest, dict]): - The request object. - name (str): - Required. The name of the private - connectivity configuration 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.datastream_v1alpha1.types.PrivateConnection: - The PrivateConnection resource is - used to establish private connectivity - between Datastream and a customer's - network. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 datastream.GetPrivateConnectionRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.GetPrivateConnectionRequest): - request = datastream.GetPrivateConnectionRequest(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_private_connection] - - # Certain fields should be provided 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_private_connections(self, - request: Union[datastream.ListPrivateConnectionsRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListPrivateConnectionsPager: - r"""Use this method to list private connectivity - configurations in a project and location. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsRequest, dict]): - The request object. - parent (str): - Required. The parent that owns the - collection of private connectivity - configurations. - - 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.datastream_v1alpha1.services.datastream.pagers.ListPrivateConnectionsPager: - 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 datastream.ListPrivateConnectionsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.ListPrivateConnectionsRequest): - request = datastream.ListPrivateConnectionsRequest(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_private_connections] - - # 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.ListPrivateConnectionsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_private_connection(self, - request: Union[datastream.DeletePrivateConnectionRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Use this method to delete a private connectivity - configuration. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.DeletePrivateConnectionRequest, dict]): - The request object. - name (str): - Required. The name of the private - connectivity configuration 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 datastream.DeletePrivateConnectionRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.DeletePrivateConnectionRequest): - request = datastream.DeletePrivateConnectionRequest(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_private_connection] - - # Certain fields should be provided 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=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - def create_route(self, - request: Union[datastream.CreateRouteRequest, dict] = None, - *, - parent: str = None, - route: datastream_resources.Route = None, - route_id: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Use this method to create a route for a private - connectivity in a project and location. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.CreateRouteRequest, dict]): - The request object. route creation request - parent (str): - Required. The parent that owns the - collection of Routes. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - route (google.cloud.datastream_v1alpha1.types.Route): - Required. The Route resource to - create. - - This corresponds to the ``route`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - route_id (str): - Required. The Route identifier. - This corresponds to the ``route_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.datastream_v1alpha1.types.Route` The Route resource is the child of the PrivateConnection resource. - It used to define a route for a PrivateConnection - setup. - - """ - # Create or coerce a protobuf request object. - # Sanity 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, route, route_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 datastream.CreateRouteRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.CreateRouteRequest): - request = datastream.CreateRouteRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if route is not None: - request.route = route - if route_id is not None: - request.route_id = route_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_route] - - # 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, - datastream_resources.Route, - metadata_type=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - def get_route(self, - request: Union[datastream.GetRouteRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> datastream_resources.Route: - r"""Use this method to get details about a route. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.GetRouteRequest, dict]): - The request object. route get request - name (str): - Required. The name of the Route - 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.datastream_v1alpha1.types.Route: - The Route resource is the child of - the PrivateConnection resource. It used - to define a route for a - PrivateConnection setup. - - """ - # Create or coerce a protobuf request object. - # Sanity 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 datastream.GetRouteRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.GetRouteRequest): - request = datastream.GetRouteRequest(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_route] - - # Certain fields should be provided 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_routes(self, - request: Union[datastream.ListRoutesRequest, dict] = None, - *, - parent: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListRoutesPager: - r"""Use this method to list routes created for a private - connectivity in a project and location. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.ListRoutesRequest, dict]): - The request object. route list request - parent (str): - Required. The parent that owns the - collection of Routess. - - 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.datastream_v1alpha1.services.datastream.pagers.ListRoutesPager: - route list response - 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 datastream.ListRoutesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.ListRoutesRequest): - request = datastream.ListRoutesRequest(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_routes] - - # 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.ListRoutesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_route(self, - request: Union[datastream.DeleteRouteRequest, dict] = None, - *, - name: str = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Use this method to delete a route. - - Args: - request (Union[google.cloud.datastream_v1alpha1.types.DeleteRouteRequest, dict]): - The request object. route deletion request - name (str): - Required. The name of the Route - resource 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 datastream.DeleteRouteRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, datastream.DeleteRouteRequest): - request = datastream.DeleteRouteRequest(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_route] - - # Certain fields should be provided 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=datastream.OperationMetadata, - ) - - # Done; return the response. - return response - - def __enter__(self): - return self - - def __exit__(self, type, value, traceback): - """Releases underlying transport's resources. - - .. warning:: - ONLY use as a context manager if the transport is NOT shared - with other clients! Exiting the with block will CLOSE the transport - and may cause errors in other clients! - """ - self.transport.close() - - - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-datastream", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -__all__ = ( - "DatastreamClient", -) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/pagers.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/pagers.py deleted file mode 100644 index f6aa368..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/pagers.py +++ /dev/null @@ -1,629 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator - -from google.cloud.datastream_v1alpha1.types import datastream -from google.cloud.datastream_v1alpha1.types import datastream_resources - - -class ListConnectionProfilesPager: - """A pager for iterating through ``list_connection_profiles`` requests. - - This class thinly wraps an initial - :class:`google.cloud.datastream_v1alpha1.types.ListConnectionProfilesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``connection_profiles`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListConnectionProfiles`` requests and continue to iterate - through the ``connection_profiles`` field on the - corresponding responses. - - All the usual :class:`google.cloud.datastream_v1alpha1.types.ListConnectionProfilesResponse` - 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[..., datastream.ListConnectionProfilesResponse], - request: datastream.ListConnectionProfilesRequest, - response: datastream.ListConnectionProfilesResponse, - *, - 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.datastream_v1alpha1.types.ListConnectionProfilesRequest): - The initial request object. - response (google.cloud.datastream_v1alpha1.types.ListConnectionProfilesResponse): - 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 = datastream.ListConnectionProfilesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[datastream.ListConnectionProfilesResponse]: - 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[datastream_resources.ConnectionProfile]: - for page in self.pages: - yield from page.connection_profiles - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListConnectionProfilesAsyncPager: - """A pager for iterating through ``list_connection_profiles`` requests. - - This class thinly wraps an initial - :class:`google.cloud.datastream_v1alpha1.types.ListConnectionProfilesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``connection_profiles`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListConnectionProfiles`` requests and continue to iterate - through the ``connection_profiles`` field on the - corresponding responses. - - All the usual :class:`google.cloud.datastream_v1alpha1.types.ListConnectionProfilesResponse` - 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[datastream.ListConnectionProfilesResponse]], - request: datastream.ListConnectionProfilesRequest, - response: datastream.ListConnectionProfilesResponse, - *, - 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.datastream_v1alpha1.types.ListConnectionProfilesRequest): - The initial request object. - response (google.cloud.datastream_v1alpha1.types.ListConnectionProfilesResponse): - 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 = datastream.ListConnectionProfilesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[datastream.ListConnectionProfilesResponse]: - 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[datastream_resources.ConnectionProfile]: - async def async_generator(): - async for page in self.pages: - for response in page.connection_profiles: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListStreamsPager: - """A pager for iterating through ``list_streams`` requests. - - This class thinly wraps an initial - :class:`google.cloud.datastream_v1alpha1.types.ListStreamsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``streams`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListStreams`` requests and continue to iterate - through the ``streams`` field on the - corresponding responses. - - All the usual :class:`google.cloud.datastream_v1alpha1.types.ListStreamsResponse` - 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[..., datastream.ListStreamsResponse], - request: datastream.ListStreamsRequest, - response: datastream.ListStreamsResponse, - *, - 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.datastream_v1alpha1.types.ListStreamsRequest): - The initial request object. - response (google.cloud.datastream_v1alpha1.types.ListStreamsResponse): - 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 = datastream.ListStreamsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[datastream.ListStreamsResponse]: - 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[datastream_resources.Stream]: - for page in self.pages: - yield from page.streams - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListStreamsAsyncPager: - """A pager for iterating through ``list_streams`` requests. - - This class thinly wraps an initial - :class:`google.cloud.datastream_v1alpha1.types.ListStreamsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``streams`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListStreams`` requests and continue to iterate - through the ``streams`` field on the - corresponding responses. - - All the usual :class:`google.cloud.datastream_v1alpha1.types.ListStreamsResponse` - 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[datastream.ListStreamsResponse]], - request: datastream.ListStreamsRequest, - response: datastream.ListStreamsResponse, - *, - 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.datastream_v1alpha1.types.ListStreamsRequest): - The initial request object. - response (google.cloud.datastream_v1alpha1.types.ListStreamsResponse): - 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 = datastream.ListStreamsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[datastream.ListStreamsResponse]: - 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[datastream_resources.Stream]: - async def async_generator(): - async for page in self.pages: - for response in page.streams: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class FetchStaticIpsPager: - """A pager for iterating through ``fetch_static_ips`` requests. - - This class thinly wraps an initial - :class:`google.cloud.datastream_v1alpha1.types.FetchStaticIpsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``static_ips`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``FetchStaticIps`` requests and continue to iterate - through the ``static_ips`` field on the - corresponding responses. - - All the usual :class:`google.cloud.datastream_v1alpha1.types.FetchStaticIpsResponse` - 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[..., datastream.FetchStaticIpsResponse], - request: datastream.FetchStaticIpsRequest, - response: datastream.FetchStaticIpsResponse, - *, - 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.datastream_v1alpha1.types.FetchStaticIpsRequest): - The initial request object. - response (google.cloud.datastream_v1alpha1.types.FetchStaticIpsResponse): - 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 = datastream.FetchStaticIpsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[datastream.FetchStaticIpsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[str]: - for page in self.pages: - yield from page.static_ips - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class FetchStaticIpsAsyncPager: - """A pager for iterating through ``fetch_static_ips`` requests. - - This class thinly wraps an initial - :class:`google.cloud.datastream_v1alpha1.types.FetchStaticIpsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``static_ips`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``FetchStaticIps`` requests and continue to iterate - through the ``static_ips`` field on the - corresponding responses. - - All the usual :class:`google.cloud.datastream_v1alpha1.types.FetchStaticIpsResponse` - 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[datastream.FetchStaticIpsResponse]], - request: datastream.FetchStaticIpsRequest, - response: datastream.FetchStaticIpsResponse, - *, - 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.datastream_v1alpha1.types.FetchStaticIpsRequest): - The initial request object. - response (google.cloud.datastream_v1alpha1.types.FetchStaticIpsResponse): - 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 = datastream.FetchStaticIpsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[datastream.FetchStaticIpsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterator[str]: - async def async_generator(): - async for page in self.pages: - for response in page.static_ips: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPrivateConnectionsPager: - """A pager for iterating through ``list_private_connections`` requests. - - This class thinly wraps an initial - :class:`google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``private_connections`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListPrivateConnections`` requests and continue to iterate - through the ``private_connections`` field on the - corresponding responses. - - All the usual :class:`google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsResponse` - 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[..., datastream.ListPrivateConnectionsResponse], - request: datastream.ListPrivateConnectionsRequest, - response: datastream.ListPrivateConnectionsResponse, - *, - 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.datastream_v1alpha1.types.ListPrivateConnectionsRequest): - The initial request object. - response (google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsResponse): - 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 = datastream.ListPrivateConnectionsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[datastream.ListPrivateConnectionsResponse]: - 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[datastream_resources.PrivateConnection]: - for page in self.pages: - yield from page.private_connections - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPrivateConnectionsAsyncPager: - """A pager for iterating through ``list_private_connections`` requests. - - This class thinly wraps an initial - :class:`google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``private_connections`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListPrivateConnections`` requests and continue to iterate - through the ``private_connections`` field on the - corresponding responses. - - All the usual :class:`google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsResponse` - 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[datastream.ListPrivateConnectionsResponse]], - request: datastream.ListPrivateConnectionsRequest, - response: datastream.ListPrivateConnectionsResponse, - *, - 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.datastream_v1alpha1.types.ListPrivateConnectionsRequest): - The initial request object. - response (google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsResponse): - 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 = datastream.ListPrivateConnectionsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[datastream.ListPrivateConnectionsResponse]: - 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[datastream_resources.PrivateConnection]: - async def async_generator(): - async for page in self.pages: - for response in page.private_connections: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListRoutesPager: - """A pager for iterating through ``list_routes`` requests. - - This class thinly wraps an initial - :class:`google.cloud.datastream_v1alpha1.types.ListRoutesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``routes`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListRoutes`` requests and continue to iterate - through the ``routes`` field on the - corresponding responses. - - All the usual :class:`google.cloud.datastream_v1alpha1.types.ListRoutesResponse` - 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[..., datastream.ListRoutesResponse], - request: datastream.ListRoutesRequest, - response: datastream.ListRoutesResponse, - *, - 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.datastream_v1alpha1.types.ListRoutesRequest): - The initial request object. - response (google.cloud.datastream_v1alpha1.types.ListRoutesResponse): - 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 = datastream.ListRoutesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[datastream.ListRoutesResponse]: - 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[datastream_resources.Route]: - for page in self.pages: - yield from page.routes - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListRoutesAsyncPager: - """A pager for iterating through ``list_routes`` requests. - - This class thinly wraps an initial - :class:`google.cloud.datastream_v1alpha1.types.ListRoutesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``routes`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListRoutes`` requests and continue to iterate - through the ``routes`` field on the - corresponding responses. - - All the usual :class:`google.cloud.datastream_v1alpha1.types.ListRoutesResponse` - 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[datastream.ListRoutesResponse]], - request: datastream.ListRoutesRequest, - response: datastream.ListRoutesResponse, - *, - 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.datastream_v1alpha1.types.ListRoutesRequest): - The initial request object. - response (google.cloud.datastream_v1alpha1.types.ListRoutesResponse): - 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 = datastream.ListRoutesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[datastream.ListRoutesResponse]: - 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[datastream_resources.Route]: - async def async_generator(): - async for page in self.pages: - for response in page.routes: - 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/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/__init__.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/__init__.py deleted file mode 100644 index 6563729..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from collections import OrderedDict -from typing import Dict, Type - -from .base import DatastreamTransport -from .grpc import DatastreamGrpcTransport -from .grpc_asyncio import DatastreamGrpcAsyncIOTransport - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[DatastreamTransport]] -_transport_registry['grpc'] = DatastreamGrpcTransport -_transport_registry['grpc_asyncio'] = DatastreamGrpcAsyncIOTransport - -__all__ = ( - 'DatastreamTransport', - 'DatastreamGrpcTransport', - 'DatastreamGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py deleted file mode 100644 index 336435f..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py +++ /dev/null @@ -1,434 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources - -import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.datastream_v1alpha1.types import datastream -from google.cloud.datastream_v1alpha1.types import datastream_resources -from google.longrunning import operations_pb2 # type: ignore - -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-cloud-datastream', - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() - - -class DatastreamTransport(abc.ABC): - """Abstract transport class for Datastream.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) - - DEFAULT_HOST: str = 'datastream.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.list_connection_profiles: gapic_v1.method.wrap_method( - self.list_connection_profiles, - default_timeout=None, - client_info=client_info, - ), - self.get_connection_profile: gapic_v1.method.wrap_method( - self.get_connection_profile, - default_timeout=None, - client_info=client_info, - ), - self.create_connection_profile: gapic_v1.method.wrap_method( - self.create_connection_profile, - default_timeout=60.0, - client_info=client_info, - ), - self.update_connection_profile: gapic_v1.method.wrap_method( - self.update_connection_profile, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_connection_profile: gapic_v1.method.wrap_method( - self.delete_connection_profile, - default_timeout=60.0, - client_info=client_info, - ), - self.discover_connection_profile: gapic_v1.method.wrap_method( - self.discover_connection_profile, - default_timeout=None, - client_info=client_info, - ), - self.list_streams: gapic_v1.method.wrap_method( - self.list_streams, - default_timeout=None, - client_info=client_info, - ), - self.get_stream: gapic_v1.method.wrap_method( - self.get_stream, - default_timeout=None, - client_info=client_info, - ), - self.create_stream: gapic_v1.method.wrap_method( - self.create_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.update_stream: gapic_v1.method.wrap_method( - self.update_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_stream: gapic_v1.method.wrap_method( - self.delete_stream, - default_timeout=60.0, - client_info=client_info, - ), - self.fetch_errors: gapic_v1.method.wrap_method( - self.fetch_errors, - default_timeout=None, - client_info=client_info, - ), - self.fetch_static_ips: gapic_v1.method.wrap_method( - self.fetch_static_ips, - default_timeout=None, - client_info=client_info, - ), - self.create_private_connection: gapic_v1.method.wrap_method( - self.create_private_connection, - default_timeout=60.0, - client_info=client_info, - ), - self.get_private_connection: gapic_v1.method.wrap_method( - self.get_private_connection, - default_timeout=None, - client_info=client_info, - ), - self.list_private_connections: gapic_v1.method.wrap_method( - self.list_private_connections, - default_timeout=None, - client_info=client_info, - ), - self.delete_private_connection: gapic_v1.method.wrap_method( - self.delete_private_connection, - default_timeout=60.0, - client_info=client_info, - ), - self.create_route: gapic_v1.method.wrap_method( - self.create_route, - default_timeout=60.0, - client_info=client_info, - ), - self.get_route: gapic_v1.method.wrap_method( - self.get_route, - default_timeout=None, - client_info=client_info, - ), - self.list_routes: gapic_v1.method.wrap_method( - self.list_routes, - default_timeout=None, - client_info=client_info, - ), - self.delete_route: gapic_v1.method.wrap_method( - self.delete_route, - default_timeout=60.0, - client_info=client_info, - ), - } - - def close(self): - """Closes resources associated with the transport. - - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! - """ - raise NotImplementedError() - - @property - def operations_client(self): - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def list_connection_profiles(self) -> Callable[ - [datastream.ListConnectionProfilesRequest], - Union[ - datastream.ListConnectionProfilesResponse, - Awaitable[datastream.ListConnectionProfilesResponse] - ]]: - raise NotImplementedError() - - @property - def get_connection_profile(self) -> Callable[ - [datastream.GetConnectionProfileRequest], - Union[ - datastream_resources.ConnectionProfile, - Awaitable[datastream_resources.ConnectionProfile] - ]]: - raise NotImplementedError() - - @property - def create_connection_profile(self) -> Callable[ - [datastream.CreateConnectionProfileRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_connection_profile(self) -> Callable[ - [datastream.UpdateConnectionProfileRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_connection_profile(self) -> Callable[ - [datastream.DeleteConnectionProfileRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def discover_connection_profile(self) -> Callable[ - [datastream.DiscoverConnectionProfileRequest], - Union[ - datastream.DiscoverConnectionProfileResponse, - Awaitable[datastream.DiscoverConnectionProfileResponse] - ]]: - raise NotImplementedError() - - @property - def list_streams(self) -> Callable[ - [datastream.ListStreamsRequest], - Union[ - datastream.ListStreamsResponse, - Awaitable[datastream.ListStreamsResponse] - ]]: - raise NotImplementedError() - - @property - def get_stream(self) -> Callable[ - [datastream.GetStreamRequest], - Union[ - datastream_resources.Stream, - Awaitable[datastream_resources.Stream] - ]]: - raise NotImplementedError() - - @property - def create_stream(self) -> Callable[ - [datastream.CreateStreamRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_stream(self) -> Callable[ - [datastream.UpdateStreamRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_stream(self) -> Callable[ - [datastream.DeleteStreamRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def fetch_errors(self) -> Callable[ - [datastream.FetchErrorsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def fetch_static_ips(self) -> Callable[ - [datastream.FetchStaticIpsRequest], - Union[ - datastream.FetchStaticIpsResponse, - Awaitable[datastream.FetchStaticIpsResponse] - ]]: - raise NotImplementedError() - - @property - def create_private_connection(self) -> Callable[ - [datastream.CreatePrivateConnectionRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_private_connection(self) -> Callable[ - [datastream.GetPrivateConnectionRequest], - Union[ - datastream_resources.PrivateConnection, - Awaitable[datastream_resources.PrivateConnection] - ]]: - raise NotImplementedError() - - @property - def list_private_connections(self) -> Callable[ - [datastream.ListPrivateConnectionsRequest], - Union[ - datastream.ListPrivateConnectionsResponse, - Awaitable[datastream.ListPrivateConnectionsResponse] - ]]: - raise NotImplementedError() - - @property - def delete_private_connection(self) -> Callable[ - [datastream.DeletePrivateConnectionRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def create_route(self) -> Callable[ - [datastream.CreateRouteRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_route(self) -> Callable[ - [datastream.GetRouteRequest], - Union[ - datastream_resources.Route, - Awaitable[datastream_resources.Route] - ]]: - raise NotImplementedError() - - @property - def list_routes(self) -> Callable[ - [datastream.ListRoutesRequest], - Union[ - datastream.ListRoutesResponse, - Awaitable[datastream.ListRoutesResponse] - ]]: - raise NotImplementedError() - - @property - def delete_route(self) -> Callable[ - [datastream.DeleteRouteRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - -__all__ = ( - 'DatastreamTransport', -) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py deleted file mode 100644 index c23ca1f..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py +++ /dev/null @@ -1,814 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.datastream_v1alpha1.types import datastream -from google.cloud.datastream_v1alpha1.types import datastream_resources -from google.longrunning import operations_pb2 # type: ignore -from .base import DatastreamTransport, DEFAULT_CLIENT_INFO - - -class DatastreamGrpcTransport(DatastreamTransport): - """gRPC backend transport for Datastream. - - Datastream service - - 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 = 'datastream.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 = 'datastream.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Sanity check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def list_connection_profiles(self) -> Callable[ - [datastream.ListConnectionProfilesRequest], - datastream.ListConnectionProfilesResponse]: - r"""Return a callable for the list connection profiles method over gRPC. - - Use this method to list connection profiles created - in a project and location. - - Returns: - Callable[[~.ListConnectionProfilesRequest], - ~.ListConnectionProfilesResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_connection_profiles' not in self._stubs: - self._stubs['list_connection_profiles'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/ListConnectionProfiles', - request_serializer=datastream.ListConnectionProfilesRequest.serialize, - response_deserializer=datastream.ListConnectionProfilesResponse.deserialize, - ) - return self._stubs['list_connection_profiles'] - - @property - def get_connection_profile(self) -> Callable[ - [datastream.GetConnectionProfileRequest], - datastream_resources.ConnectionProfile]: - r"""Return a callable for the get connection profile method over gRPC. - - Use this method to get details about a connection - profile. - - Returns: - Callable[[~.GetConnectionProfileRequest], - ~.ConnectionProfile]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_connection_profile' not in self._stubs: - self._stubs['get_connection_profile'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/GetConnectionProfile', - request_serializer=datastream.GetConnectionProfileRequest.serialize, - response_deserializer=datastream_resources.ConnectionProfile.deserialize, - ) - return self._stubs['get_connection_profile'] - - @property - def create_connection_profile(self) -> Callable[ - [datastream.CreateConnectionProfileRequest], - operations_pb2.Operation]: - r"""Return a callable for the create connection profile method over gRPC. - - Use this method to create a connection profile in a - project and location. - - Returns: - Callable[[~.CreateConnectionProfileRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_connection_profile' not in self._stubs: - self._stubs['create_connection_profile'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/CreateConnectionProfile', - request_serializer=datastream.CreateConnectionProfileRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_connection_profile'] - - @property - def update_connection_profile(self) -> Callable[ - [datastream.UpdateConnectionProfileRequest], - operations_pb2.Operation]: - r"""Return a callable for the update connection profile method over gRPC. - - Use this method to update the parameters of a - connection profile. - - Returns: - Callable[[~.UpdateConnectionProfileRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_connection_profile' not in self._stubs: - self._stubs['update_connection_profile'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/UpdateConnectionProfile', - request_serializer=datastream.UpdateConnectionProfileRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_connection_profile'] - - @property - def delete_connection_profile(self) -> Callable[ - [datastream.DeleteConnectionProfileRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete connection profile method over gRPC. - - Use this method to delete a connection profile.. - - Returns: - Callable[[~.DeleteConnectionProfileRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_connection_profile' not in self._stubs: - self._stubs['delete_connection_profile'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/DeleteConnectionProfile', - request_serializer=datastream.DeleteConnectionProfileRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_connection_profile'] - - @property - def discover_connection_profile(self) -> Callable[ - [datastream.DiscoverConnectionProfileRequest], - datastream.DiscoverConnectionProfileResponse]: - r"""Return a callable for the discover connection profile method over gRPC. - - Use this method to discover a connection profile. - The discover API call exposes the data objects and - metadata belonging to the profile. Typically, a request - returns children data objects under a parent data object - that's optionally supplied in the request. - - Returns: - Callable[[~.DiscoverConnectionProfileRequest], - ~.DiscoverConnectionProfileResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'discover_connection_profile' not in self._stubs: - self._stubs['discover_connection_profile'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/DiscoverConnectionProfile', - request_serializer=datastream.DiscoverConnectionProfileRequest.serialize, - response_deserializer=datastream.DiscoverConnectionProfileResponse.deserialize, - ) - return self._stubs['discover_connection_profile'] - - @property - def list_streams(self) -> Callable[ - [datastream.ListStreamsRequest], - datastream.ListStreamsResponse]: - r"""Return a callable for the list streams method over gRPC. - - Use this method to list streams in a project and - location. - - Returns: - Callable[[~.ListStreamsRequest], - ~.ListStreamsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_streams' not in self._stubs: - self._stubs['list_streams'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/ListStreams', - request_serializer=datastream.ListStreamsRequest.serialize, - response_deserializer=datastream.ListStreamsResponse.deserialize, - ) - return self._stubs['list_streams'] - - @property - def get_stream(self) -> Callable[ - [datastream.GetStreamRequest], - datastream_resources.Stream]: - r"""Return a callable for the get stream method over gRPC. - - Use this method to get details about a stream. - - Returns: - Callable[[~.GetStreamRequest], - ~.Stream]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_stream' not in self._stubs: - self._stubs['get_stream'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/GetStream', - request_serializer=datastream.GetStreamRequest.serialize, - response_deserializer=datastream_resources.Stream.deserialize, - ) - return self._stubs['get_stream'] - - @property - def create_stream(self) -> Callable[ - [datastream.CreateStreamRequest], - operations_pb2.Operation]: - r"""Return a callable for the create stream method over gRPC. - - Use this method to create a stream. - - Returns: - Callable[[~.CreateStreamRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_stream' not in self._stubs: - self._stubs['create_stream'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/CreateStream', - request_serializer=datastream.CreateStreamRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_stream'] - - @property - def update_stream(self) -> Callable[ - [datastream.UpdateStreamRequest], - operations_pb2.Operation]: - r"""Return a callable for the update stream method over gRPC. - - Use this method to update the configuration of a - stream. - - Returns: - Callable[[~.UpdateStreamRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_stream' not in self._stubs: - self._stubs['update_stream'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/UpdateStream', - request_serializer=datastream.UpdateStreamRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_stream'] - - @property - def delete_stream(self) -> Callable[ - [datastream.DeleteStreamRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete stream method over gRPC. - - Use this method to delete a stream. - - Returns: - Callable[[~.DeleteStreamRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_stream' not in self._stubs: - self._stubs['delete_stream'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/DeleteStream', - request_serializer=datastream.DeleteStreamRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_stream'] - - @property - def fetch_errors(self) -> Callable[ - [datastream.FetchErrorsRequest], - operations_pb2.Operation]: - r"""Return a callable for the fetch errors method over gRPC. - - Use this method to fetch any errors associated with a - stream. - - Returns: - Callable[[~.FetchErrorsRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'fetch_errors' not in self._stubs: - self._stubs['fetch_errors'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/FetchErrors', - request_serializer=datastream.FetchErrorsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['fetch_errors'] - - @property - def fetch_static_ips(self) -> Callable[ - [datastream.FetchStaticIpsRequest], - datastream.FetchStaticIpsResponse]: - r"""Return a callable for the fetch static ips method over gRPC. - - The FetchStaticIps API call exposes the static ips - used by Datastream. Typically, a request returns - children data objects under a parent data object that's - optionally supplied in the request. - - Returns: - Callable[[~.FetchStaticIpsRequest], - ~.FetchStaticIpsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'fetch_static_ips' not in self._stubs: - self._stubs['fetch_static_ips'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/FetchStaticIps', - request_serializer=datastream.FetchStaticIpsRequest.serialize, - response_deserializer=datastream.FetchStaticIpsResponse.deserialize, - ) - return self._stubs['fetch_static_ips'] - - @property - def create_private_connection(self) -> Callable[ - [datastream.CreatePrivateConnectionRequest], - operations_pb2.Operation]: - r"""Return a callable for the create private connection method over gRPC. - - Use this method to create a private connectivity - configuration. - - Returns: - Callable[[~.CreatePrivateConnectionRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_private_connection' not in self._stubs: - self._stubs['create_private_connection'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/CreatePrivateConnection', - request_serializer=datastream.CreatePrivateConnectionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_private_connection'] - - @property - def get_private_connection(self) -> Callable[ - [datastream.GetPrivateConnectionRequest], - datastream_resources.PrivateConnection]: - r"""Return a callable for the get private connection method over gRPC. - - Use this method to get details about a private - connectivity configuration. - - Returns: - Callable[[~.GetPrivateConnectionRequest], - ~.PrivateConnection]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_private_connection' not in self._stubs: - self._stubs['get_private_connection'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/GetPrivateConnection', - request_serializer=datastream.GetPrivateConnectionRequest.serialize, - response_deserializer=datastream_resources.PrivateConnection.deserialize, - ) - return self._stubs['get_private_connection'] - - @property - def list_private_connections(self) -> Callable[ - [datastream.ListPrivateConnectionsRequest], - datastream.ListPrivateConnectionsResponse]: - r"""Return a callable for the list private connections method over gRPC. - - Use this method to list private connectivity - configurations in a project and location. - - Returns: - Callable[[~.ListPrivateConnectionsRequest], - ~.ListPrivateConnectionsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_private_connections' not in self._stubs: - self._stubs['list_private_connections'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/ListPrivateConnections', - request_serializer=datastream.ListPrivateConnectionsRequest.serialize, - response_deserializer=datastream.ListPrivateConnectionsResponse.deserialize, - ) - return self._stubs['list_private_connections'] - - @property - def delete_private_connection(self) -> Callable[ - [datastream.DeletePrivateConnectionRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete private connection method over gRPC. - - Use this method to delete a private connectivity - configuration. - - Returns: - Callable[[~.DeletePrivateConnectionRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_private_connection' not in self._stubs: - self._stubs['delete_private_connection'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/DeletePrivateConnection', - request_serializer=datastream.DeletePrivateConnectionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_private_connection'] - - @property - def create_route(self) -> Callable[ - [datastream.CreateRouteRequest], - operations_pb2.Operation]: - r"""Return a callable for the create route method over gRPC. - - Use this method to create a route for a private - connectivity in a project and location. - - Returns: - Callable[[~.CreateRouteRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_route' not in self._stubs: - self._stubs['create_route'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/CreateRoute', - request_serializer=datastream.CreateRouteRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_route'] - - @property - def get_route(self) -> Callable[ - [datastream.GetRouteRequest], - datastream_resources.Route]: - r"""Return a callable for the get route method over gRPC. - - Use this method to get details about a route. - - Returns: - Callable[[~.GetRouteRequest], - ~.Route]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_route' not in self._stubs: - self._stubs['get_route'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/GetRoute', - request_serializer=datastream.GetRouteRequest.serialize, - response_deserializer=datastream_resources.Route.deserialize, - ) - return self._stubs['get_route'] - - @property - def list_routes(self) -> Callable[ - [datastream.ListRoutesRequest], - datastream.ListRoutesResponse]: - r"""Return a callable for the list routes method over gRPC. - - Use this method to list routes created for a private - connectivity in a project and location. - - Returns: - Callable[[~.ListRoutesRequest], - ~.ListRoutesResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_routes' not in self._stubs: - self._stubs['list_routes'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/ListRoutes', - request_serializer=datastream.ListRoutesRequest.serialize, - response_deserializer=datastream.ListRoutesResponse.deserialize, - ) - return self._stubs['list_routes'] - - @property - def delete_route(self) -> Callable[ - [datastream.DeleteRouteRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete route method over gRPC. - - Use this method to delete a route. - - Returns: - Callable[[~.DeleteRouteRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_route' not in self._stubs: - self._stubs['delete_route'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/DeleteRoute', - request_serializer=datastream.DeleteRouteRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_route'] - - def close(self): - self.grpc_channel.close() - -__all__ = ( - 'DatastreamGrpcTransport', -) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py deleted file mode 100644 index 857f17f..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py +++ /dev/null @@ -1,818 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.datastream_v1alpha1.types import datastream -from google.cloud.datastream_v1alpha1.types import datastream_resources -from google.longrunning import operations_pb2 # type: ignore -from .base import DatastreamTransport, DEFAULT_CLIENT_INFO -from .grpc import DatastreamGrpcTransport - - -class DatastreamGrpcAsyncIOTransport(DatastreamTransport): - """gRPC AsyncIO backend transport for Datastream. - - Datastream service - - 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 = 'datastream.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 = 'datastream.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 list_connection_profiles(self) -> Callable[ - [datastream.ListConnectionProfilesRequest], - Awaitable[datastream.ListConnectionProfilesResponse]]: - r"""Return a callable for the list connection profiles method over gRPC. - - Use this method to list connection profiles created - in a project and location. - - Returns: - Callable[[~.ListConnectionProfilesRequest], - Awaitable[~.ListConnectionProfilesResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_connection_profiles' not in self._stubs: - self._stubs['list_connection_profiles'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/ListConnectionProfiles', - request_serializer=datastream.ListConnectionProfilesRequest.serialize, - response_deserializer=datastream.ListConnectionProfilesResponse.deserialize, - ) - return self._stubs['list_connection_profiles'] - - @property - def get_connection_profile(self) -> Callable[ - [datastream.GetConnectionProfileRequest], - Awaitable[datastream_resources.ConnectionProfile]]: - r"""Return a callable for the get connection profile method over gRPC. - - Use this method to get details about a connection - profile. - - Returns: - Callable[[~.GetConnectionProfileRequest], - Awaitable[~.ConnectionProfile]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_connection_profile' not in self._stubs: - self._stubs['get_connection_profile'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/GetConnectionProfile', - request_serializer=datastream.GetConnectionProfileRequest.serialize, - response_deserializer=datastream_resources.ConnectionProfile.deserialize, - ) - return self._stubs['get_connection_profile'] - - @property - def create_connection_profile(self) -> Callable[ - [datastream.CreateConnectionProfileRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create connection profile method over gRPC. - - Use this method to create a connection profile in a - project and location. - - Returns: - Callable[[~.CreateConnectionProfileRequest], - 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_connection_profile' not in self._stubs: - self._stubs['create_connection_profile'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/CreateConnectionProfile', - request_serializer=datastream.CreateConnectionProfileRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_connection_profile'] - - @property - def update_connection_profile(self) -> Callable[ - [datastream.UpdateConnectionProfileRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update connection profile method over gRPC. - - Use this method to update the parameters of a - connection profile. - - Returns: - Callable[[~.UpdateConnectionProfileRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_connection_profile' not in self._stubs: - self._stubs['update_connection_profile'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/UpdateConnectionProfile', - request_serializer=datastream.UpdateConnectionProfileRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_connection_profile'] - - @property - def delete_connection_profile(self) -> Callable[ - [datastream.DeleteConnectionProfileRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete connection profile method over gRPC. - - Use this method to delete a connection profile.. - - Returns: - Callable[[~.DeleteConnectionProfileRequest], - 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_connection_profile' not in self._stubs: - self._stubs['delete_connection_profile'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/DeleteConnectionProfile', - request_serializer=datastream.DeleteConnectionProfileRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_connection_profile'] - - @property - def discover_connection_profile(self) -> Callable[ - [datastream.DiscoverConnectionProfileRequest], - Awaitable[datastream.DiscoverConnectionProfileResponse]]: - r"""Return a callable for the discover connection profile method over gRPC. - - Use this method to discover a connection profile. - The discover API call exposes the data objects and - metadata belonging to the profile. Typically, a request - returns children data objects under a parent data object - that's optionally supplied in the request. - - Returns: - Callable[[~.DiscoverConnectionProfileRequest], - Awaitable[~.DiscoverConnectionProfileResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'discover_connection_profile' not in self._stubs: - self._stubs['discover_connection_profile'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/DiscoverConnectionProfile', - request_serializer=datastream.DiscoverConnectionProfileRequest.serialize, - response_deserializer=datastream.DiscoverConnectionProfileResponse.deserialize, - ) - return self._stubs['discover_connection_profile'] - - @property - def list_streams(self) -> Callable[ - [datastream.ListStreamsRequest], - Awaitable[datastream.ListStreamsResponse]]: - r"""Return a callable for the list streams method over gRPC. - - Use this method to list streams in a project and - location. - - Returns: - Callable[[~.ListStreamsRequest], - Awaitable[~.ListStreamsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_streams' not in self._stubs: - self._stubs['list_streams'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/ListStreams', - request_serializer=datastream.ListStreamsRequest.serialize, - response_deserializer=datastream.ListStreamsResponse.deserialize, - ) - return self._stubs['list_streams'] - - @property - def get_stream(self) -> Callable[ - [datastream.GetStreamRequest], - Awaitable[datastream_resources.Stream]]: - r"""Return a callable for the get stream method over gRPC. - - Use this method to get details about a stream. - - Returns: - Callable[[~.GetStreamRequest], - Awaitable[~.Stream]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_stream' not in self._stubs: - self._stubs['get_stream'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/GetStream', - request_serializer=datastream.GetStreamRequest.serialize, - response_deserializer=datastream_resources.Stream.deserialize, - ) - return self._stubs['get_stream'] - - @property - def create_stream(self) -> Callable[ - [datastream.CreateStreamRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create stream method over gRPC. - - Use this method to create a stream. - - Returns: - Callable[[~.CreateStreamRequest], - 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_stream' not in self._stubs: - self._stubs['create_stream'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/CreateStream', - request_serializer=datastream.CreateStreamRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_stream'] - - @property - def update_stream(self) -> Callable[ - [datastream.UpdateStreamRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update stream method over gRPC. - - Use this method to update the configuration of a - stream. - - Returns: - Callable[[~.UpdateStreamRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_stream' not in self._stubs: - self._stubs['update_stream'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/UpdateStream', - request_serializer=datastream.UpdateStreamRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_stream'] - - @property - def delete_stream(self) -> Callable[ - [datastream.DeleteStreamRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete stream method over gRPC. - - Use this method to delete a stream. - - Returns: - Callable[[~.DeleteStreamRequest], - 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_stream' not in self._stubs: - self._stubs['delete_stream'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/DeleteStream', - request_serializer=datastream.DeleteStreamRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_stream'] - - @property - def fetch_errors(self) -> Callable[ - [datastream.FetchErrorsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the fetch errors method over gRPC. - - Use this method to fetch any errors associated with a - stream. - - Returns: - Callable[[~.FetchErrorsRequest], - 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 'fetch_errors' not in self._stubs: - self._stubs['fetch_errors'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/FetchErrors', - request_serializer=datastream.FetchErrorsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['fetch_errors'] - - @property - def fetch_static_ips(self) -> Callable[ - [datastream.FetchStaticIpsRequest], - Awaitable[datastream.FetchStaticIpsResponse]]: - r"""Return a callable for the fetch static ips method over gRPC. - - The FetchStaticIps API call exposes the static ips - used by Datastream. Typically, a request returns - children data objects under a parent data object that's - optionally supplied in the request. - - Returns: - Callable[[~.FetchStaticIpsRequest], - Awaitable[~.FetchStaticIpsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'fetch_static_ips' not in self._stubs: - self._stubs['fetch_static_ips'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/FetchStaticIps', - request_serializer=datastream.FetchStaticIpsRequest.serialize, - response_deserializer=datastream.FetchStaticIpsResponse.deserialize, - ) - return self._stubs['fetch_static_ips'] - - @property - def create_private_connection(self) -> Callable[ - [datastream.CreatePrivateConnectionRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create private connection method over gRPC. - - Use this method to create a private connectivity - configuration. - - Returns: - Callable[[~.CreatePrivateConnectionRequest], - 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_private_connection' not in self._stubs: - self._stubs['create_private_connection'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/CreatePrivateConnection', - request_serializer=datastream.CreatePrivateConnectionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_private_connection'] - - @property - def get_private_connection(self) -> Callable[ - [datastream.GetPrivateConnectionRequest], - Awaitable[datastream_resources.PrivateConnection]]: - r"""Return a callable for the get private connection method over gRPC. - - Use this method to get details about a private - connectivity configuration. - - Returns: - Callable[[~.GetPrivateConnectionRequest], - Awaitable[~.PrivateConnection]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_private_connection' not in self._stubs: - self._stubs['get_private_connection'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/GetPrivateConnection', - request_serializer=datastream.GetPrivateConnectionRequest.serialize, - response_deserializer=datastream_resources.PrivateConnection.deserialize, - ) - return self._stubs['get_private_connection'] - - @property - def list_private_connections(self) -> Callable[ - [datastream.ListPrivateConnectionsRequest], - Awaitable[datastream.ListPrivateConnectionsResponse]]: - r"""Return a callable for the list private connections method over gRPC. - - Use this method to list private connectivity - configurations in a project and location. - - Returns: - Callable[[~.ListPrivateConnectionsRequest], - Awaitable[~.ListPrivateConnectionsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_private_connections' not in self._stubs: - self._stubs['list_private_connections'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/ListPrivateConnections', - request_serializer=datastream.ListPrivateConnectionsRequest.serialize, - response_deserializer=datastream.ListPrivateConnectionsResponse.deserialize, - ) - return self._stubs['list_private_connections'] - - @property - def delete_private_connection(self) -> Callable[ - [datastream.DeletePrivateConnectionRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete private connection method over gRPC. - - Use this method to delete a private connectivity - configuration. - - Returns: - Callable[[~.DeletePrivateConnectionRequest], - 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_private_connection' not in self._stubs: - self._stubs['delete_private_connection'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/DeletePrivateConnection', - request_serializer=datastream.DeletePrivateConnectionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_private_connection'] - - @property - def create_route(self) -> Callable[ - [datastream.CreateRouteRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create route method over gRPC. - - Use this method to create a route for a private - connectivity in a project and location. - - Returns: - Callable[[~.CreateRouteRequest], - 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_route' not in self._stubs: - self._stubs['create_route'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/CreateRoute', - request_serializer=datastream.CreateRouteRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_route'] - - @property - def get_route(self) -> Callable[ - [datastream.GetRouteRequest], - Awaitable[datastream_resources.Route]]: - r"""Return a callable for the get route method over gRPC. - - Use this method to get details about a route. - - Returns: - Callable[[~.GetRouteRequest], - Awaitable[~.Route]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_route' not in self._stubs: - self._stubs['get_route'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/GetRoute', - request_serializer=datastream.GetRouteRequest.serialize, - response_deserializer=datastream_resources.Route.deserialize, - ) - return self._stubs['get_route'] - - @property - def list_routes(self) -> Callable[ - [datastream.ListRoutesRequest], - Awaitable[datastream.ListRoutesResponse]]: - r"""Return a callable for the list routes method over gRPC. - - Use this method to list routes created for a private - connectivity in a project and location. - - Returns: - Callable[[~.ListRoutesRequest], - Awaitable[~.ListRoutesResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_routes' not in self._stubs: - self._stubs['list_routes'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/ListRoutes', - request_serializer=datastream.ListRoutesRequest.serialize, - response_deserializer=datastream.ListRoutesResponse.deserialize, - ) - return self._stubs['list_routes'] - - @property - def delete_route(self) -> Callable[ - [datastream.DeleteRouteRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete route method over gRPC. - - Use this method to delete a route. - - Returns: - Callable[[~.DeleteRouteRequest], - 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_route' not in self._stubs: - self._stubs['delete_route'] = self.grpc_channel.unary_unary( - '/google.cloud.datastream.v1alpha1.Datastream/DeleteRoute', - request_serializer=datastream.DeleteRouteRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_route'] - - def close(self): - return self.grpc_channel.close() - - -__all__ = ( - 'DatastreamGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/__init__.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/__init__.py deleted file mode 100644 index 0aaa80a..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/__init__.py +++ /dev/null @@ -1,148 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from .datastream import ( - CreateConnectionProfileRequest, - CreatePrivateConnectionRequest, - CreateRouteRequest, - CreateStreamRequest, - DeleteConnectionProfileRequest, - DeletePrivateConnectionRequest, - DeleteRouteRequest, - DeleteStreamRequest, - DiscoverConnectionProfileRequest, - DiscoverConnectionProfileResponse, - FetchErrorsRequest, - FetchErrorsResponse, - FetchStaticIpsRequest, - FetchStaticIpsResponse, - GetConnectionProfileRequest, - GetPrivateConnectionRequest, - GetRouteRequest, - GetStreamRequest, - ListConnectionProfilesRequest, - ListConnectionProfilesResponse, - ListPrivateConnectionsRequest, - ListPrivateConnectionsResponse, - ListRoutesRequest, - ListRoutesResponse, - ListStreamsRequest, - ListStreamsResponse, - OperationMetadata, - UpdateConnectionProfileRequest, - UpdateStreamRequest, -) -from .datastream_resources import ( - AvroFileFormat, - ConnectionProfile, - DestinationConfig, - Error, - ForwardSshTunnelConnectivity, - GcsDestinationConfig, - GcsProfile, - JsonFileFormat, - MysqlColumn, - MysqlDatabase, - MysqlProfile, - MysqlRdbms, - MysqlSourceConfig, - MysqlSslConfig, - MysqlTable, - NoConnectivitySettings, - OracleColumn, - OracleProfile, - OracleRdbms, - OracleSchema, - OracleSourceConfig, - OracleTable, - PrivateConnection, - PrivateConnectivity, - Route, - SourceConfig, - StaticServiceIpConnectivity, - Stream, - Validation, - ValidationMessage, - ValidationResult, - VpcPeeringConfig, - GcsFileFormat, - SchemaFileFormat, -) - -__all__ = ( - 'CreateConnectionProfileRequest', - 'CreatePrivateConnectionRequest', - 'CreateRouteRequest', - 'CreateStreamRequest', - 'DeleteConnectionProfileRequest', - 'DeletePrivateConnectionRequest', - 'DeleteRouteRequest', - 'DeleteStreamRequest', - 'DiscoverConnectionProfileRequest', - 'DiscoverConnectionProfileResponse', - 'FetchErrorsRequest', - 'FetchErrorsResponse', - 'FetchStaticIpsRequest', - 'FetchStaticIpsResponse', - 'GetConnectionProfileRequest', - 'GetPrivateConnectionRequest', - 'GetRouteRequest', - 'GetStreamRequest', - 'ListConnectionProfilesRequest', - 'ListConnectionProfilesResponse', - 'ListPrivateConnectionsRequest', - 'ListPrivateConnectionsResponse', - 'ListRoutesRequest', - 'ListRoutesResponse', - 'ListStreamsRequest', - 'ListStreamsResponse', - 'OperationMetadata', - 'UpdateConnectionProfileRequest', - 'UpdateStreamRequest', - 'AvroFileFormat', - 'ConnectionProfile', - 'DestinationConfig', - 'Error', - 'ForwardSshTunnelConnectivity', - 'GcsDestinationConfig', - 'GcsProfile', - 'JsonFileFormat', - 'MysqlColumn', - 'MysqlDatabase', - 'MysqlProfile', - 'MysqlRdbms', - 'MysqlSourceConfig', - 'MysqlSslConfig', - 'MysqlTable', - 'NoConnectivitySettings', - 'OracleColumn', - 'OracleProfile', - 'OracleRdbms', - 'OracleSchema', - 'OracleSourceConfig', - 'OracleTable', - 'PrivateConnection', - 'PrivateConnectivity', - 'Route', - 'SourceConfig', - 'StaticServiceIpConnectivity', - 'Stream', - 'Validation', - 'ValidationMessage', - 'ValidationResult', - 'VpcPeeringConfig', - 'GcsFileFormat', - 'SchemaFileFormat', -) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream.py deleted file mode 100644 index 44f8590..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream.py +++ /dev/null @@ -1,1195 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import proto # type: ignore - -from google.cloud.datastream_v1alpha1.types import datastream_resources -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.datastream.v1alpha1', - manifest={ - 'DiscoverConnectionProfileRequest', - 'DiscoverConnectionProfileResponse', - 'FetchStaticIpsRequest', - 'FetchStaticIpsResponse', - 'FetchErrorsRequest', - 'FetchErrorsResponse', - 'ListConnectionProfilesRequest', - 'ListConnectionProfilesResponse', - 'GetConnectionProfileRequest', - 'CreateConnectionProfileRequest', - 'UpdateConnectionProfileRequest', - 'DeleteConnectionProfileRequest', - 'ListStreamsRequest', - 'ListStreamsResponse', - 'GetStreamRequest', - 'CreateStreamRequest', - 'UpdateStreamRequest', - 'DeleteStreamRequest', - 'OperationMetadata', - 'CreatePrivateConnectionRequest', - 'ListPrivateConnectionsRequest', - 'ListPrivateConnectionsResponse', - 'DeletePrivateConnectionRequest', - 'GetPrivateConnectionRequest', - 'CreateRouteRequest', - 'ListRoutesRequest', - 'ListRoutesResponse', - 'DeleteRouteRequest', - 'GetRouteRequest', - }, -) - - -class DiscoverConnectionProfileRequest(proto.Message): - r"""Request message for 'discover' ConnectionProfile request. - - 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: - parent (str): - Required. The parent resource of the ConnectionProfile type. - Must be in the format ``projects/*/locations/*``. - connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile): - An ad-hoc ConnectionProfile configuration. - This field is a member of `oneof`_ ``target``. - connection_profile_name (str): - A reference to an existing ConnectionProfile. - This field is a member of `oneof`_ ``target``. - recursive (bool): - Whether to retrieve the full hierarchy of - data objects (TRUE) or only the current level - (FALSE). - This field is a member of `oneof`_ ``depth``. - recursion_depth (int): - The number of hierarchy levels below the - current level to be retrieved. - This field is a member of `oneof`_ ``depth``. - oracle_rdbms (google.cloud.datastream_v1alpha1.types.OracleRdbms): - Oracle RDBMS to enrich with child data - objects and metadata. - This field is a member of `oneof`_ ``data_object``. - mysql_rdbms (google.cloud.datastream_v1alpha1.types.MysqlRdbms): - MySQL RDBMS to enrich with child data objects - and metadata. - This field is a member of `oneof`_ ``data_object``. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - connection_profile = proto.Field( - proto.MESSAGE, - number=200, - oneof='target', - message=datastream_resources.ConnectionProfile, - ) - connection_profile_name = proto.Field( - proto.STRING, - number=201, - oneof='target', - ) - recursive = proto.Field( - proto.BOOL, - number=3, - oneof='depth', - ) - recursion_depth = proto.Field( - proto.INT32, - number=4, - oneof='depth', - ) - oracle_rdbms = proto.Field( - proto.MESSAGE, - number=100, - oneof='data_object', - message=datastream_resources.OracleRdbms, - ) - mysql_rdbms = proto.Field( - proto.MESSAGE, - number=101, - oneof='data_object', - message=datastream_resources.MysqlRdbms, - ) - - -class DiscoverConnectionProfileResponse(proto.Message): - r""" - - 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: - oracle_rdbms (google.cloud.datastream_v1alpha1.types.OracleRdbms): - Enriched Oracle RDBMS object. - This field is a member of `oneof`_ ``data_object``. - mysql_rdbms (google.cloud.datastream_v1alpha1.types.MysqlRdbms): - Enriched MySQL RDBMS object. - This field is a member of `oneof`_ ``data_object``. - """ - - oracle_rdbms = proto.Field( - proto.MESSAGE, - number=100, - oneof='data_object', - message=datastream_resources.OracleRdbms, - ) - mysql_rdbms = proto.Field( - proto.MESSAGE, - number=101, - oneof='data_object', - message=datastream_resources.MysqlRdbms, - ) - - -class FetchStaticIpsRequest(proto.Message): - r"""Request message for 'FetchStaticIps' request. - - Attributes: - name (str): - Required. The name resource of the Response type. Must be in - the format ``projects/*/locations/*``. - page_size (int): - Maximum number of Ips to return, will likely - not be specified. - page_token (str): - A page token, received from a previous ``ListStaticIps`` - call. will likely not be specified. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - - -class FetchStaticIpsResponse(proto.Message): - r"""Response message for a 'FetchStaticIps' response. - - Attributes: - static_ips (Sequence[str]): - list of static ips by account - next_page_token (str): - A token that can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - static_ips = proto.RepeatedField( - proto.STRING, - number=1, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - - -class FetchErrorsRequest(proto.Message): - r"""Request message for 'FetchErrors' request. - - Attributes: - stream (str): - Name of the Stream resource for which to - fetch any errors. - """ - - stream = proto.Field( - proto.STRING, - number=1, - ) - - -class FetchErrorsResponse(proto.Message): - r"""Response message for a 'FetchErrors' response. - - Attributes: - errors (Sequence[google.cloud.datastream_v1alpha1.types.Error]): - The list of errors on the Stream. - """ - - errors = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=datastream_resources.Error, - ) - - -class ListConnectionProfilesRequest(proto.Message): - r""" - - Attributes: - parent (str): - Required. The parent that owns the collection - of connection profiles. - page_size (int): - Maximum number of connection profiles to - return. If unspecified, at most 50 connection - profiles will be returned. The maximum value is - 1000; values above 1000 will be coerced to 1000. - page_token (str): - Page token received from a previous - ``ListConnectionProfiles`` call. Provide this to retrieve - the subsequent page. - - When paginating, all other parameters provided to - ``ListConnectionProfiles`` must match the call that provided - the page token. - filter (str): - Filter request. - order_by (str): - Order by fields for the result. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListConnectionProfilesResponse(proto.Message): - r""" - - Attributes: - connection_profiles (Sequence[google.cloud.datastream_v1alpha1.types.ConnectionProfile]): - List of connection profiles. - 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. - unreachable (Sequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - connection_profiles = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=datastream_resources.ConnectionProfile, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetConnectionProfileRequest(proto.Message): - r""" - - Attributes: - name (str): - Required. The name of the connection profile - resource to get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateConnectionProfileRequest(proto.Message): - r""" - - Attributes: - parent (str): - Required. The parent that owns the collection - of ConnectionProfiles. - connection_profile_id (str): - Required. The connection profile identifier. - connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile): - Required. The connection profile resource to - create. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes since the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - connection_profile_id = proto.Field( - proto.STRING, - number=2, - ) - connection_profile = proto.Field( - proto.MESSAGE, - number=3, - message=datastream_resources.ConnectionProfile, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - - -class UpdateConnectionProfileRequest(proto.Message): - r""" - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Optional. Field mask is used to specify the fields to be - overwritten in the ConnectionProfile resource by the update. - The fields specified in the update_mask are relative to the - resource, not the full request. A field will be overwritten - if it is in the mask. If the user does not provide a mask - then all fields will be overwritten. - connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile): - Required. The ConnectionProfile to update. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes since the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - update_mask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - connection_profile = proto.Field( - proto.MESSAGE, - number=2, - message=datastream_resources.ConnectionProfile, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - - -class DeleteConnectionProfileRequest(proto.Message): - r""" - - Attributes: - name (str): - Required. The name of the connection profile - resource to delete. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes after the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class ListStreamsRequest(proto.Message): - r""" - - Attributes: - parent (str): - Required. The parent that owns the collection - of streams. - page_size (int): - Maximum number of streams to return. - If unspecified, at most 50 streams will be - returned. The maximum value is 1000; values - above 1000 will be coerced to 1000. - page_token (str): - Page token received from a previous ``ListStreams`` call. - Provide this to retrieve the subsequent page. - - When paginating, all other parameters provided to - ``ListStreams`` must match the call that provided the page - token. - filter (str): - Filter request. - order_by (str): - Order by fields for the result. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListStreamsResponse(proto.Message): - r""" - - Attributes: - streams (Sequence[google.cloud.datastream_v1alpha1.types.Stream]): - List of streams - 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. - unreachable (Sequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - streams = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=datastream_resources.Stream, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetStreamRequest(proto.Message): - r""" - - Attributes: - name (str): - Required. The name of the stream resource to - get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateStreamRequest(proto.Message): - r""" - - Attributes: - parent (str): - Required. The parent that owns the collection - of streams. - stream_id (str): - Required. The stream identifier. - stream (google.cloud.datastream_v1alpha1.types.Stream): - Required. The stream resource to create. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes since the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - validate_only (bool): - Optional. Only validate the stream, but do - not create any resources. The default is false. - force (bool): - Optional. Create the stream without - validating it. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - stream_id = proto.Field( - proto.STRING, - number=2, - ) - stream = proto.Field( - proto.MESSAGE, - number=3, - message=datastream_resources.Stream, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - validate_only = proto.Field( - proto.BOOL, - number=5, - ) - force = proto.Field( - proto.BOOL, - number=6, - ) - - -class UpdateStreamRequest(proto.Message): - r""" - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Optional. Field mask is used to specify the fields to be - overwritten in the stream resource by the update. The fields - specified in the update_mask are relative to the resource, - not the full request. A field will be overwritten if it is - in the mask. If the user does not provide a mask then all - fields will be overwritten. - stream (google.cloud.datastream_v1alpha1.types.Stream): - Required. The stream resource to update. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes since the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - validate_only (bool): - Optional. Only validate the stream with the - changes, without actually updating it. The - default is false. - force (bool): - Optional. Execute the update without - validating it. - """ - - update_mask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - stream = proto.Field( - proto.MESSAGE, - number=2, - message=datastream_resources.Stream, - ) - request_id = proto.Field( - proto.STRING, - number=3, - ) - validate_only = proto.Field( - proto.BOOL, - number=4, - ) - force = proto.Field( - proto.BOOL, - number=5, - ) - - -class DeleteStreamRequest(proto.Message): - r""" - - Attributes: - name (str): - Required. The name of the stream resource to - delete. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes after the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class OperationMetadata(proto.Message): - r"""Represents the metadata of the long-running operation. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - target (str): - Output only. Server-defined resource path for - the target of the operation. - verb (str): - Output only. Name of the verb executed by the - operation. - status_message (str): - Output only. Human-readable status of the - operation, if any. - requested_cancellation (bool): - Output only. Identifies whether the user has requested - cancellation of the operation. Operations that have - successfully been cancelled have [Operation.error][] value - with a [google.rpc.Status.code][google.rpc.Status.code] of - 1, corresponding to ``Code.CANCELLED``. - api_version (str): - Output only. API version used to start the - operation. - validation_result (google.cloud.datastream_v1alpha1.types.ValidationResult): - Output only. Results of executed validations - if there are any. - """ - - create_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - target = proto.Field( - proto.STRING, - number=3, - ) - verb = proto.Field( - proto.STRING, - number=4, - ) - status_message = proto.Field( - proto.STRING, - number=5, - ) - requested_cancellation = proto.Field( - proto.BOOL, - number=6, - ) - api_version = proto.Field( - proto.STRING, - number=7, - ) - validation_result = proto.Field( - proto.MESSAGE, - number=8, - message=datastream_resources.ValidationResult, - ) - - -class CreatePrivateConnectionRequest(proto.Message): - r""" - - Attributes: - parent (str): - Required. The parent that owns the collection - of PrivateConnections. - private_connection_id (str): - Required. The private connectivity - identifier. - private_connection (google.cloud.datastream_v1alpha1.types.PrivateConnection): - Required. The Private Connectivity resource - to create. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes since the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - private_connection_id = proto.Field( - proto.STRING, - number=2, - ) - private_connection = proto.Field( - proto.MESSAGE, - number=3, - message=datastream_resources.PrivateConnection, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - - -class ListPrivateConnectionsRequest(proto.Message): - r""" - - Attributes: - parent (str): - Required. The parent that owns the collection - of private connectivity configurations. - page_size (int): - Maximum number of private connectivity - configurations to return. If unspecified, at - most 50 private connectivity configurations that - will be returned. The maximum value is 1000; - values above 1000 will be coerced to 1000. - page_token (str): - Page token received from a previous - ``ListPrivateConnections`` call. Provide this to retrieve - the subsequent page. - - When paginating, all other parameters provided to - ``ListPrivateConnections`` must match the call that provided - the page token. - filter (str): - Filter request. - order_by (str): - Order by fields for the result. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListPrivateConnectionsResponse(proto.Message): - r""" - - Attributes: - private_connections (Sequence[google.cloud.datastream_v1alpha1.types.PrivateConnection]): - List of private connectivity configurations. - 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. - unreachable (Sequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - private_connections = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=datastream_resources.PrivateConnection, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class DeletePrivateConnectionRequest(proto.Message): - r""" - - Attributes: - name (str): - Required. The name of the private - connectivity configuration to delete. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes after the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - force (bool): - Optional. If set to true, any child routes - that belong to this PrivateConnection will also - be deleted. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - force = proto.Field( - proto.BOOL, - number=3, - ) - - -class GetPrivateConnectionRequest(proto.Message): - r""" - - Attributes: - name (str): - Required. The name of the private - connectivity configuration to get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateRouteRequest(proto.Message): - r"""route creation request - - Attributes: - parent (str): - Required. The parent that owns the collection - of Routes. - route_id (str): - Required. The Route identifier. - route (google.cloud.datastream_v1alpha1.types.Route): - Required. The Route resource to create. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes since the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - route_id = proto.Field( - proto.STRING, - number=2, - ) - route = proto.Field( - proto.MESSAGE, - number=3, - message=datastream_resources.Route, - ) - request_id = proto.Field( - proto.STRING, - number=4, - ) - - -class ListRoutesRequest(proto.Message): - r"""route list request - - Attributes: - parent (str): - Required. The parent that owns the collection - of Routess. - page_size (int): - Maximum number of Routes to return. The - service may return fewer than this value. If - unspecified, at most 50 Routes will be returned. - The maximum value is 1000; values above 1000 - will be coerced to 1000. - page_token (str): - Page token received from a previous ``ListRoutes`` call. - Provide this to retrieve the subsequent page. - - When paginating, all other parameters provided to - ``ListRoutes`` must match the call that provided the page - token. - filter (str): - Filter request. - order_by (str): - Order by fields for the result. - """ - - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) - order_by = proto.Field( - proto.STRING, - number=5, - ) - - -class ListRoutesResponse(proto.Message): - r"""route list response - - Attributes: - routes (Sequence[google.cloud.datastream_v1alpha1.types.Route]): - List of Routes. - 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. - unreachable (Sequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - routes = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=datastream_resources.Route, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) - unreachable = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class DeleteRouteRequest(proto.Message): - r"""route deletion request - - Attributes: - name (str): - Required. The name of the Route resource to - delete. - request_id (str): - Optional. A request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. The server will guarantee that for at - least 60 minutes after the first request. - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - request_id = proto.Field( - proto.STRING, - number=2, - ) - - -class GetRouteRequest(proto.Message): - r"""route get request - - Attributes: - name (str): - Required. The name of the Route resource to - get. - """ - - name = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream_resources.py b/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream_resources.py deleted file mode 100644 index 1dcda3e..0000000 --- a/owl-bot-staging/v1alpha1/google/cloud/datastream_v1alpha1/types/datastream_resources.py +++ /dev/null @@ -1,1311 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import proto # type: ignore - -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.datastream.v1alpha1', - manifest={ - 'GcsFileFormat', - 'SchemaFileFormat', - 'OracleProfile', - 'MysqlProfile', - 'GcsProfile', - 'NoConnectivitySettings', - 'StaticServiceIpConnectivity', - 'ForwardSshTunnelConnectivity', - 'VpcPeeringConfig', - 'PrivateConnection', - 'PrivateConnectivity', - 'Route', - 'MysqlSslConfig', - 'ConnectionProfile', - 'OracleColumn', - 'OracleTable', - 'OracleSchema', - 'OracleRdbms', - 'OracleSourceConfig', - 'MysqlColumn', - 'MysqlTable', - 'MysqlDatabase', - 'MysqlRdbms', - 'MysqlSourceConfig', - 'SourceConfig', - 'AvroFileFormat', - 'JsonFileFormat', - 'GcsDestinationConfig', - 'DestinationConfig', - 'Stream', - 'Error', - 'ValidationResult', - 'Validation', - 'ValidationMessage', - }, -) - - -class GcsFileFormat(proto.Enum): - r"""File format in Cloud Storage.""" - _pb_options = {'deprecated': True} - GCS_FILE_FORMAT_UNSPECIFIED = 0 - AVRO = 1 - - -class SchemaFileFormat(proto.Enum): - r"""Schema file format.""" - SCHEMA_FILE_FORMAT_UNSPECIFIED = 0 - NO_SCHEMA_FILE = 1 - AVRO_SCHEMA_FILE = 2 - - -class OracleProfile(proto.Message): - r"""Oracle database profile. - - Attributes: - hostname (str): - Required. Hostname for the Oracle connection. - port (int): - Port for the Oracle connection, default value - is 1521. - username (str): - Required. Username for the Oracle connection. - password (str): - Required. Password for the Oracle connection. - database_service (str): - Required. Database for the Oracle connection. - connection_attributes (Sequence[google.cloud.datastream_v1alpha1.types.OracleProfile.ConnectionAttributesEntry]): - Connection string attributes - """ - - hostname = proto.Field( - proto.STRING, - number=1, - ) - port = proto.Field( - proto.INT32, - number=2, - ) - username = proto.Field( - proto.STRING, - number=3, - ) - password = proto.Field( - proto.STRING, - number=4, - ) - database_service = proto.Field( - proto.STRING, - number=5, - ) - connection_attributes = proto.MapField( - proto.STRING, - proto.STRING, - number=6, - ) - - -class MysqlProfile(proto.Message): - r"""MySQL database profile. - - Attributes: - hostname (str): - Required. Hostname for the MySQL connection. - port (int): - Port for the MySQL connection, default value - is 3306. - username (str): - Required. Username for the MySQL connection. - password (str): - Required. Input only. Password for the MySQL - connection. - ssl_config (google.cloud.datastream_v1alpha1.types.MysqlSslConfig): - SSL configuration for the MySQL connection. - """ - - hostname = proto.Field( - proto.STRING, - number=1, - ) - port = proto.Field( - proto.INT32, - number=2, - ) - username = proto.Field( - proto.STRING, - number=3, - ) - password = proto.Field( - proto.STRING, - number=4, - ) - ssl_config = proto.Field( - proto.MESSAGE, - number=5, - message='MysqlSslConfig', - ) - - -class GcsProfile(proto.Message): - r"""Cloud Storage bucket profile. - - Attributes: - bucket_name (str): - Required. The full project and resource path - for Cloud Storage bucket including the name. - root_path (str): - The root path inside the Cloud Storage - bucket. - """ - - bucket_name = proto.Field( - proto.STRING, - number=1, - ) - root_path = proto.Field( - proto.STRING, - number=2, - ) - - -class NoConnectivitySettings(proto.Message): - r"""No connectivity settings. - """ - - -class StaticServiceIpConnectivity(proto.Message): - r"""Static IP address connectivity. - """ - - -class ForwardSshTunnelConnectivity(proto.Message): - r"""Forward SSH Tunnel connectivity. - - 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: - hostname (str): - Required. Hostname for the SSH tunnel. - username (str): - Required. Username for the SSH tunnel. - port (int): - Port for the SSH tunnel, default value is 22. - password (str): - Input only. SSH password. - This field is a member of `oneof`_ ``authentication_method``. - private_key (str): - Input only. SSH private key. - This field is a member of `oneof`_ ``authentication_method``. - """ - - hostname = proto.Field( - proto.STRING, - number=1, - ) - username = proto.Field( - proto.STRING, - number=2, - ) - port = proto.Field( - proto.INT32, - number=3, - ) - password = proto.Field( - proto.STRING, - number=100, - oneof='authentication_method', - ) - private_key = proto.Field( - proto.STRING, - number=101, - oneof='authentication_method', - ) - - -class VpcPeeringConfig(proto.Message): - r"""The VPC Peering configuration is used to create VPC peering - between Datastream and the consumer's VPC. - - Attributes: - vpc_name (str): - Required. fully qualified name of the VPC - Datastream will peer to. - subnet (str): - Required. A free subnet for peering. (CIDR of - /29) - """ - - vpc_name = proto.Field( - proto.STRING, - number=1, - ) - subnet = proto.Field( - proto.STRING, - number=2, - ) - - -class PrivateConnection(proto.Message): - r"""The PrivateConnection resource is used to establish private - connectivity between Datastream and a customer's network. - - Attributes: - name (str): - Output only. The resource's name. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The create time of the resource. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The update time of the resource. - labels (Sequence[google.cloud.datastream_v1alpha1.types.PrivateConnection.LabelsEntry]): - Labels. - display_name (str): - Required. Display name. - state (google.cloud.datastream_v1alpha1.types.PrivateConnection.State): - Output only. The state of the Private - Connection. - error (google.cloud.datastream_v1alpha1.types.Error): - Output only. In case of error, the details of - the error in a user-friendly format. - vpc_peering_config (google.cloud.datastream_v1alpha1.types.VpcPeeringConfig): - VPC Peering Config - """ - class State(proto.Enum): - r"""Private Connection state.""" - STATE_UNSPECIFIED = 0 - CREATING = 1 - CREATED = 2 - FAILED = 3 - - 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, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - display_name = proto.Field( - proto.STRING, - number=5, - ) - state = proto.Field( - proto.ENUM, - number=6, - enum=State, - ) - error = proto.Field( - proto.MESSAGE, - number=7, - message='Error', - ) - vpc_peering_config = proto.Field( - proto.MESSAGE, - number=100, - message='VpcPeeringConfig', - ) - - -class PrivateConnectivity(proto.Message): - r"""Private Connectivity - - Attributes: - private_connection_name (str): - - """ - - private_connection_name = proto.Field( - proto.STRING, - number=1, - ) - - -class Route(proto.Message): - r"""The Route resource is the child of the PrivateConnection - resource. It used to define a route for a PrivateConnection - setup. - - Attributes: - name (str): - Output only. The resource's name. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The create time of the resource. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The update time of the resource. - labels (Sequence[google.cloud.datastream_v1alpha1.types.Route.LabelsEntry]): - Labels. - display_name (str): - Required. Display name. - destination_address (str): - Required. Destination address for connection - destination_port (int): - Destination port for connection - """ - - 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, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - display_name = proto.Field( - proto.STRING, - number=5, - ) - destination_address = proto.Field( - proto.STRING, - number=6, - ) - destination_port = proto.Field( - proto.INT32, - number=7, - ) - - -class MysqlSslConfig(proto.Message): - r"""MySQL SSL configuration information. - - Attributes: - client_key (str): - Input only. PEM-encoded private key associated with the - Client Certificate. If this field is used then the - 'client_certificate' and the 'ca_certificate' fields are - mandatory. - client_key_set (bool): - Output only. Indicates whether the client_key field is set. - client_certificate (str): - Input only. PEM-encoded certificate that will be used by the - replica to authenticate against the source database server. - If this field is used then the 'client_key' and the - 'ca_certificate' fields are mandatory. - client_certificate_set (bool): - Output only. Indicates whether the client_certificate field - is set. - ca_certificate (str): - Input only. PEM-encoded certificate of the CA - that signed the source database server's - certificate. - ca_certificate_set (bool): - Output only. Indicates whether the ca_certificate field is - set. - """ - - client_key = proto.Field( - proto.STRING, - number=11, - ) - client_key_set = proto.Field( - proto.BOOL, - number=12, - ) - client_certificate = proto.Field( - proto.STRING, - number=13, - ) - client_certificate_set = proto.Field( - proto.BOOL, - number=14, - ) - ca_certificate = proto.Field( - proto.STRING, - number=15, - ) - ca_certificate_set = proto.Field( - proto.BOOL, - number=16, - ) - - -class ConnectionProfile(proto.Message): - r""" - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - name (str): - Output only. The resource's name. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The create time of the resource. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The update time of the resource. - labels (Sequence[google.cloud.datastream_v1alpha1.types.ConnectionProfile.LabelsEntry]): - Labels. - display_name (str): - Required. Display name. - oracle_profile (google.cloud.datastream_v1alpha1.types.OracleProfile): - Oracle ConnectionProfile configuration. - This field is a member of `oneof`_ ``profile``. - gcs_profile (google.cloud.datastream_v1alpha1.types.GcsProfile): - Cloud Storage ConnectionProfile - configuration. - This field is a member of `oneof`_ ``profile``. - mysql_profile (google.cloud.datastream_v1alpha1.types.MysqlProfile): - MySQL ConnectionProfile configuration. - This field is a member of `oneof`_ ``profile``. - no_connectivity (google.cloud.datastream_v1alpha1.types.NoConnectivitySettings): - No connectivity option chosen. - This field is a member of `oneof`_ ``connectivity``. - static_service_ip_connectivity (google.cloud.datastream_v1alpha1.types.StaticServiceIpConnectivity): - Static Service IP connectivity. - This field is a member of `oneof`_ ``connectivity``. - forward_ssh_connectivity (google.cloud.datastream_v1alpha1.types.ForwardSshTunnelConnectivity): - Forward SSH tunnel connectivity. - This field is a member of `oneof`_ ``connectivity``. - private_connectivity (google.cloud.datastream_v1alpha1.types.PrivateConnectivity): - Private connectivity. - This field is a member of `oneof`_ ``connectivity``. - """ - - 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, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - display_name = proto.Field( - proto.STRING, - number=5, - ) - oracle_profile = proto.Field( - proto.MESSAGE, - number=100, - oneof='profile', - message='OracleProfile', - ) - gcs_profile = proto.Field( - proto.MESSAGE, - number=101, - oneof='profile', - message='GcsProfile', - ) - mysql_profile = proto.Field( - proto.MESSAGE, - number=102, - oneof='profile', - message='MysqlProfile', - ) - no_connectivity = proto.Field( - proto.MESSAGE, - number=200, - oneof='connectivity', - message='NoConnectivitySettings', - ) - static_service_ip_connectivity = proto.Field( - proto.MESSAGE, - number=201, - oneof='connectivity', - message='StaticServiceIpConnectivity', - ) - forward_ssh_connectivity = proto.Field( - proto.MESSAGE, - number=202, - oneof='connectivity', - message='ForwardSshTunnelConnectivity', - ) - private_connectivity = proto.Field( - proto.MESSAGE, - number=203, - oneof='connectivity', - message='PrivateConnectivity', - ) - - -class OracleColumn(proto.Message): - r"""Oracle Column. - - Attributes: - column_name (str): - Column name. - data_type (str): - The Oracle data type. - length (int): - Column length. - precision (int): - Column precision. - scale (int): - Column scale. - encoding (str): - Column encoding. - primary_key (bool): - Whether or not the column represents a - primary key. - nullable (bool): - Whether or not the column can accept a null - value. - ordinal_position (int): - The ordinal position of the column in the - table. - """ - - column_name = proto.Field( - proto.STRING, - number=1, - ) - data_type = proto.Field( - proto.STRING, - number=2, - ) - length = proto.Field( - proto.INT32, - number=3, - ) - precision = proto.Field( - proto.INT32, - number=4, - ) - scale = proto.Field( - proto.INT32, - number=5, - ) - encoding = proto.Field( - proto.STRING, - number=6, - ) - primary_key = proto.Field( - proto.BOOL, - number=7, - ) - nullable = proto.Field( - proto.BOOL, - number=8, - ) - ordinal_position = proto.Field( - proto.INT32, - number=9, - ) - - -class OracleTable(proto.Message): - r"""Oracle table. - - Attributes: - table_name (str): - Table name. - oracle_columns (Sequence[google.cloud.datastream_v1alpha1.types.OracleColumn]): - Oracle columns in the schema. - When unspecified as part of inclue/exclude - lists, includes/excludes everything. - """ - - table_name = proto.Field( - proto.STRING, - number=1, - ) - oracle_columns = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='OracleColumn', - ) - - -class OracleSchema(proto.Message): - r"""Oracle schema. - - Attributes: - schema_name (str): - Schema name. - oracle_tables (Sequence[google.cloud.datastream_v1alpha1.types.OracleTable]): - Tables in the schema. - """ - - schema_name = proto.Field( - proto.STRING, - number=1, - ) - oracle_tables = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='OracleTable', - ) - - -class OracleRdbms(proto.Message): - r"""Oracle database structure. - - Attributes: - oracle_schemas (Sequence[google.cloud.datastream_v1alpha1.types.OracleSchema]): - Oracle schemas/databases in the database - server. - """ - - oracle_schemas = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='OracleSchema', - ) - - -class OracleSourceConfig(proto.Message): - r"""Oracle data source configuration - - Attributes: - allowlist (google.cloud.datastream_v1alpha1.types.OracleRdbms): - Oracle objects to include in the stream. - rejectlist (google.cloud.datastream_v1alpha1.types.OracleRdbms): - Oracle objects to exclude from the stream. - """ - - allowlist = proto.Field( - proto.MESSAGE, - number=1, - message='OracleRdbms', - ) - rejectlist = proto.Field( - proto.MESSAGE, - number=2, - message='OracleRdbms', - ) - - -class MysqlColumn(proto.Message): - r"""MySQL Column. - - Attributes: - column_name (str): - Column name. - data_type (str): - The MySQL data type. Full data types list can - be found here: - https://dev.mysql.com/doc/refman/8.0/en/data- - types.html - length (int): - Column length. - collation (str): - Column collation. - primary_key (bool): - Whether or not the column represents a - primary key. - nullable (bool): - Whether or not the column can accept a null - value. - ordinal_position (int): - The ordinal position of the column in the - table. - """ - - column_name = proto.Field( - proto.STRING, - number=1, - ) - data_type = proto.Field( - proto.STRING, - number=2, - ) - length = proto.Field( - proto.INT32, - number=3, - ) - collation = proto.Field( - proto.STRING, - number=4, - ) - primary_key = proto.Field( - proto.BOOL, - number=5, - ) - nullable = proto.Field( - proto.BOOL, - number=6, - ) - ordinal_position = proto.Field( - proto.INT32, - number=7, - ) - - -class MysqlTable(proto.Message): - r"""MySQL table. - - Attributes: - table_name (str): - Table name. - mysql_columns (Sequence[google.cloud.datastream_v1alpha1.types.MysqlColumn]): - MySQL columns in the database. - When unspecified as part of include/exclude - lists, includes/excludes everything. - """ - - table_name = proto.Field( - proto.STRING, - number=1, - ) - mysql_columns = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='MysqlColumn', - ) - - -class MysqlDatabase(proto.Message): - r"""MySQL database. - - Attributes: - database_name (str): - Database name. - mysql_tables (Sequence[google.cloud.datastream_v1alpha1.types.MysqlTable]): - Tables in the database. - """ - - database_name = proto.Field( - proto.STRING, - number=1, - ) - mysql_tables = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='MysqlTable', - ) - - -class MysqlRdbms(proto.Message): - r"""MySQL database structure - - Attributes: - mysql_databases (Sequence[google.cloud.datastream_v1alpha1.types.MysqlDatabase]): - Mysql databases on the server - """ - - mysql_databases = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='MysqlDatabase', - ) - - -class MysqlSourceConfig(proto.Message): - r"""MySQL source configuration - - Attributes: - allowlist (google.cloud.datastream_v1alpha1.types.MysqlRdbms): - MySQL objects to retrieve from the source. - rejectlist (google.cloud.datastream_v1alpha1.types.MysqlRdbms): - MySQL objects to exclude from the stream. - """ - - allowlist = proto.Field( - proto.MESSAGE, - number=1, - message='MysqlRdbms', - ) - rejectlist = proto.Field( - proto.MESSAGE, - number=2, - message='MysqlRdbms', - ) - - -class SourceConfig(proto.Message): - r"""The configuration of the stream source. - - 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: - source_connection_profile_name (str): - Required. Source connection profile - identifier. - oracle_source_config (google.cloud.datastream_v1alpha1.types.OracleSourceConfig): - Oracle data source configuration - This field is a member of `oneof`_ ``source_stream_config``. - mysql_source_config (google.cloud.datastream_v1alpha1.types.MysqlSourceConfig): - MySQL data source configuration - This field is a member of `oneof`_ ``source_stream_config``. - """ - - source_connection_profile_name = proto.Field( - proto.STRING, - number=1, - ) - oracle_source_config = proto.Field( - proto.MESSAGE, - number=100, - oneof='source_stream_config', - message='OracleSourceConfig', - ) - mysql_source_config = proto.Field( - proto.MESSAGE, - number=101, - oneof='source_stream_config', - message='MysqlSourceConfig', - ) - - -class AvroFileFormat(proto.Message): - r"""AVRO file format configuration. - """ - - -class JsonFileFormat(proto.Message): - r"""JSON file format configuration. - - Attributes: - schema_file_format (google.cloud.datastream_v1alpha1.types.SchemaFileFormat): - The schema file format along JSON data files. - compression (google.cloud.datastream_v1alpha1.types.JsonFileFormat.JsonCompression): - Compression of the loaded JSON file. - """ - class JsonCompression(proto.Enum): - r"""Json file compression.""" - JSON_COMPRESSION_UNSPECIFIED = 0 - NO_COMPRESSION = 1 - GZIP = 2 - - schema_file_format = proto.Field( - proto.ENUM, - number=1, - enum='SchemaFileFormat', - ) - compression = proto.Field( - proto.ENUM, - number=2, - enum=JsonCompression, - ) - - -class GcsDestinationConfig(proto.Message): - r"""Google Cloud Storage destination configuration - - 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: - path (str): - Path inside the Cloud Storage bucket to write - data to. - gcs_file_format (google.cloud.datastream_v1alpha1.types.GcsFileFormat): - File format that data should be written in. Deprecated field - - use file_format instead. - file_rotation_mb (int): - The maximum file size to be saved in the - bucket. - file_rotation_interval (google.protobuf.duration_pb2.Duration): - The maximum duration for which new events are - added before a file is closed and a new file is - created. - avro_file_format (google.cloud.datastream_v1alpha1.types.AvroFileFormat): - AVRO file format configuration. - This field is a member of `oneof`_ ``file_format``. - json_file_format (google.cloud.datastream_v1alpha1.types.JsonFileFormat): - JSON file format configuration. - This field is a member of `oneof`_ ``file_format``. - """ - - path = proto.Field( - proto.STRING, - number=1, - ) - gcs_file_format = proto.Field( - proto.ENUM, - number=2, - enum='GcsFileFormat', - ) - file_rotation_mb = proto.Field( - proto.INT32, - number=3, - ) - file_rotation_interval = proto.Field( - proto.MESSAGE, - number=4, - message=duration_pb2.Duration, - ) - avro_file_format = proto.Field( - proto.MESSAGE, - number=100, - oneof='file_format', - message='AvroFileFormat', - ) - json_file_format = proto.Field( - proto.MESSAGE, - number=101, - oneof='file_format', - message='JsonFileFormat', - ) - - -class DestinationConfig(proto.Message): - r"""The configuration of the stream destination. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - destination_connection_profile_name (str): - Required. Destination connection profile - identifier. - gcs_destination_config (google.cloud.datastream_v1alpha1.types.GcsDestinationConfig): - - This field is a member of `oneof`_ ``destination_stream_config``. - """ - - destination_connection_profile_name = proto.Field( - proto.STRING, - number=1, - ) - gcs_destination_config = proto.Field( - proto.MESSAGE, - number=100, - oneof='destination_stream_config', - message='GcsDestinationConfig', - ) - - -class Stream(proto.Message): - r""" - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - name (str): - Output only. The stream's name. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The creation time of the stream. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The last update time of the - stream. - labels (Sequence[google.cloud.datastream_v1alpha1.types.Stream.LabelsEntry]): - Labels. - display_name (str): - Required. Display name. - source_config (google.cloud.datastream_v1alpha1.types.SourceConfig): - Required. Source connection profile - configuration. - destination_config (google.cloud.datastream_v1alpha1.types.DestinationConfig): - Required. Destination connection profile - configuration. - state (google.cloud.datastream_v1alpha1.types.Stream.State): - The state of the stream. - backfill_all (google.cloud.datastream_v1alpha1.types.Stream.BackfillAllStrategy): - Automatically backfill objects included in - the stream source configuration. Specific - objects can be excluded. - This field is a member of `oneof`_ ``backfill_strategy``. - backfill_none (google.cloud.datastream_v1alpha1.types.Stream.BackfillNoneStrategy): - Do not automatically backfill any objects. - This field is a member of `oneof`_ ``backfill_strategy``. - errors (Sequence[google.cloud.datastream_v1alpha1.types.Error]): - Output only. Errors on the Stream. - """ - class State(proto.Enum): - r"""Stream state.""" - STATE_UNSPECIFIED = 0 - CREATED = 1 - RUNNING = 2 - PAUSED = 3 - MAINTENANCE = 4 - FAILED = 5 - FAILED_PERMANENTLY = 6 - STARTING = 7 - DRAINING = 8 - - class BackfillAllStrategy(proto.Message): - r"""Backfill strategy to automatically backfill the Stream's - objects. Specific objects can be excluded. - - 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: - oracle_excluded_objects (google.cloud.datastream_v1alpha1.types.OracleRdbms): - Oracle data source objects to avoid - backfilling. - This field is a member of `oneof`_ ``excluded_objects``. - mysql_excluded_objects (google.cloud.datastream_v1alpha1.types.MysqlRdbms): - MySQL data source objects to avoid - backfilling. - This field is a member of `oneof`_ ``excluded_objects``. - """ - - oracle_excluded_objects = proto.Field( - proto.MESSAGE, - number=1, - oneof='excluded_objects', - message='OracleRdbms', - ) - mysql_excluded_objects = proto.Field( - proto.MESSAGE, - number=2, - oneof='excluded_objects', - message='MysqlRdbms', - ) - - class BackfillNoneStrategy(proto.Message): - r"""Backfill strategy to disable automatic backfill for the - Stream's objects. - - """ - - 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, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - display_name = proto.Field( - proto.STRING, - number=5, - ) - source_config = proto.Field( - proto.MESSAGE, - number=6, - message='SourceConfig', - ) - destination_config = proto.Field( - proto.MESSAGE, - number=7, - message='DestinationConfig', - ) - state = proto.Field( - proto.ENUM, - number=8, - enum=State, - ) - backfill_all = proto.Field( - proto.MESSAGE, - number=101, - oneof='backfill_strategy', - message=BackfillAllStrategy, - ) - backfill_none = proto.Field( - proto.MESSAGE, - number=102, - oneof='backfill_strategy', - message=BackfillNoneStrategy, - ) - errors = proto.RepeatedField( - proto.MESSAGE, - number=9, - message='Error', - ) - - -class Error(proto.Message): - r"""Represent a user-facing Error. - - Attributes: - reason (str): - A title that explains the reason for the - error. - error_uuid (str): - A unique identifier for this specific error, - allowing it to be traced throughout the system - in logs and API responses. - message (str): - A message containing more information about - the error that occurred. - error_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the error occurred. - details (Sequence[google.cloud.datastream_v1alpha1.types.Error.DetailsEntry]): - Additional information about the error. - """ - - reason = proto.Field( - proto.STRING, - number=1, - ) - error_uuid = proto.Field( - proto.STRING, - number=2, - ) - message = proto.Field( - proto.STRING, - number=3, - ) - error_time = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - details = proto.MapField( - proto.STRING, - proto.STRING, - number=5, - ) - - -class ValidationResult(proto.Message): - r"""Contains the current validation results. - - Attributes: - validations (Sequence[google.cloud.datastream_v1alpha1.types.Validation]): - A list of validations (includes both executed - as well as not executed validations). - """ - - validations = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Validation', - ) - - -class Validation(proto.Message): - r""" - - Attributes: - description (str): - A short description of the validation. - status (google.cloud.datastream_v1alpha1.types.Validation.Status): - Validation execution status. - message (Sequence[google.cloud.datastream_v1alpha1.types.ValidationMessage]): - Messages reflecting the validation results. - code (str): - A custom code identifying this validation. - """ - class Status(proto.Enum): - r"""Validation execution status.""" - STATUS_UNSPECIFIED = 0 - NOT_EXECUTED = 1 - FAILED = 2 - PASSED = 3 - - description = proto.Field( - proto.STRING, - number=1, - ) - status = proto.Field( - proto.ENUM, - number=2, - enum=Status, - ) - message = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='ValidationMessage', - ) - code = proto.Field( - proto.STRING, - number=4, - ) - - -class ValidationMessage(proto.Message): - r"""Represent user-facing validation result message. - - Attributes: - message (str): - The result of the validation. - level (google.cloud.datastream_v1alpha1.types.ValidationMessage.Level): - Message severity level (warning or error). - metadata (Sequence[google.cloud.datastream_v1alpha1.types.ValidationMessage.MetadataEntry]): - Additional metadata related to the result. - code (str): - A custom code identifying this specific - message. - """ - class Level(proto.Enum): - r"""Validation message level.""" - LEVEL_UNSPECIFIED = 0 - WARNING = 1 - ERROR = 2 - - message = proto.Field( - proto.STRING, - number=1, - ) - level = proto.Field( - proto.ENUM, - number=2, - enum=Level, - ) - metadata = proto.MapField( - proto.STRING, - proto.STRING, - number=3, - ) - code = proto.Field( - proto.STRING, - number=4, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v1alpha1/mypy.ini b/owl-bot-staging/v1alpha1/mypy.ini deleted file mode 100644 index 4505b48..0000000 --- a/owl-bot-staging/v1alpha1/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.6 -namespace_packages = True diff --git a/owl-bot-staging/v1alpha1/noxfile.py b/owl-bot-staging/v1alpha1/noxfile.py deleted file mode 100644 index e5cac4e..0000000 --- a/owl-bot-staging/v1alpha1/noxfile.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") - - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", -] - -@nox.session(python=['3.6', '3.7', '3.8', '3.9', '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/datastream_v1alpha1/', - '--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/v1alpha1/scripts/fixup_datastream_v1alpha1_keywords.py b/owl-bot-staging/v1alpha1/scripts/fixup_datastream_v1alpha1_keywords.py deleted file mode 100644 index 636ec17..0000000 --- a/owl-bot-staging/v1alpha1/scripts/fixup_datastream_v1alpha1_keywords.py +++ /dev/null @@ -1,196 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class datastreamCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_connection_profile': ('parent', 'connection_profile_id', 'connection_profile', 'request_id', ), - 'create_private_connection': ('parent', 'private_connection_id', 'private_connection', 'request_id', ), - 'create_route': ('parent', 'route_id', 'route', 'request_id', ), - 'create_stream': ('parent', 'stream_id', 'stream', 'request_id', 'validate_only', 'force', ), - 'delete_connection_profile': ('name', 'request_id', ), - 'delete_private_connection': ('name', 'request_id', 'force', ), - 'delete_route': ('name', 'request_id', ), - 'delete_stream': ('name', 'request_id', ), - 'discover_connection_profile': ('parent', 'connection_profile', 'connection_profile_name', 'recursive', 'recursion_depth', 'oracle_rdbms', 'mysql_rdbms', ), - 'fetch_errors': ('stream', ), - 'fetch_static_ips': ('name', 'page_size', 'page_token', ), - 'get_connection_profile': ('name', ), - 'get_private_connection': ('name', ), - 'get_route': ('name', ), - 'get_stream': ('name', ), - 'list_connection_profiles': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_private_connections': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_routes': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_streams': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'update_connection_profile': ('connection_profile', 'update_mask', 'request_id', ), - 'update_stream': ('stream', 'update_mask', 'request_id', 'validate_only', 'force', ), - } - - 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=datastreamCallTransformer(), -): - """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 datastream 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/v1alpha1/setup.py b/owl-bot-staging/v1alpha1/setup.py deleted file mode 100644 index e819da1..0000000 --- a/owl-bot-staging/v1alpha1/setup.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import io -import os -import setuptools # type: ignore - -version = '0.1.0' - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, 'README.rst') -with io.open(readme_filename, encoding='utf-8') as readme_file: - readme = readme_file.read() - -setuptools.setup( - name='google-cloud-datastream', - 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.4', - ), - 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/v1alpha1/tests/__init__.py b/owl-bot-staging/v1alpha1/tests/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha1/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1alpha1/tests/unit/__init__.py b/owl-bot-staging/v1alpha1/tests/unit/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha1/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1alpha1/tests/unit/gapic/__init__.py b/owl-bot-staging/v1alpha1/tests/unit/gapic/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha1/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/__init__.py b/owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/__init__.py deleted file mode 100644 index b54a5fc..0000000 --- a/owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/test_datastream.py b/owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/test_datastream.py deleted file mode 100644 index 1c82416..0000000 --- a/owl-bot-staging/v1alpha1/tests/unit/gapic/datastream_v1alpha1/test_datastream.py +++ /dev/null @@ -1,6756 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -import mock - -import 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.datastream_v1alpha1.services.datastream import DatastreamAsyncClient -from google.cloud.datastream_v1alpha1.services.datastream import DatastreamClient -from google.cloud.datastream_v1alpha1.services.datastream import pagers -from google.cloud.datastream_v1alpha1.services.datastream import transports -from google.cloud.datastream_v1alpha1.types import datastream -from google.cloud.datastream_v1alpha1.types import datastream_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 DatastreamClient._get_default_mtls_endpoint(None) is None - assert DatastreamClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert DatastreamClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert DatastreamClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert DatastreamClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert DatastreamClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class", [ - DatastreamClient, - DatastreamAsyncClient, -]) -def test_datastream_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 == 'datastream.googleapis.com:443' - - -@pytest.mark.parametrize("transport_class,transport_name", [ - (transports.DatastreamGrpcTransport, "grpc"), - (transports.DatastreamGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_datastream_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", [ - DatastreamClient, - DatastreamAsyncClient, -]) -def test_datastream_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 == 'datastream.googleapis.com:443' - - -def test_datastream_client_get_transport_class(): - transport = DatastreamClient.get_transport_class() - available_transports = [ - transports.DatastreamGrpcTransport, - ] - assert transport in available_transports - - transport = DatastreamClient.get_transport_class("grpc") - assert transport == transports.DatastreamGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (DatastreamClient, transports.DatastreamGrpcTransport, "grpc"), - (DatastreamAsyncClient, transports.DatastreamGrpcAsyncIOTransport, "grpc_asyncio"), -]) -@mock.patch.object(DatastreamClient, "DEFAULT_ENDPOINT", modify_default_endpoint(DatastreamClient)) -@mock.patch.object(DatastreamAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(DatastreamAsyncClient)) -def test_datastream_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(DatastreamClient, '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(DatastreamClient, '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() - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError): - client = client_class() - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name, client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (DatastreamClient, transports.DatastreamGrpcTransport, "grpc", "true"), - (DatastreamAsyncClient, transports.DatastreamGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (DatastreamClient, transports.DatastreamGrpcTransport, "grpc", "false"), - (DatastreamAsyncClient, transports.DatastreamGrpcAsyncIOTransport, "grpc_asyncio", "false"), -]) -@mock.patch.object(DatastreamClient, "DEFAULT_ENDPOINT", modify_default_endpoint(DatastreamClient)) -@mock.patch.object(DatastreamAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(DatastreamAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_datastream_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(transport=transport_name, client_options=options) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class(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", [ - (DatastreamClient, transports.DatastreamGrpcTransport, "grpc"), - (DatastreamAsyncClient, transports.DatastreamGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_datastream_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(transport=transport_name, client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (DatastreamClient, transports.DatastreamGrpcTransport, "grpc"), - (DatastreamAsyncClient, transports.DatastreamGrpcAsyncIOTransport, "grpc_asyncio"), -]) -def test_datastream_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(transport=transport_name, client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -def test_datastream_client_client_options_from_dict(): - with mock.patch('google.cloud.datastream_v1alpha1.services.datastream.transports.DatastreamGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = DatastreamClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - ) - - -def test_list_connection_profiles(transport: str = 'grpc', request_type=datastream.ListConnectionProfilesRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_connection_profiles), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.ListConnectionProfilesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_connection_profiles(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.ListConnectionProfilesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListConnectionProfilesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_connection_profiles_from_dict(): - test_list_connection_profiles(request_type=dict) - - -def test_list_connection_profiles_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_connection_profiles), - '__call__') as call: - client.list_connection_profiles() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.ListConnectionProfilesRequest() - - -@pytest.mark.asyncio -async def test_list_connection_profiles_async(transport: str = 'grpc_asyncio', request_type=datastream.ListConnectionProfilesRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_connection_profiles), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListConnectionProfilesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_connection_profiles(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.ListConnectionProfilesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListConnectionProfilesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_connection_profiles_async_from_dict(): - await test_list_connection_profiles_async(request_type=dict) - - -def test_list_connection_profiles_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.ListConnectionProfilesRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_connection_profiles), - '__call__') as call: - call.return_value = datastream.ListConnectionProfilesResponse() - client.list_connection_profiles(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_connection_profiles_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.ListConnectionProfilesRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_connection_profiles), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListConnectionProfilesResponse()) - await client.list_connection_profiles(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_connection_profiles_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_connection_profiles), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.ListConnectionProfilesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_connection_profiles( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -def test_list_connection_profiles_flattened_error(): - client = DatastreamClient( - credentials=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_connection_profiles( - datastream.ListConnectionProfilesRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_connection_profiles_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_connection_profiles), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.ListConnectionProfilesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListConnectionProfilesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_connection_profiles( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_connection_profiles_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_connection_profiles( - datastream.ListConnectionProfilesRequest(), - parent='parent_value', - ) - - -def test_list_connection_profiles_pager(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_connection_profiles), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListConnectionProfilesResponse( - connection_profiles=[ - datastream_resources.ConnectionProfile(), - datastream_resources.ConnectionProfile(), - datastream_resources.ConnectionProfile(), - ], - next_page_token='abc', - ), - datastream.ListConnectionProfilesResponse( - connection_profiles=[], - next_page_token='def', - ), - datastream.ListConnectionProfilesResponse( - connection_profiles=[ - datastream_resources.ConnectionProfile(), - ], - next_page_token='ghi', - ), - datastream.ListConnectionProfilesResponse( - connection_profiles=[ - datastream_resources.ConnectionProfile(), - datastream_resources.ConnectionProfile(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_connection_profiles(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, datastream_resources.ConnectionProfile) - for i in results) - -def test_list_connection_profiles_pages(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_connection_profiles), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListConnectionProfilesResponse( - connection_profiles=[ - datastream_resources.ConnectionProfile(), - datastream_resources.ConnectionProfile(), - datastream_resources.ConnectionProfile(), - ], - next_page_token='abc', - ), - datastream.ListConnectionProfilesResponse( - connection_profiles=[], - next_page_token='def', - ), - datastream.ListConnectionProfilesResponse( - connection_profiles=[ - datastream_resources.ConnectionProfile(), - ], - next_page_token='ghi', - ), - datastream.ListConnectionProfilesResponse( - connection_profiles=[ - datastream_resources.ConnectionProfile(), - datastream_resources.ConnectionProfile(), - ], - ), - RuntimeError, - ) - pages = list(client.list_connection_profiles(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_connection_profiles_async_pager(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_connection_profiles), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListConnectionProfilesResponse( - connection_profiles=[ - datastream_resources.ConnectionProfile(), - datastream_resources.ConnectionProfile(), - datastream_resources.ConnectionProfile(), - ], - next_page_token='abc', - ), - datastream.ListConnectionProfilesResponse( - connection_profiles=[], - next_page_token='def', - ), - datastream.ListConnectionProfilesResponse( - connection_profiles=[ - datastream_resources.ConnectionProfile(), - ], - next_page_token='ghi', - ), - datastream.ListConnectionProfilesResponse( - connection_profiles=[ - datastream_resources.ConnectionProfile(), - datastream_resources.ConnectionProfile(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_connection_profiles(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, datastream_resources.ConnectionProfile) - for i in responses) - -@pytest.mark.asyncio -async def test_list_connection_profiles_async_pages(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_connection_profiles), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListConnectionProfilesResponse( - connection_profiles=[ - datastream_resources.ConnectionProfile(), - datastream_resources.ConnectionProfile(), - datastream_resources.ConnectionProfile(), - ], - next_page_token='abc', - ), - datastream.ListConnectionProfilesResponse( - connection_profiles=[], - next_page_token='def', - ), - datastream.ListConnectionProfilesResponse( - connection_profiles=[ - datastream_resources.ConnectionProfile(), - ], - next_page_token='ghi', - ), - datastream.ListConnectionProfilesResponse( - connection_profiles=[ - datastream_resources.ConnectionProfile(), - datastream_resources.ConnectionProfile(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_connection_profiles(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_get_connection_profile(transport: str = 'grpc', request_type=datastream.GetConnectionProfileRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_connection_profile), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream_resources.ConnectionProfile( - name='name_value', - display_name='display_name_value', - oracle_profile=datastream_resources.OracleProfile(hostname='hostname_value'), - no_connectivity=None, - ) - response = client.get_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.GetConnectionProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, datastream_resources.ConnectionProfile) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - - -def test_get_connection_profile_from_dict(): - test_get_connection_profile(request_type=dict) - - -def test_get_connection_profile_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_connection_profile), - '__call__') as call: - client.get_connection_profile() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.GetConnectionProfileRequest() - - -@pytest.mark.asyncio -async def test_get_connection_profile_async(transport: str = 'grpc_asyncio', request_type=datastream.GetConnectionProfileRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_connection_profile), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.ConnectionProfile( - name='name_value', - display_name='display_name_value', - )) - response = await client.get_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.GetConnectionProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, datastream_resources.ConnectionProfile) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - - -@pytest.mark.asyncio -async def test_get_connection_profile_async_from_dict(): - await test_get_connection_profile_async(request_type=dict) - - -def test_get_connection_profile_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.GetConnectionProfileRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_connection_profile), - '__call__') as call: - call.return_value = datastream_resources.ConnectionProfile() - client.get_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_connection_profile_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.GetConnectionProfileRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_connection_profile), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.ConnectionProfile()) - await client.get_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_connection_profile_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_connection_profile), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream_resources.ConnectionProfile() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_connection_profile( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_get_connection_profile_flattened_error(): - client = DatastreamClient( - credentials=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_connection_profile( - datastream.GetConnectionProfileRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_connection_profile_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_connection_profile), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream_resources.ConnectionProfile() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.ConnectionProfile()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_connection_profile( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_connection_profile_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_connection_profile( - datastream.GetConnectionProfileRequest(), - name='name_value', - ) - - -def test_create_connection_profile(transport: str = 'grpc', request_type=datastream.CreateConnectionProfileRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_connection_profile), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.CreateConnectionProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_connection_profile_from_dict(): - test_create_connection_profile(request_type=dict) - - -def test_create_connection_profile_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_connection_profile), - '__call__') as call: - client.create_connection_profile() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.CreateConnectionProfileRequest() - - -@pytest.mark.asyncio -async def test_create_connection_profile_async(transport: str = 'grpc_asyncio', request_type=datastream.CreateConnectionProfileRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_connection_profile), - '__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_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.CreateConnectionProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_connection_profile_async_from_dict(): - await test_create_connection_profile_async(request_type=dict) - - -def test_create_connection_profile_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.CreateConnectionProfileRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_connection_profile), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_connection_profile_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.CreateConnectionProfileRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_connection_profile), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_connection_profile_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_connection_profile), - '__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_connection_profile( - parent='parent_value', - connection_profile=datastream_resources.ConnectionProfile(name='name_value'), - connection_profile_id='connection_profile_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].connection_profile == datastream_resources.ConnectionProfile(name='name_value') - assert args[0].connection_profile_id == 'connection_profile_id_value' - - -def test_create_connection_profile_flattened_error(): - client = DatastreamClient( - credentials=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_connection_profile( - datastream.CreateConnectionProfileRequest(), - parent='parent_value', - connection_profile=datastream_resources.ConnectionProfile(name='name_value'), - connection_profile_id='connection_profile_id_value', - ) - - -@pytest.mark.asyncio -async def test_create_connection_profile_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_connection_profile), - '__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_connection_profile( - parent='parent_value', - connection_profile=datastream_resources.ConnectionProfile(name='name_value'), - connection_profile_id='connection_profile_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].connection_profile == datastream_resources.ConnectionProfile(name='name_value') - assert args[0].connection_profile_id == 'connection_profile_id_value' - - -@pytest.mark.asyncio -async def test_create_connection_profile_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_connection_profile( - datastream.CreateConnectionProfileRequest(), - parent='parent_value', - connection_profile=datastream_resources.ConnectionProfile(name='name_value'), - connection_profile_id='connection_profile_id_value', - ) - - -def test_update_connection_profile(transport: str = 'grpc', request_type=datastream.UpdateConnectionProfileRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_connection_profile), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.UpdateConnectionProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_connection_profile_from_dict(): - test_update_connection_profile(request_type=dict) - - -def test_update_connection_profile_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_connection_profile), - '__call__') as call: - client.update_connection_profile() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.UpdateConnectionProfileRequest() - - -@pytest.mark.asyncio -async def test_update_connection_profile_async(transport: str = 'grpc_asyncio', request_type=datastream.UpdateConnectionProfileRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_connection_profile), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.update_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.UpdateConnectionProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_connection_profile_async_from_dict(): - await test_update_connection_profile_async(request_type=dict) - - -def test_update_connection_profile_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.UpdateConnectionProfileRequest() - - request.connection_profile.name = 'connection_profile.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_connection_profile), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'connection_profile.name=connection_profile.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_connection_profile_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.UpdateConnectionProfileRequest() - - request.connection_profile.name = 'connection_profile.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_connection_profile), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'connection_profile.name=connection_profile.name/value', - ) in kw['metadata'] - - -def test_update_connection_profile_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_connection_profile), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_connection_profile( - connection_profile=datastream_resources.ConnectionProfile(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].connection_profile == datastream_resources.ConnectionProfile(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_connection_profile_flattened_error(): - client = DatastreamClient( - credentials=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_connection_profile( - datastream.UpdateConnectionProfileRequest(), - connection_profile=datastream_resources.ConnectionProfile(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_connection_profile_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_connection_profile), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_connection_profile( - connection_profile=datastream_resources.ConnectionProfile(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].connection_profile == datastream_resources.ConnectionProfile(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_connection_profile_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_connection_profile( - datastream.UpdateConnectionProfileRequest(), - connection_profile=datastream_resources.ConnectionProfile(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_delete_connection_profile(transport: str = 'grpc', request_type=datastream.DeleteConnectionProfileRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_connection_profile), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DeleteConnectionProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_connection_profile_from_dict(): - test_delete_connection_profile(request_type=dict) - - -def test_delete_connection_profile_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_connection_profile), - '__call__') as call: - client.delete_connection_profile() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DeleteConnectionProfileRequest() - - -@pytest.mark.asyncio -async def test_delete_connection_profile_async(transport: str = 'grpc_asyncio', request_type=datastream.DeleteConnectionProfileRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_connection_profile), - '__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_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DeleteConnectionProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_connection_profile_async_from_dict(): - await test_delete_connection_profile_async(request_type=dict) - - -def test_delete_connection_profile_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.DeleteConnectionProfileRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_connection_profile), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_connection_profile_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.DeleteConnectionProfileRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_connection_profile), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_connection_profile_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_connection_profile), - '__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_connection_profile( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_delete_connection_profile_flattened_error(): - client = DatastreamClient( - credentials=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_connection_profile( - datastream.DeleteConnectionProfileRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_connection_profile_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_connection_profile), - '__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_connection_profile( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_delete_connection_profile_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_connection_profile( - datastream.DeleteConnectionProfileRequest(), - name='name_value', - ) - - -def test_discover_connection_profile(transport: str = 'grpc', request_type=datastream.DiscoverConnectionProfileRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.discover_connection_profile), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.DiscoverConnectionProfileResponse( - oracle_rdbms=datastream_resources.OracleRdbms(oracle_schemas=[datastream_resources.OracleSchema(schema_name='schema_name_value')]), - ) - response = client.discover_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DiscoverConnectionProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, datastream.DiscoverConnectionProfileResponse) - - -def test_discover_connection_profile_from_dict(): - test_discover_connection_profile(request_type=dict) - - -def test_discover_connection_profile_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.discover_connection_profile), - '__call__') as call: - client.discover_connection_profile() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DiscoverConnectionProfileRequest() - - -@pytest.mark.asyncio -async def test_discover_connection_profile_async(transport: str = 'grpc_asyncio', request_type=datastream.DiscoverConnectionProfileRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.discover_connection_profile), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream.DiscoverConnectionProfileResponse( - )) - response = await client.discover_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DiscoverConnectionProfileRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, datastream.DiscoverConnectionProfileResponse) - - -@pytest.mark.asyncio -async def test_discover_connection_profile_async_from_dict(): - await test_discover_connection_profile_async(request_type=dict) - - -def test_discover_connection_profile_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.DiscoverConnectionProfileRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.discover_connection_profile), - '__call__') as call: - call.return_value = datastream.DiscoverConnectionProfileResponse() - client.discover_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_discover_connection_profile_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.DiscoverConnectionProfileRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.discover_connection_profile), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.DiscoverConnectionProfileResponse()) - await client.discover_connection_profile(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_streams(transport: str = 'grpc', request_type=datastream.ListStreamsRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.ListStreamsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_streams(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.ListStreamsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListStreamsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_streams_from_dict(): - test_list_streams(request_type=dict) - - -def test_list_streams_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_streams), - '__call__') as call: - client.list_streams() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.ListStreamsRequest() - - -@pytest.mark.asyncio -async def test_list_streams_async(transport: str = 'grpc_asyncio', request_type=datastream.ListStreamsRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListStreamsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_streams(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.ListStreamsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListStreamsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_streams_async_from_dict(): - await test_list_streams_async(request_type=dict) - - -def test_list_streams_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.ListStreamsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_streams), - '__call__') as call: - call.return_value = datastream.ListStreamsResponse() - client.list_streams(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_streams_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.ListStreamsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_streams), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListStreamsResponse()) - await client.list_streams(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_streams_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.ListStreamsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_streams( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -def test_list_streams_flattened_error(): - client = DatastreamClient( - credentials=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_streams( - datastream.ListStreamsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_streams_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_streams), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.ListStreamsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListStreamsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_streams( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_streams_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_streams( - datastream.ListStreamsRequest(), - parent='parent_value', - ) - - -def test_list_streams_pager(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_streams), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListStreamsResponse( - streams=[ - datastream_resources.Stream(), - datastream_resources.Stream(), - datastream_resources.Stream(), - ], - next_page_token='abc', - ), - datastream.ListStreamsResponse( - streams=[], - next_page_token='def', - ), - datastream.ListStreamsResponse( - streams=[ - datastream_resources.Stream(), - ], - next_page_token='ghi', - ), - datastream.ListStreamsResponse( - streams=[ - datastream_resources.Stream(), - datastream_resources.Stream(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_streams(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, datastream_resources.Stream) - for i in results) - -def test_list_streams_pages(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_streams), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListStreamsResponse( - streams=[ - datastream_resources.Stream(), - datastream_resources.Stream(), - datastream_resources.Stream(), - ], - next_page_token='abc', - ), - datastream.ListStreamsResponse( - streams=[], - next_page_token='def', - ), - datastream.ListStreamsResponse( - streams=[ - datastream_resources.Stream(), - ], - next_page_token='ghi', - ), - datastream.ListStreamsResponse( - streams=[ - datastream_resources.Stream(), - datastream_resources.Stream(), - ], - ), - RuntimeError, - ) - pages = list(client.list_streams(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_streams_async_pager(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_streams), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListStreamsResponse( - streams=[ - datastream_resources.Stream(), - datastream_resources.Stream(), - datastream_resources.Stream(), - ], - next_page_token='abc', - ), - datastream.ListStreamsResponse( - streams=[], - next_page_token='def', - ), - datastream.ListStreamsResponse( - streams=[ - datastream_resources.Stream(), - ], - next_page_token='ghi', - ), - datastream.ListStreamsResponse( - streams=[ - datastream_resources.Stream(), - datastream_resources.Stream(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_streams(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, datastream_resources.Stream) - for i in responses) - -@pytest.mark.asyncio -async def test_list_streams_async_pages(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_streams), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListStreamsResponse( - streams=[ - datastream_resources.Stream(), - datastream_resources.Stream(), - datastream_resources.Stream(), - ], - next_page_token='abc', - ), - datastream.ListStreamsResponse( - streams=[], - next_page_token='def', - ), - datastream.ListStreamsResponse( - streams=[ - datastream_resources.Stream(), - ], - next_page_token='ghi', - ), - datastream.ListStreamsResponse( - streams=[ - datastream_resources.Stream(), - datastream_resources.Stream(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_streams(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_get_stream(transport: str = 'grpc', request_type=datastream.GetStreamRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream_resources.Stream( - name='name_value', - display_name='display_name_value', - state=datastream_resources.Stream.State.CREATED, - backfill_all=datastream_resources.Stream.BackfillAllStrategy(oracle_excluded_objects=datastream_resources.OracleRdbms(oracle_schemas=[datastream_resources.OracleSchema(schema_name='schema_name_value')])), - ) - response = client.get_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.GetStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, datastream_resources.Stream) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.state == datastream_resources.Stream.State.CREATED - - -def test_get_stream_from_dict(): - test_get_stream(request_type=dict) - - -def test_get_stream_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_stream), - '__call__') as call: - client.get_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.GetStreamRequest() - - -@pytest.mark.asyncio -async def test_get_stream_async(transport: str = 'grpc_asyncio', request_type=datastream.GetStreamRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.Stream( - name='name_value', - display_name='display_name_value', - state=datastream_resources.Stream.State.CREATED, - )) - response = await client.get_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.GetStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, datastream_resources.Stream) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.state == datastream_resources.Stream.State.CREATED - - -@pytest.mark.asyncio -async def test_get_stream_async_from_dict(): - await test_get_stream_async(request_type=dict) - - -def test_get_stream_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.GetStreamRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_stream), - '__call__') as call: - call.return_value = datastream_resources.Stream() - client.get_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_stream_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.GetStreamRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.Stream()) - await client.get_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_stream_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream_resources.Stream() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_stream( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_get_stream_flattened_error(): - client = DatastreamClient( - credentials=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_stream( - datastream.GetStreamRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_stream_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream_resources.Stream() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.Stream()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_stream( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_stream_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_stream( - datastream.GetStreamRequest(), - name='name_value', - ) - - -def test_create_stream(transport: str = 'grpc', request_type=datastream.CreateStreamRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.CreateStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_stream_from_dict(): - test_create_stream(request_type=dict) - - -def test_create_stream_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_stream), - '__call__') as call: - client.create_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.CreateStreamRequest() - - -@pytest.mark.asyncio -async def test_create_stream_async(transport: str = 'grpc_asyncio', request_type=datastream.CreateStreamRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_stream), - '__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_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.CreateStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_stream_async_from_dict(): - await test_create_stream_async(request_type=dict) - - -def test_create_stream_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.CreateStreamRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_stream), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_stream_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.CreateStreamRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_stream_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_stream), - '__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_stream( - parent='parent_value', - stream=datastream_resources.Stream(name='name_value'), - stream_id='stream_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].stream == datastream_resources.Stream(name='name_value') - assert args[0].stream_id == 'stream_id_value' - - -def test_create_stream_flattened_error(): - client = DatastreamClient( - credentials=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_stream( - datastream.CreateStreamRequest(), - parent='parent_value', - stream=datastream_resources.Stream(name='name_value'), - stream_id='stream_id_value', - ) - - -@pytest.mark.asyncio -async def test_create_stream_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_stream), - '__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_stream( - parent='parent_value', - stream=datastream_resources.Stream(name='name_value'), - stream_id='stream_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].stream == datastream_resources.Stream(name='name_value') - assert args[0].stream_id == 'stream_id_value' - - -@pytest.mark.asyncio -async def test_create_stream_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_stream( - datastream.CreateStreamRequest(), - parent='parent_value', - stream=datastream_resources.Stream(name='name_value'), - stream_id='stream_id_value', - ) - - -def test_update_stream(transport: str = 'grpc', request_type=datastream.UpdateStreamRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.UpdateStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_stream_from_dict(): - test_update_stream(request_type=dict) - - -def test_update_stream_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_stream), - '__call__') as call: - client.update_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.UpdateStreamRequest() - - -@pytest.mark.asyncio -async def test_update_stream_async(transport: str = 'grpc_asyncio', request_type=datastream.UpdateStreamRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.update_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.UpdateStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_stream_async_from_dict(): - await test_update_stream_async(request_type=dict) - - -def test_update_stream_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.UpdateStreamRequest() - - request.stream.name = 'stream.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_stream), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'stream.name=stream.name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_stream_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.UpdateStreamRequest() - - request.stream.name = 'stream.name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'stream.name=stream.name/value', - ) in kw['metadata'] - - -def test_update_stream_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_stream( - stream=datastream_resources.Stream(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].stream == datastream_resources.Stream(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -def test_update_stream_flattened_error(): - client = DatastreamClient( - credentials=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_stream( - datastream.UpdateStreamRequest(), - stream=datastream_resources.Stream(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.asyncio -async def test_update_stream_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_stream( - stream=datastream_resources.Stream(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].stream == datastream_resources.Stream(name='name_value') - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=['paths_value']) - - -@pytest.mark.asyncio -async def test_update_stream_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_stream( - datastream.UpdateStreamRequest(), - stream=datastream_resources.Stream(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_delete_stream(transport: str = 'grpc', request_type=datastream.DeleteStreamRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_stream), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DeleteStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_stream_from_dict(): - test_delete_stream(request_type=dict) - - -def test_delete_stream_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_stream), - '__call__') as call: - client.delete_stream() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DeleteStreamRequest() - - -@pytest.mark.asyncio -async def test_delete_stream_async(transport: str = 'grpc_asyncio', request_type=datastream.DeleteStreamRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_stream), - '__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_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DeleteStreamRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_stream_async_from_dict(): - await test_delete_stream_async(request_type=dict) - - -def test_delete_stream_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.DeleteStreamRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_stream), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_stream_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.DeleteStreamRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_stream), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_stream(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_stream_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_stream), - '__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_stream( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_delete_stream_flattened_error(): - client = DatastreamClient( - credentials=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_stream( - datastream.DeleteStreamRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_stream_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_stream), - '__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_stream( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_delete_stream_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_stream( - datastream.DeleteStreamRequest(), - name='name_value', - ) - - -def test_fetch_errors(transport: str = 'grpc', request_type=datastream.FetchErrorsRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_errors), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.fetch_errors(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.FetchErrorsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_fetch_errors_from_dict(): - test_fetch_errors(request_type=dict) - - -def test_fetch_errors_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_errors), - '__call__') as call: - client.fetch_errors() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.FetchErrorsRequest() - - -@pytest.mark.asyncio -async def test_fetch_errors_async(transport: str = 'grpc_asyncio', request_type=datastream.FetchErrorsRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_errors), - '__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.fetch_errors(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.FetchErrorsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_fetch_errors_async_from_dict(): - await test_fetch_errors_async(request_type=dict) - - -def test_fetch_errors_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.FetchErrorsRequest() - - request.stream = 'stream/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_errors), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.fetch_errors(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'stream=stream/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_fetch_errors_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.FetchErrorsRequest() - - request.stream = 'stream/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_errors), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.fetch_errors(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'stream=stream/value', - ) in kw['metadata'] - - -def test_fetch_static_ips(transport: str = 'grpc', request_type=datastream.FetchStaticIpsRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_static_ips), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.FetchStaticIpsResponse( - static_ips=['static_ips_value'], - next_page_token='next_page_token_value', - ) - response = client.fetch_static_ips(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.FetchStaticIpsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.FetchStaticIpsPager) - assert response.static_ips == ['static_ips_value'] - assert response.next_page_token == 'next_page_token_value' - - -def test_fetch_static_ips_from_dict(): - test_fetch_static_ips(request_type=dict) - - -def test_fetch_static_ips_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_static_ips), - '__call__') as call: - client.fetch_static_ips() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.FetchStaticIpsRequest() - - -@pytest.mark.asyncio -async def test_fetch_static_ips_async(transport: str = 'grpc_asyncio', request_type=datastream.FetchStaticIpsRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_static_ips), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream.FetchStaticIpsResponse( - static_ips=['static_ips_value'], - next_page_token='next_page_token_value', - )) - response = await client.fetch_static_ips(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.FetchStaticIpsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.FetchStaticIpsAsyncPager) - assert response.static_ips == ['static_ips_value'] - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_fetch_static_ips_async_from_dict(): - await test_fetch_static_ips_async(request_type=dict) - - -def test_fetch_static_ips_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.FetchStaticIpsRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_static_ips), - '__call__') as call: - call.return_value = datastream.FetchStaticIpsResponse() - client.fetch_static_ips(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_fetch_static_ips_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.FetchStaticIpsRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_static_ips), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.FetchStaticIpsResponse()) - await client.fetch_static_ips(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name/value', - ) in kw['metadata'] - - -def test_fetch_static_ips_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_static_ips), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.FetchStaticIpsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.fetch_static_ips( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_fetch_static_ips_flattened_error(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.fetch_static_ips( - datastream.FetchStaticIpsRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_fetch_static_ips_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_static_ips), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.FetchStaticIpsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.FetchStaticIpsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.fetch_static_ips( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_fetch_static_ips_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.fetch_static_ips( - datastream.FetchStaticIpsRequest(), - name='name_value', - ) - - -def test_fetch_static_ips_pager(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_static_ips), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.FetchStaticIpsResponse( - static_ips=[ - str(), - str(), - str(), - ], - next_page_token='abc', - ), - datastream.FetchStaticIpsResponse( - static_ips=[], - next_page_token='def', - ), - datastream.FetchStaticIpsResponse( - static_ips=[ - str(), - ], - next_page_token='ghi', - ), - datastream.FetchStaticIpsResponse( - static_ips=[ - str(), - str(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('name', ''), - )), - ) - pager = client.fetch_static_ips(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, str) - for i in results) - -def test_fetch_static_ips_pages(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_static_ips), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.FetchStaticIpsResponse( - static_ips=[ - str(), - str(), - str(), - ], - next_page_token='abc', - ), - datastream.FetchStaticIpsResponse( - static_ips=[], - next_page_token='def', - ), - datastream.FetchStaticIpsResponse( - static_ips=[ - str(), - ], - next_page_token='ghi', - ), - datastream.FetchStaticIpsResponse( - static_ips=[ - str(), - str(), - ], - ), - RuntimeError, - ) - pages = list(client.fetch_static_ips(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_fetch_static_ips_async_pager(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_static_ips), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.FetchStaticIpsResponse( - static_ips=[ - str(), - str(), - str(), - ], - next_page_token='abc', - ), - datastream.FetchStaticIpsResponse( - static_ips=[], - next_page_token='def', - ), - datastream.FetchStaticIpsResponse( - static_ips=[ - str(), - ], - next_page_token='ghi', - ), - datastream.FetchStaticIpsResponse( - static_ips=[ - str(), - str(), - ], - ), - RuntimeError, - ) - async_pager = await client.fetch_static_ips(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, str) - for i in responses) - -@pytest.mark.asyncio -async def test_fetch_static_ips_async_pages(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.fetch_static_ips), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.FetchStaticIpsResponse( - static_ips=[ - str(), - str(), - str(), - ], - next_page_token='abc', - ), - datastream.FetchStaticIpsResponse( - static_ips=[], - next_page_token='def', - ), - datastream.FetchStaticIpsResponse( - static_ips=[ - str(), - ], - next_page_token='ghi', - ), - datastream.FetchStaticIpsResponse( - static_ips=[ - str(), - str(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.fetch_static_ips(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_create_private_connection(transport: str = 'grpc', request_type=datastream.CreatePrivateConnectionRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_private_connection), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_private_connection(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.CreatePrivateConnectionRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_private_connection_from_dict(): - test_create_private_connection(request_type=dict) - - -def test_create_private_connection_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_private_connection), - '__call__') as call: - client.create_private_connection() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.CreatePrivateConnectionRequest() - - -@pytest.mark.asyncio -async def test_create_private_connection_async(transport: str = 'grpc_asyncio', request_type=datastream.CreatePrivateConnectionRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_private_connection), - '__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_private_connection(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.CreatePrivateConnectionRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_private_connection_async_from_dict(): - await test_create_private_connection_async(request_type=dict) - - -def test_create_private_connection_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.CreatePrivateConnectionRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_private_connection), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_private_connection(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_private_connection_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.CreatePrivateConnectionRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_private_connection), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_private_connection(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_private_connection_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_private_connection), - '__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_private_connection( - parent='parent_value', - private_connection=datastream_resources.PrivateConnection(name='name_value'), - private_connection_id='private_connection_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].private_connection == datastream_resources.PrivateConnection(name='name_value') - assert args[0].private_connection_id == 'private_connection_id_value' - - -def test_create_private_connection_flattened_error(): - client = DatastreamClient( - credentials=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_private_connection( - datastream.CreatePrivateConnectionRequest(), - parent='parent_value', - private_connection=datastream_resources.PrivateConnection(name='name_value'), - private_connection_id='private_connection_id_value', - ) - - -@pytest.mark.asyncio -async def test_create_private_connection_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_private_connection), - '__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_private_connection( - parent='parent_value', - private_connection=datastream_resources.PrivateConnection(name='name_value'), - private_connection_id='private_connection_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].private_connection == datastream_resources.PrivateConnection(name='name_value') - assert args[0].private_connection_id == 'private_connection_id_value' - - -@pytest.mark.asyncio -async def test_create_private_connection_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_private_connection( - datastream.CreatePrivateConnectionRequest(), - parent='parent_value', - private_connection=datastream_resources.PrivateConnection(name='name_value'), - private_connection_id='private_connection_id_value', - ) - - -def test_get_private_connection(transport: str = 'grpc', request_type=datastream.GetPrivateConnectionRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_private_connection), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream_resources.PrivateConnection( - name='name_value', - display_name='display_name_value', - state=datastream_resources.PrivateConnection.State.CREATING, - ) - response = client.get_private_connection(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.GetPrivateConnectionRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, datastream_resources.PrivateConnection) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.state == datastream_resources.PrivateConnection.State.CREATING - - -def test_get_private_connection_from_dict(): - test_get_private_connection(request_type=dict) - - -def test_get_private_connection_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_private_connection), - '__call__') as call: - client.get_private_connection() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.GetPrivateConnectionRequest() - - -@pytest.mark.asyncio -async def test_get_private_connection_async(transport: str = 'grpc_asyncio', request_type=datastream.GetPrivateConnectionRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_private_connection), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.PrivateConnection( - name='name_value', - display_name='display_name_value', - state=datastream_resources.PrivateConnection.State.CREATING, - )) - response = await client.get_private_connection(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.GetPrivateConnectionRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, datastream_resources.PrivateConnection) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.state == datastream_resources.PrivateConnection.State.CREATING - - -@pytest.mark.asyncio -async def test_get_private_connection_async_from_dict(): - await test_get_private_connection_async(request_type=dict) - - -def test_get_private_connection_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.GetPrivateConnectionRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_private_connection), - '__call__') as call: - call.return_value = datastream_resources.PrivateConnection() - client.get_private_connection(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_private_connection_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.GetPrivateConnectionRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_private_connection), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.PrivateConnection()) - await client.get_private_connection(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_private_connection_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_private_connection), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream_resources.PrivateConnection() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_private_connection( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_get_private_connection_flattened_error(): - client = DatastreamClient( - credentials=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_private_connection( - datastream.GetPrivateConnectionRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_private_connection_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_private_connection), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream_resources.PrivateConnection() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.PrivateConnection()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_private_connection( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_private_connection_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_private_connection( - datastream.GetPrivateConnectionRequest(), - name='name_value', - ) - - -def test_list_private_connections(transport: str = 'grpc', request_type=datastream.ListPrivateConnectionsRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_private_connections), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.ListPrivateConnectionsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_private_connections(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.ListPrivateConnectionsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPrivateConnectionsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_private_connections_from_dict(): - test_list_private_connections(request_type=dict) - - -def test_list_private_connections_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_private_connections), - '__call__') as call: - client.list_private_connections() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.ListPrivateConnectionsRequest() - - -@pytest.mark.asyncio -async def test_list_private_connections_async(transport: str = 'grpc_asyncio', request_type=datastream.ListPrivateConnectionsRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_private_connections), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListPrivateConnectionsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_private_connections(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.ListPrivateConnectionsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPrivateConnectionsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_private_connections_async_from_dict(): - await test_list_private_connections_async(request_type=dict) - - -def test_list_private_connections_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.ListPrivateConnectionsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_private_connections), - '__call__') as call: - call.return_value = datastream.ListPrivateConnectionsResponse() - client.list_private_connections(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_private_connections_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.ListPrivateConnectionsRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_private_connections), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListPrivateConnectionsResponse()) - await client.list_private_connections(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_private_connections_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_private_connections), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.ListPrivateConnectionsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_private_connections( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -def test_list_private_connections_flattened_error(): - client = DatastreamClient( - credentials=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_private_connections( - datastream.ListPrivateConnectionsRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_private_connections_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_private_connections), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.ListPrivateConnectionsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListPrivateConnectionsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_private_connections( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_private_connections_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_private_connections( - datastream.ListPrivateConnectionsRequest(), - parent='parent_value', - ) - - -def test_list_private_connections_pager(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_private_connections), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListPrivateConnectionsResponse( - private_connections=[ - datastream_resources.PrivateConnection(), - datastream_resources.PrivateConnection(), - datastream_resources.PrivateConnection(), - ], - next_page_token='abc', - ), - datastream.ListPrivateConnectionsResponse( - private_connections=[], - next_page_token='def', - ), - datastream.ListPrivateConnectionsResponse( - private_connections=[ - datastream_resources.PrivateConnection(), - ], - next_page_token='ghi', - ), - datastream.ListPrivateConnectionsResponse( - private_connections=[ - datastream_resources.PrivateConnection(), - datastream_resources.PrivateConnection(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_private_connections(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, datastream_resources.PrivateConnection) - for i in results) - -def test_list_private_connections_pages(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_private_connections), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListPrivateConnectionsResponse( - private_connections=[ - datastream_resources.PrivateConnection(), - datastream_resources.PrivateConnection(), - datastream_resources.PrivateConnection(), - ], - next_page_token='abc', - ), - datastream.ListPrivateConnectionsResponse( - private_connections=[], - next_page_token='def', - ), - datastream.ListPrivateConnectionsResponse( - private_connections=[ - datastream_resources.PrivateConnection(), - ], - next_page_token='ghi', - ), - datastream.ListPrivateConnectionsResponse( - private_connections=[ - datastream_resources.PrivateConnection(), - datastream_resources.PrivateConnection(), - ], - ), - RuntimeError, - ) - pages = list(client.list_private_connections(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_private_connections_async_pager(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_private_connections), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListPrivateConnectionsResponse( - private_connections=[ - datastream_resources.PrivateConnection(), - datastream_resources.PrivateConnection(), - datastream_resources.PrivateConnection(), - ], - next_page_token='abc', - ), - datastream.ListPrivateConnectionsResponse( - private_connections=[], - next_page_token='def', - ), - datastream.ListPrivateConnectionsResponse( - private_connections=[ - datastream_resources.PrivateConnection(), - ], - next_page_token='ghi', - ), - datastream.ListPrivateConnectionsResponse( - private_connections=[ - datastream_resources.PrivateConnection(), - datastream_resources.PrivateConnection(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_private_connections(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, datastream_resources.PrivateConnection) - for i in responses) - -@pytest.mark.asyncio -async def test_list_private_connections_async_pages(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_private_connections), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListPrivateConnectionsResponse( - private_connections=[ - datastream_resources.PrivateConnection(), - datastream_resources.PrivateConnection(), - datastream_resources.PrivateConnection(), - ], - next_page_token='abc', - ), - datastream.ListPrivateConnectionsResponse( - private_connections=[], - next_page_token='def', - ), - datastream.ListPrivateConnectionsResponse( - private_connections=[ - datastream_resources.PrivateConnection(), - ], - next_page_token='ghi', - ), - datastream.ListPrivateConnectionsResponse( - private_connections=[ - datastream_resources.PrivateConnection(), - datastream_resources.PrivateConnection(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_private_connections(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_delete_private_connection(transport: str = 'grpc', request_type=datastream.DeletePrivateConnectionRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_private_connection), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_private_connection(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DeletePrivateConnectionRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_private_connection_from_dict(): - test_delete_private_connection(request_type=dict) - - -def test_delete_private_connection_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_private_connection), - '__call__') as call: - client.delete_private_connection() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DeletePrivateConnectionRequest() - - -@pytest.mark.asyncio -async def test_delete_private_connection_async(transport: str = 'grpc_asyncio', request_type=datastream.DeletePrivateConnectionRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_private_connection), - '__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_private_connection(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DeletePrivateConnectionRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_private_connection_async_from_dict(): - await test_delete_private_connection_async(request_type=dict) - - -def test_delete_private_connection_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.DeletePrivateConnectionRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_private_connection), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_private_connection(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_private_connection_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.DeletePrivateConnectionRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_private_connection), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_private_connection(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_private_connection_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_private_connection), - '__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_private_connection( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_delete_private_connection_flattened_error(): - client = DatastreamClient( - credentials=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_private_connection( - datastream.DeletePrivateConnectionRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_private_connection_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_private_connection), - '__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_private_connection( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_delete_private_connection_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_private_connection( - datastream.DeletePrivateConnectionRequest(), - name='name_value', - ) - - -def test_create_route(transport: str = 'grpc', request_type=datastream.CreateRouteRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_route), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_route(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.CreateRouteRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_route_from_dict(): - test_create_route(request_type=dict) - - -def test_create_route_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_route), - '__call__') as call: - client.create_route() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.CreateRouteRequest() - - -@pytest.mark.asyncio -async def test_create_route_async(transport: str = 'grpc_asyncio', request_type=datastream.CreateRouteRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_route), - '__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_route(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.CreateRouteRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_route_async_from_dict(): - await test_create_route_async(request_type=dict) - - -def test_create_route_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.CreateRouteRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_route), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_route(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_route_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.CreateRouteRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_route), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_route(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_route_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_route), - '__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_route( - parent='parent_value', - route=datastream_resources.Route(name='name_value'), - route_id='route_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].route == datastream_resources.Route(name='name_value') - assert args[0].route_id == 'route_id_value' - - -def test_create_route_flattened_error(): - client = DatastreamClient( - credentials=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_route( - datastream.CreateRouteRequest(), - parent='parent_value', - route=datastream_resources.Route(name='name_value'), - route_id='route_id_value', - ) - - -@pytest.mark.asyncio -async def test_create_route_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_route), - '__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_route( - parent='parent_value', - route=datastream_resources.Route(name='name_value'), - route_id='route_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - assert args[0].route == datastream_resources.Route(name='name_value') - assert args[0].route_id == 'route_id_value' - - -@pytest.mark.asyncio -async def test_create_route_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_route( - datastream.CreateRouteRequest(), - parent='parent_value', - route=datastream_resources.Route(name='name_value'), - route_id='route_id_value', - ) - - -def test_get_route(transport: str = 'grpc', request_type=datastream.GetRouteRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_route), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream_resources.Route( - name='name_value', - display_name='display_name_value', - destination_address='destination_address_value', - destination_port=1734, - ) - response = client.get_route(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.GetRouteRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, datastream_resources.Route) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.destination_address == 'destination_address_value' - assert response.destination_port == 1734 - - -def test_get_route_from_dict(): - test_get_route(request_type=dict) - - -def test_get_route_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_route), - '__call__') as call: - client.get_route() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.GetRouteRequest() - - -@pytest.mark.asyncio -async def test_get_route_async(transport: str = 'grpc_asyncio', request_type=datastream.GetRouteRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_route), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.Route( - name='name_value', - display_name='display_name_value', - destination_address='destination_address_value', - destination_port=1734, - )) - response = await client.get_route(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.GetRouteRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, datastream_resources.Route) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.destination_address == 'destination_address_value' - assert response.destination_port == 1734 - - -@pytest.mark.asyncio -async def test_get_route_async_from_dict(): - await test_get_route_async(request_type=dict) - - -def test_get_route_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.GetRouteRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_route), - '__call__') as call: - call.return_value = datastream_resources.Route() - client.get_route(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_route_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.GetRouteRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_route), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.Route()) - await client.get_route(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_route_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_route), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream_resources.Route() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_route( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_get_route_flattened_error(): - client = DatastreamClient( - credentials=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_route( - datastream.GetRouteRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_get_route_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_route), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream_resources.Route() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream_resources.Route()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_route( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_route_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_route( - datastream.GetRouteRequest(), - name='name_value', - ) - - -def test_list_routes(transport: str = 'grpc', request_type=datastream.ListRoutesRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_routes), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.ListRoutesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_routes(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.ListRoutesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRoutesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_routes_from_dict(): - test_list_routes(request_type=dict) - - -def test_list_routes_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_routes), - '__call__') as call: - client.list_routes() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.ListRoutesRequest() - - -@pytest.mark.asyncio -async def test_list_routes_async(transport: str = 'grpc_asyncio', request_type=datastream.ListRoutesRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_routes), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListRoutesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_routes(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.ListRoutesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRoutesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_routes_async_from_dict(): - await test_list_routes_async(request_type=dict) - - -def test_list_routes_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.ListRoutesRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_routes), - '__call__') as call: - call.return_value = datastream.ListRoutesResponse() - client.list_routes(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.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_routes_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.ListRoutesRequest() - - request.parent = 'parent/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_routes), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListRoutesResponse()) - await client.list_routes(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.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_routes_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_routes), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.ListRoutesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_routes( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -def test_list_routes_flattened_error(): - client = DatastreamClient( - credentials=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_routes( - datastream.ListRoutesRequest(), - parent='parent_value', - ) - - -@pytest.mark.asyncio -async def test_list_routes_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_routes), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = datastream.ListRoutesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(datastream.ListRoutesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_routes( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].parent == 'parent_value' - - -@pytest.mark.asyncio -async def test_list_routes_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_routes( - datastream.ListRoutesRequest(), - parent='parent_value', - ) - - -def test_list_routes_pager(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_routes), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListRoutesResponse( - routes=[ - datastream_resources.Route(), - datastream_resources.Route(), - datastream_resources.Route(), - ], - next_page_token='abc', - ), - datastream.ListRoutesResponse( - routes=[], - next_page_token='def', - ), - datastream.ListRoutesResponse( - routes=[ - datastream_resources.Route(), - ], - next_page_token='ghi', - ), - datastream.ListRoutesResponse( - routes=[ - datastream_resources.Route(), - datastream_resources.Route(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_routes(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, datastream_resources.Route) - for i in results) - -def test_list_routes_pages(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_routes), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListRoutesResponse( - routes=[ - datastream_resources.Route(), - datastream_resources.Route(), - datastream_resources.Route(), - ], - next_page_token='abc', - ), - datastream.ListRoutesResponse( - routes=[], - next_page_token='def', - ), - datastream.ListRoutesResponse( - routes=[ - datastream_resources.Route(), - ], - next_page_token='ghi', - ), - datastream.ListRoutesResponse( - routes=[ - datastream_resources.Route(), - datastream_resources.Route(), - ], - ), - RuntimeError, - ) - pages = list(client.list_routes(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_routes_async_pager(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_routes), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListRoutesResponse( - routes=[ - datastream_resources.Route(), - datastream_resources.Route(), - datastream_resources.Route(), - ], - next_page_token='abc', - ), - datastream.ListRoutesResponse( - routes=[], - next_page_token='def', - ), - datastream.ListRoutesResponse( - routes=[ - datastream_resources.Route(), - ], - next_page_token='ghi', - ), - datastream.ListRoutesResponse( - routes=[ - datastream_resources.Route(), - datastream_resources.Route(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_routes(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, datastream_resources.Route) - for i in responses) - -@pytest.mark.asyncio -async def test_list_routes_async_pages(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_routes), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - datastream.ListRoutesResponse( - routes=[ - datastream_resources.Route(), - datastream_resources.Route(), - datastream_resources.Route(), - ], - next_page_token='abc', - ), - datastream.ListRoutesResponse( - routes=[], - next_page_token='def', - ), - datastream.ListRoutesResponse( - routes=[ - datastream_resources.Route(), - ], - next_page_token='ghi', - ), - datastream.ListRoutesResponse( - routes=[ - datastream_resources.Route(), - datastream_resources.Route(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.list_routes(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -def test_delete_route(transport: str = 'grpc', request_type=datastream.DeleteRouteRequest): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_route), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_route(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DeleteRouteRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_route_from_dict(): - test_delete_route(request_type=dict) - - -def test_delete_route_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = DatastreamClient( - credentials=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_route), - '__call__') as call: - client.delete_route() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DeleteRouteRequest() - - -@pytest.mark.asyncio -async def test_delete_route_async(transport: str = 'grpc_asyncio', request_type=datastream.DeleteRouteRequest): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an 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_route), - '__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_route(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == datastream.DeleteRouteRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_route_async_from_dict(): - await test_delete_route_async(request_type=dict) - - -def test_delete_route_field_headers(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.DeleteRouteRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_route), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_route(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == 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_route_field_headers_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = datastream.DeleteRouteRequest() - - request.name = 'name/value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_route), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_route(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == 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_route_flattened(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_route), - '__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_route( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -def test_delete_route_flattened_error(): - client = DatastreamClient( - credentials=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_route( - datastream.DeleteRouteRequest(), - name='name_value', - ) - - -@pytest.mark.asyncio -async def test_delete_route_flattened_async(): - client = DatastreamAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_route), - '__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_route( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0].name == 'name_value' - - -@pytest.mark.asyncio -async def test_delete_route_flattened_error_async(): - client = DatastreamAsyncClient( - credentials=ga_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_route( - datastream.DeleteRouteRequest(), - name='name_value', - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.DatastreamGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.DatastreamGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = DatastreamClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.DatastreamGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = DatastreamClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.DatastreamGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = DatastreamClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.DatastreamGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.DatastreamGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.DatastreamGrpcTransport, - transports.DatastreamGrpcAsyncIOTransport, -]) -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 = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.DatastreamGrpcTransport, - ) - -def test_datastream_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.DatastreamTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_datastream_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.datastream_v1alpha1.services.datastream.transports.DatastreamTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.DatastreamTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'list_connection_profiles', - 'get_connection_profile', - 'create_connection_profile', - 'update_connection_profile', - 'delete_connection_profile', - 'discover_connection_profile', - 'list_streams', - 'get_stream', - 'create_stream', - 'update_stream', - 'delete_stream', - 'fetch_errors', - 'fetch_static_ips', - 'create_private_connection', - 'get_private_connection', - 'list_private_connections', - 'delete_private_connection', - 'create_route', - 'get_route', - 'list_routes', - 'delete_route', - ) - 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_datastream_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.datastream_v1alpha1.services.datastream.transports.DatastreamTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.DatastreamTransport( - 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_datastream_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.datastream_v1alpha1.services.datastream.transports.DatastreamTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.DatastreamTransport() - adc.assert_called_once() - - -def test_datastream_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) - DatastreamClient() - 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.DatastreamGrpcTransport, - transports.DatastreamGrpcAsyncIOTransport, - ], -) -def test_datastream_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.DatastreamGrpcTransport, grpc_helpers), - (transports.DatastreamGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_datastream_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( - "datastream.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="datastream.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.DatastreamGrpcTransport, transports.DatastreamGrpcAsyncIOTransport]) -def test_datastream_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_datastream_host_no_port(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='datastream.googleapis.com'), - ) - assert client.transport._host == 'datastream.googleapis.com:443' - - -def test_datastream_host_with_port(): - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='datastream.googleapis.com:8000'), - ) - assert client.transport._host == 'datastream.googleapis.com:8000' - -def test_datastream_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.DatastreamGrpcTransport( - 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_datastream_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.DatastreamGrpcAsyncIOTransport( - 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.DatastreamGrpcTransport, transports.DatastreamGrpcAsyncIOTransport]) -def test_datastream_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.DatastreamGrpcTransport, transports.DatastreamGrpcAsyncIOTransport]) -def test_datastream_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_datastream_grpc_lro_client(): - client = DatastreamClient( - 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_datastream_grpc_lro_async_client(): - client = DatastreamAsyncClient( - 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_connection_profile_path(): - project = "squid" - location = "clam" - connection_profile = "whelk" - expected = "projects/{project}/locations/{location}/connectionProfiles/{connection_profile}".format(project=project, location=location, connection_profile=connection_profile, ) - actual = DatastreamClient.connection_profile_path(project, location, connection_profile) - assert expected == actual - - -def test_parse_connection_profile_path(): - expected = { - "project": "octopus", - "location": "oyster", - "connection_profile": "nudibranch", - } - path = DatastreamClient.connection_profile_path(**expected) - - # Check that the path construction is reversible. - actual = DatastreamClient.parse_connection_profile_path(path) - assert expected == actual - -def test_private_connection_path(): - project = "cuttlefish" - location = "mussel" - private_connection = "winkle" - expected = "projects/{project}/locations/{location}/privateConnections/{private_connection}".format(project=project, location=location, private_connection=private_connection, ) - actual = DatastreamClient.private_connection_path(project, location, private_connection) - assert expected == actual - - -def test_parse_private_connection_path(): - expected = { - "project": "nautilus", - "location": "scallop", - "private_connection": "abalone", - } - path = DatastreamClient.private_connection_path(**expected) - - # Check that the path construction is reversible. - actual = DatastreamClient.parse_private_connection_path(path) - assert expected == actual - -def test_route_path(): - project = "squid" - location = "clam" - private_connection = "whelk" - route = "octopus" - expected = "projects/{project}/locations/{location}/privateConnections/{private_connection}/routes/{route}".format(project=project, location=location, private_connection=private_connection, route=route, ) - actual = DatastreamClient.route_path(project, location, private_connection, route) - assert expected == actual - - -def test_parse_route_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - "private_connection": "cuttlefish", - "route": "mussel", - } - path = DatastreamClient.route_path(**expected) - - # Check that the path construction is reversible. - actual = DatastreamClient.parse_route_path(path) - assert expected == actual - -def test_stream_path(): - project = "winkle" - location = "nautilus" - stream = "scallop" - expected = "projects/{project}/locations/{location}/streams/{stream}".format(project=project, location=location, stream=stream, ) - actual = DatastreamClient.stream_path(project, location, stream) - assert expected == actual - - -def test_parse_stream_path(): - expected = { - "project": "abalone", - "location": "squid", - "stream": "clam", - } - path = DatastreamClient.stream_path(**expected) - - # Check that the path construction is reversible. - actual = DatastreamClient.parse_stream_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "whelk" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = DatastreamClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "octopus", - } - path = DatastreamClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = DatastreamClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "oyster" - expected = "folders/{folder}".format(folder=folder, ) - actual = DatastreamClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nudibranch", - } - path = DatastreamClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = DatastreamClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization, ) - actual = DatastreamClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "mussel", - } - path = DatastreamClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = DatastreamClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "winkle" - expected = "projects/{project}".format(project=project, ) - actual = DatastreamClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "nautilus", - } - path = DatastreamClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = DatastreamClient.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 = DatastreamClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "squid", - "location": "clam", - } - path = DatastreamClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = DatastreamClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_withDEFAULT_CLIENT_INFO(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object(transports.DatastreamTransport, '_prep_wrapped_messages') as prep: - client = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.DatastreamTransport, '_prep_wrapped_messages') as prep: - transport_class = DatastreamClient.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 = DatastreamAsyncClient( - 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 = DatastreamClient( - 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 = DatastreamClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport - ) - # Test client calls underlying transport. - with mock.patch.object(type(client.transport), "close") as close: - close.assert_not_called() - with client: - pass - close.assert_called() diff --git a/tests/unit/gapic/datastream_v1alpha1/test_datastream.py b/tests/unit/gapic/datastream_v1alpha1/test_datastream.py index 116b55e..efd3ae3 100644 --- a/tests/unit/gapic/datastream_v1alpha1/test_datastream.py +++ b/tests/unit/gapic/datastream_v1alpha1/test_datastream.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -39,9 +38,6 @@ from google.cloud.datastream_v1alpha1.services.datastream import DatastreamClient from google.cloud.datastream_v1alpha1.services.datastream import pagers from google.cloud.datastream_v1alpha1.services.datastream import transports -from google.cloud.datastream_v1alpha1.services.datastream.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.datastream_v1alpha1.types import datastream from google.cloud.datastream_v1alpha1.types import datastream_resources from google.longrunning import operations_pb2 @@ -52,20 +48,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -213,7 +195,7 @@ def test_datastream_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -230,7 +212,7 @@ def test_datastream_client_client_options( 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() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -247,7 +229,7 @@ def test_datastream_client_client_options( 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() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -276,7 +258,7 @@ def test_datastream_client_client_options( 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) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -333,7 +315,7 @@ def test_datastream_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -375,7 +357,7 @@ def test_datastream_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -397,7 +379,7 @@ def test_datastream_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -428,7 +410,7 @@ def test_datastream_client_client_options_scopes( 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) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -459,7 +441,7 @@ def test_datastream_client_client_options_credentials_file( 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) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -5696,7 +5678,6 @@ def test_datastream_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_datastream_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -5717,26 +5698,6 @@ def test_datastream_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_datastream_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.datastream_v1alpha1.services.datastream.transports.DatastreamTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.DatastreamTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_datastream_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( @@ -5748,7 +5709,6 @@ def test_datastream_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_datastream_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -5761,23 +5721,10 @@ def test_datastream_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_datastream_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - DatastreamClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [transports.DatastreamGrpcTransport, transports.DatastreamGrpcAsyncIOTransport,], ) -@requires_google_auth_gte_1_25_0 def test_datastream_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -5791,23 +5738,6 @@ def test_datastream_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [transports.DatastreamGrpcTransport, transports.DatastreamGrpcAsyncIOTransport,], -) -@requires_google_auth_lt_1_25_0 -def test_datastream_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ From 4b9a2a166bc213ec179b9eb3367e1e202cdfc591 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Sat, 30 Oct 2021 15:14:29 +0000 Subject: [PATCH 3/4] fix(deps): require google-api-core 1.28.0 --- setup.py | 2 +- testing/constraints-3.6.txt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 523d6d5..85ffaf6 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ # NOTE: Maintainers, please do not require google-api-core>=2.x.x # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 - "google-api-core[grpc] >= 1.26.0, <3.0.0dev", + "google-api-core[grpc] >= 1.28.0, <3.0.0dev", "proto-plus >= 1.15.0", "packaging >= 14.3", ] diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index fe11de2..c91fb73 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -4,7 +4,6 @@ # Pin the version to the lower bound. # e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", # Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.26.0 +google-api-core==1.28.0 proto-plus==1.15.0 packaging==14.3 -google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 si transitively required through google-api-core \ No newline at end of file From c287e9d2c1a60942b12041f7ee52de657df1d262 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Sat, 30 Oct 2021 19:56:46 +0000 Subject: [PATCH 4/4] fix(deps): drop packaging dependency --- setup.py | 1 - testing/constraints-3.6.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/setup.py b/setup.py index 85ffaf6..b23f9c2 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,6 @@ # https://github.com/googleapis/google-cloud-python/issues/10566 "google-api-core[grpc] >= 1.28.0, <3.0.0dev", "proto-plus >= 1.15.0", - "packaging >= 14.3", ] package_root = os.path.abspath(os.path.dirname(__file__)) diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index c91fb73..1e3ec8b 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -6,4 +6,3 @@ # Then this file should have google-cloud-foo==1.14.0 google-api-core==1.28.0 proto-plus==1.15.0 -packaging==14.3